@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' 错误
我尝试使用上下文,但没有帮助
更改此:
@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, )