Python 3.x 属性错误:';CallbackContext';(';更新';)对象没有属性';消息';

Python 3.x 属性错误:';CallbackContext';(';更新';)对象没有属性';消息';,python-3.x,telegram-bot,attributeerror,Python 3.x,Telegram Bot,Attributeerror,我有一个问题后,转移我的tg机器人到新的服务器。完全不知道我为什么会出错。似乎我丢失了一些要安装的python数据包。在具有相同操作系统参数的旧服务器中,我对这个bot没有任何问题 对不起,如果我的错误幼稚。我试图用谷歌搜索我的错误,但没有答案 代码1: def start(bot, update): if update.message.from_user.username == AAA: bot.sendMessage(chat_id=update.message.ch

我有一个问题后,转移我的tg机器人到新的服务器。完全不知道我为什么会出错。似乎我丢失了一些要安装的python数据包。在具有相同操作系统参数的旧服务器中,我对这个bot没有任何问题

对不起,如果我的错误幼稚。我试图用谷歌搜索我的错误,但没有答案

代码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'

处理程序签名不正确:

def start(update, context):
   context.bot.sendMessage(chat_id=update.message.chat_id, 'Text One')

updater.dispatcher.add_handler(CommandHandler('start', start))

处理程序签名不正确:

def start(update, context):
   context.bot.sendMessage(chat_id=update.message.chat_id, 'Text One')

updater.dispatcher.add_handler(CommandHandler('start', start))

非常奇怪–在旧服务器上,我的代码工作正常。你的代码现在对我有用了,谢谢。顺便说一下,现在我用sendMessage重命名来发送你的消息。也许这些信息对阅读此票证的任何人都有帮助。它是正确的,但sendMessage仍然可以工作(send_message的别名)非常奇怪–在旧服务器上,我的代码工作正常。你的代码现在对我有用了,谢谢。顺便说一下,现在我用sendMessage重命名来发送你的消息。可能此信息对阅读此票证的任何人都有帮助。它是正确的,但sendMessage仍应有效(send_message的别名)