Beispiel #1
0
async def get_mod_help_callback(event):
    chat_id = event.chat_id
    module = re.search('mod_help_(.*)', str(event.data)).group(1)[:-1]
    text = get_string(module, "title", chat_id, dir="HELPS")
    text += '\n'
    lang = get_chat_lang(chat_id)
    buttons = []
    for string in get_string(module, "text", chat_id, dir="HELPS"):
        if "HELPS" in LANGUAGES[lang]:
            text += LANGUAGES[lang]["HELPS"][module]['text'][string]
        else:
            text += LANGUAGES["en"]["HELPS"][module]['text'][string]
        text += '\n'
    if 'buttons' in LANGUAGES[lang]["HELPS"][module]:
        counter = 0
        for btn in LANGUAGES[lang]["HELPS"][module]['buttons']:
            counter += 1
            btn_name = LANGUAGES[lang]["HELPS"][module]['buttons'][btn]
            t = [Button.inline(btn_name, btn)]
            if counter % 2 == 0:
                new = buttons[-1] + t
                buttons = buttons[:-1]
                buttons.append(new)
            else:
                buttons.append(t)
    buttons += [[Button.inline("Back", 'get_help')]]
    await event.edit(text, buttons=buttons)
Beispiel #2
0
async def get_help_button_callback(query, callback_data=False, **kwargs):
    message = query.message
    module = callback_data['module']
    data = callback_data['btn']
    chat_id = query.message.chat.id
    lang = get_chat_lang(chat_id)
    text = ""
    text += LANGUAGES[lang]["HELPS"][module][data]
    buttons = InlineKeyboardMarkup().add(InlineKeyboardButton("Back", callback_data='get_help'))
    await message.edit_text(text, reply_markup=buttons)
Beispiel #3
0
async def get_help_button_callback(event):
    event_raw = re.search('help_btn_(.*)_(.*)', str(event.data))
    module = event_raw.group(1)
    data = event_raw.group(2)[:-1]
    chat_id = event.chat_id
    lang = get_chat_lang(chat_id)
    text = "Help of {}"
    if data in LANGUAGES[lang]["HELPS"][module]:
        for btn in get_string(module, data, chat_id, dir="HELPS"):
            text += LANGUAGES[lang]["HELPS"][module][data][btn]
            text += '\n'
    buttons = [[Button.inline("Back", 'mod_help_' + module)]]
    await event.edit(text, buttons=buttons)
Beispiel #4
0
async def get_mod_help_callback(query, callback_data=False, **kwargs):
    chat_id = query.message.chat.id
    message = query.message
    module = callback_data['module']
    lang = get_chat_lang(chat_id)
    buttons = InlineKeyboardMarkup(row_width=2)
    text = LANGUAGES[lang]["HELPS"][module]['text']
    if 'buttons' in LANGUAGES[lang]["HELPS"][module]:
        counter = 0
        for btn in LANGUAGES[lang]["HELPS"][module]['buttons']:
            counter += 1
            btn_name = LANGUAGES[lang]["HELPS"][module]['buttons'][btn]
            buttons.insert(InlineKeyboardButton(
                btn_name, callback_data=help_btn_cp.new(module=module, btn=btn)))
    buttons.add(InlineKeyboardButton("Back", callback_data='get_help'))
    await message.edit_text(text, reply_markup=buttons)