async def help_button(client, query): mod_match = re.match(r"help_module\((.+?)\)", query.data) prev_match = re.match(r"help_prev\((.+?)\)", query.data) next_match = re.match(r"help_next\((.+?)\)", query.data) back_match = re.match(r"help_back", query.data) create_match = re.match(r"help_create", query.data) top_text = f""" Hello {query.from_user.first_name}! My name is {BOT_NAME}! I'm a group management bot with some usefule features. You can choose an option below, by clicking a button. Also you can ask anything in Support Group. ° Join: @ReXoMaChaT """ if mod_match: module = mod_match.group(1) text = ("{} **{}**:\n".format("Here is the help for", HELPABLE[module].__MODULE__) + HELPABLE[module].__HELP__) await query.message.edit( text=text, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("back", callback_data="help_back")]]), disable_web_page_preview=True, ) elif prev_match: curr_page = int(prev_match.group(1)) await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(curr_page - 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif next_match: next_page = int(next_match.group(1)) await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(next_page + 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif back_match: await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(0, HELPABLE, "help")), disable_web_page_preview=True, ) elif create_match: text, keyboard = await help_parser(query) await query.message.edit(text=text, reply_markup=keyboard, disable_web_page_preview=True) return await client.answer_callback_query(query.id)
async def help_parser(message, keyboard=None): if not keyboard: keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help")) return ( "Hi {first_name}, I am {bot_name}".format( first_name=message.from_user.first_name, bot_name=botinfo.BOT_NAME, ), keyboard, )
async def help_parser(name, keyboard=None): if not keyboard: keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help")) return ( """Hello {first_name}, My name is {bot_name}. I'm a group management bot with some useful features. You can choose an option below, by clicking a button. Also you can ask anything in Support Group. """.format( first_name=name, bot_name=BOT_NAME, ), keyboard, )
async def help_parser(name, keyboard=None): if not keyboard: keyboard = InlineKeyboardMarkup(paginate_modules(0, HELPABLE, "help")) return ( """Hello {first_name}! My name is {bot_name}! I'm a group management bot with some usefule features. You can choose an option below, by clicking a button. Also you can ask anything in Support Group. General command are: - /start: Start the bot - /help: Give this message""".format( first_name=name, bot_name=BOT_NAME, ), keyboard, )
async def help_button(c, q): mod_match = re.match(r"help_module\((.+?)\)", q.data) prev_match = re.match(r"help_prev\((.+?)\)", q.data) next_match = re.match(r"help_next\((.+?)\)", q.data) back_match = re.match(r"help_back", q.data) create_match = re.match(r"help_create", q.data) if mod_match: module = mod_match.group(1) text = ("{} **{}**:\n".format("Here is the help for", HELPABLE[module].__MODULE__) + HELPABLE[module].__HELP__) await q.message.edit( text=text, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("back", callback_data="help_back")]]), disable_web_page_preview=True, ) elif prev_match: curr_page = int(prev_match.group(1)) await q.message.edit( text="Hi {first_name}. I am {bot_name}".format( first_name=q.from_user.first_name, bot_name=botinfo.BOT_NAME, ), reply_markup=InlineKeyboardMarkup( paginate_modules(curr_page - 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif next_match: next_page = int(next_match.group(1)) await q.message.edit( text="Hi {first_name}. I am {bot_name}".format( first_name=q.from_user.first_name, bot_name=botinfo.BOT_NAME, ), reply_markup=InlineKeyboardMarkup( paginate_modules(next_page + 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif back_match: await q.message.edit( text="Hi {first_name}. I am {bot_name}".format( first_name=q.from_user.first_name, bot_name=botinfo.BOT_NAME, ), reply_markup=InlineKeyboardMarkup( paginate_modules(0, HELPABLE, "help")), disable_web_page_preview=True, ) elif create_match: text, keyboard = await help_parser(q) await q.message.edit(text=text, reply_markup=keyboard, disable_web_page_preview=True) return await c.answer_callback_query(q.id)
async def help_button(client, query): home_match = re.match(r"help_home\((.+?)\)", query.data) mod_match = re.match(r"help_module\((.+?)\)", query.data) prev_match = re.match(r"help_prev\((.+?)\)", query.data) next_match = re.match(r"help_next\((.+?)\)", query.data) back_match = re.match(r"help_back", query.data) create_match = re.match(r"help_create", query.data) top_text = f""" Hello {query.from_user.first_name}, My name is {BOT_NAME}. I'm a group management bot with some usefule features. You can choose an option below, by clicking a button. Also you can ask anything in Support Group. General command are: - /start: Start the bot - /help: Give this message """ if mod_match: module = (mod_match.group(1)).replace(" ", "_") text = ("{} **{}**:\n".format("Here is the help for", HELPABLE[module].__MODULE__) + HELPABLE[module].__HELP__) await query.message.edit( text=text, reply_markup=InlineKeyboardMarkup( [[InlineKeyboardButton("back", callback_data="help_back")]]), disable_web_page_preview=True, ) elif home_match: await app.send_message( query.from_user.id, text=home_text_pm, reply_markup=home_keyboard_pm, ) await query.message.delete() elif prev_match: curr_page = int(prev_match.group(1)) await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(curr_page - 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif next_match: next_page = int(next_match.group(1)) await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(next_page + 1, HELPABLE, "help")), disable_web_page_preview=True, ) elif back_match: await query.message.edit( text=top_text, reply_markup=InlineKeyboardMarkup( paginate_modules(0, HELPABLE, "help")), disable_web_page_preview=True, ) elif create_match: text, keyboard = await help_parser(query) await query.message.edit( text=text, reply_markup=keyboard, disable_web_page_preview=True, ) return await client.answer_callback_query(query.id)