我有一个问题后,转移我的tg机器人到新的服务器。我不知道为什么我有错误。好像我丢失了一些Python包来安装。在旧服务器与操作系统的参数相同,我没有这个机器人的任何问题。
抱歉,我的错误太幼稚了。我试着谷歌我的错误,没有答案。
代码1:
def start(bot, update):
if update.message.from_user.username == AAA:
bot.sendMessage(chat_id=update.message.chat_id, text="Text_one")
else:
bot.sendMessage(chat_id=update.message.chat_id, text="Text_two")
...
updater = Updater(token=bot_token)
start_handler = CommandHandler('start', start)
updater.dispatcher.add_handler(start_handler)
错误1:
File "/usr/local/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 425, in process_update handler.handle_update(update, self, check, context)
File "/usr/local/lib/python3.7/site-packages/telegram/ext/handler.py", line 145, in handle_update return self.callback(update, context)
File "./bot.py", line 43, in start
if update.message.from_user.username == AAA:
AttributeError: 'CallbackContext' object has no attribute 'message'
代码2:
def rating(bot, update):
bot.send_sticker(chat_id,'some_sticker_id')
...
rating_handler = CommandHandler('rating', rating)
updater.dispatcher.add_handler(rating_handler)
错误2:
File "/usr/local/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 425, in process_update handler.handle_update(update, self, check, context)
File "/usr/local/lib/python3.7/site-packages/telegram/ext/handler.py", line 145, in handle_update return self.callback(update, context)
File "./bot.py", line 108, in rating
bot.send_sticker(chat_id, 'some_sticker_id')
AttributeError: 'Update' object has no attribute 'send_sticker'
1条答案
按热度按时间i7uq4tfw1#
处理程序签名不正确: