daily() 缺少 1 个必需的位置参数:'self'

问题描述 投票:0回答:1
    @bot.message_handler(commands=\['remind'\])
def callback_verse(message):
r = requests.get("http://russian-poetry.ru/Random.php").text
soup = bs(r, "html.parser")
m = soup.find("title").text
b = soup.find("pre").text
msg = m + b
bot.send_message(message.chat.id, text=msg, parse_mode='html')

@bot.message_handler(commands=\['daily'\])
def daily(update):
JobQueue.run_repeating(callback=callback_verse, interval=10, first=0, )    

我得到 daily() 缺少 1 个必需的位置参数:'self' 错误

我尝试使用上下文,但没有帮助

python telegram telegram-bot
1个回答
0
投票

更改此:

@bot.message_handler(commands=\['daily'\])
def daily(update):
JobQueue.run_repeating(callback=callback_verse, interval=10, first=0, )  

致:

@bot.message_handler(commands=\['daily'\])
@staticmethod
def daily(update):
    JobQueue.run_repeating(callback=callback_verse, interval=10, first=0, )  

或者:

@bot.message_handler(commands=\['daily'\])
@staticmethod
def daily(self, update):
    JobQueue.run_repeating(callback=callback_verse, interval=10, first=0, )  
© www.soinside.com 2019 - 2024. All rights reserved.