テレグラム用のテレポット API ラッパーを使用してカードベースのゲーム ボットを作成しようとしていますが、水平レイアウトではなく垂直レイアウトを使用する方法がわかりません。
サンプルコード:
keyboard = []
for card in data['current_games'][userGame]['players'][messageLocationID]['cards']:
button = [KeyboardButton(text=card)]
keyboard += button
次に、sendMessage() メソッドを ReplyKeyboardMarkup() メソッドと一緒に使用しますが、縦長で横長のボタンの列が作成され、テキストの表示に影響します。
私が行方不明のステップはありますか?次を使用してキーの正方形を作成できました。
keyboard = [[KeyboardButton(text='0'), KeyboardButton(text='1'), KeyboardButton(text='2'), KeyboardButton(text='3')],
[KeyboardButton(text='4'), KeyboardButton(text='5'), KeyboardButton(text='6'), KeyboardButton(text='7')],
[KeyboardButton(text='8'), KeyboardButton(text='9'), KeyboardButton(text='10'), KeyboardButton(text='11')],
[KeyboardButton(text='12'), KeyboardButton(text='13'), KeyboardButton(text='14'), KeyboardButton(text='15')]]
プログラムではなく手動でキーボードを作成できたので、2 番目の方法を使用してのみキーボードを作成しましたが、ターンごとに変化する動的リストであるため、各カードに順番にアクセスせずにカード リストを処理する方法はありません。 .
API ノートを調べましたが、使用できるものは見つかりませんでした
2 番目のキーボードの結果に基づいて、各カードを配列にして、元の配列内にネストすることで垂直方向の行を作成できると想定しましたが、私の経験ではそうではないことが判明しました
手順がありませんか?