我想在代码中输入两个令牌,也就是说,通过执行代码,两个电报机器人就可以工作。我的代码:
from telegram.ext import Updater,CommandHandler
updater = Updater(token='TOKEN', token1='TOKEN1')
def start_method(bot,update):
bot.sendMessage(update.message.chat_id,"Hello")
start_command = CommandHandler('start', start_method)
updater.dispatcher.add_handler(start_command)
updater.start_polling()
当我运行这些代码时,它将会出错:
Traceback (most recent call last):
File "G:/python2.7.9/dsdad.py", line 2, in <module>
updater = Updater(token='TOKEN', token1='TOKEN1')
TypeError: __init__() got an unexpected keyword argument 'token1'
我该怎么做?所以通过在代码中插入两个令牌,代码将运行两个电报机器人?
答案 0 :(得分:0)
您只需将要使用的机器人代码添加到函数中即可。你可以使用线程将两个机器人传递给函数。
nUł"˘ÂUÓ"…F˙i+Şž›‘Ş˘éăŁqëKĄ®qâ %˘ dŞn‘ĄŐňŢ^{łcąWq\)ńÂÔ€
然后你将线程放在那里,xxxxxxxx是你的机器人代码:
blWzIh+iwgYbVdODDyKFRv9pFCuqnpuRqqLp46Nx60ulrnHioCWiIARk-qm6RpdUB8t5ee7NjG7lXcVwp8cLUg==