I am creating a bot that has dynamic buttons and want to detect if the start of the callback query is classes_
and then allow me to further parse. How would I use regex or a built in pattern function to detect the beginning of a string?
@bot.callback_query_handler(func=lambda c: c.data == f'classes_'.startswith)
def callback_is_return(call: types.CallbackQuery):
print('Found!')
I tried using ().startswith
CodePudding user response:
Do this.
@bot.callback_query_handler(func=lambda c: c.data.startswith('classes_'))