def textcb(bot, update): # Get Data d = get_database() try: cid = update.message.from_user.id trainer = Trainer(cid) trainer.get_values(d, "id, menu_id") if trainer.menu_id == 2: renamestarter(bot, update, d, trainer) finally: free_database(d)
def pickuppkmn(self, bot: Bot, update: Update, trainer: Trainer, database: Database): trainer.get_values(database, "blocktimer") blocktime = trainer.blocktimer if blocktime <= dt.datetime.now(): bot.send_message( Trainer.id, text= """Thank you! Your Pokémon are fighting fit! We hope to see you again! Hehe... What? I'm not a s****t... Click or write /handler to show the handler!""" ) # d.cmd("UPDATE trainer SET blocktimer = NULL WHERE id = %s;", (cid,)) trainer.blocktime = None trainer.menu_id = 3 trainer.update_values(database, "menu_id, blocktimer") pass else: waitfor = blocktime - dt.datetime.now() minutes = (waitfor.days * 1440) + (waitfor.seconds / 60) + 1 # + waitfor.minute bot.answerCallbackQuery(callback_query_id=update.callback_query.id, text="Wait for %d min..." % minutes, show_alert=False)