pytelegrambotapi, @bot.callback_query_handler makes an inexplicable mistake.
-
Makes an incomprehensible mistake, the act3 function cannot take two meanings, but how do you make the code work? It's been a long time since I can't figure out how to help you with the lick.
def act2(message): global temp key = message.text user_id = message.from_user.id markup = types.InlineKeyboardMarkup(row_width=1) for i in range(temp, temp + 10): markup.add( types.InlineKeyboardButton(text=f'{track[i]} - {artist[i]}', callback_data=f'btn{i}') ) nextbtn = types.InlineKeyboardButton('➡️', callback_data='next') backbtn = types.InlineKeyboardButton('⬅️', callback_data='back') markup.add(backbtn, nextbtn, row_width=2) bot.send_message(user_id, f'{key}:', reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def act3(call, message):
global temp
if call.data == 'next':
temp += 10
act2(message)
Here's the error code.
File "D:/pythonProject/main.py", line 87, in <module>
bot.polling(none_stop=True, interval=0)
File "D:\pythonProject\venv\lib\site-packages\telebot_init_.py", line 637, in polling
self._threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "D:\pythonProject\venv\lib\site-packages\telebot_init.py", line 699, in _threaded_polling
raise e
File "D:\pythonProject\venv\lib\site-packages\telebot_init.py", line 659, in __threaded_polling
self.worker_pool.raise_exceptions()
File "D:\pythonProject\venv\lib\site-packages\telebot\util.py", line 130, in raise_exceptions
raise self.exception_info
File "D:\pythonProject\venv\lib\site-packages\telebot\util.py", line 82, in run
task(*args, **kwargs)
TypeError: act3() missing 1 required positional argument: 'message'
-
The erroneous report tells you that it's a function.
act3
No casemessage
♪ The processor will always transfer it onlycall
and objectmessage
We need to retrieve ourselves:@bot.callback_query_handler(func=lambda call: True) def act3(call): global temp if call.data == 'next': temp += 10 act2(call.message)