import os
from telegram.ext import Updater, CommandHandler, MessageHandler, filters
def start(update, context):
context.bot.send_message(chat_id=update.effective_chat.id, text="test")
def echo(update, context):
context.bot.forward_message(chat_id=ADMIN_CHAT_ID, from_chat_id=update.message.chat_id, message_id=update.message.message_id)
context.bot.send_message(chat_id=update.effective_chat.id, text="test")
ADMIN_CHAT_ID = os.environ.get('1014171853')
def main():
TOKEN = os.environ.get('<MY-TOKEN>')
ADMIN_CHAT_ID = os.environ.get('228')
token= "<MY-TOKEN>"
updater = Updater(token, use_context=True)
dispatcher = updater.dispatcher
start_handler = CommandHandler('start', start)
echo_handler = MessageHandler(filters.text & ~filters.command, echo)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(echo_handler)
updater.start_polling()
updater.idle()
if __name__ == '__main__':
main()
File "c:\Users\rufer\OneDrive\desktop\codes\bot2.py", line 30, in <module>
main()
File "c:\Users\rufer\OneDrive\desktop\codes\bot2.py", line 17, in main
updater = Updater(token, use_context=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Updater.__init__() got an unexpected keyword argument 'use_context'
当我收到此错误时,我尝试将令牌指定为变量,但我仍然不明白如何修复此错误。我的 python-telegram-bot 版本是 20.2