请求失败,代码为400。电报的响应:“请求错误:消息文本为空”

时间:2020-04-15 14:59:04

标签: python json bots telegram

我遇到了这个问题,我想通过botogram创建一个电报机器人。我正在寻找在电报上创建按钮列表的方法,并为每个按钮附加一个名称(您可以在列表中找到)。我想在Json列表中转换“ dict”(从列表循环中获取)。但是'json.dumps'不起作用。你知道解决方案吗?

import botogram
import json

bot = botogram.create("token")
list = ["hi","sandwich","fries"]
bot.about = "Benvenuti"
@bot.command("start")
def start_command(chat, message):
    for i in list:
        dict = {
            'chat_id': chat.id,
            'text': 'Where are you?',
            'reply_markup': {
            'keyboard': [[
                {'text': i},
                {'text': 'Action B'},
            ],
            [
                {
                    'text': 'Use geolocation',
                    'request_location': True,
                },
            ],
        ],
        'resize_keyboard': True,
        'one_time_keyboard': True,
        'selective': True,
        }
    }
    bot.api.call('sendMessage', json.dumps(dict))

if __name__ == "__main__":
     bot.run()

输出:Request failed with code 400. Response from Telegram: "Bad Request: message text is empty

0 个答案:

没有答案