Пример #1
0
async def get_start_func(message, strings, edit=False):
    msg = message.message if hasattr(message, 'message') else message
    task = msg.edit_text if edit else msg.reply
    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(strings['btn_help'], callback_data='get_help'),
                InlineKeyboardButton(strings['btn_lang'], callback_data='lang_btn'))
    buttons.add(InlineKeyboardButton(strings['btn_channel'], url='https://t.me/HitsukiNews'),
                InlineKeyboardButton(strings['btn_source'], url='https://github.com/HitsukiNetwork/HitsukiX'))
    # Handle error when user click the button 2 or more times simultaneously
    with suppress(MessageNotModified):
        await task(strings['start_hi'], reply_markup=buttons)
Пример #2
0
async def clear_all_notes(message, chat, strings):
    # Ensure notes count
    if not await db.notes.find_one({'chat_id': chat['chat_id']}):
        await message.reply(strings['notelist_no_notes'].format(chat_title=chat['chat_title']))
        return

    text = strings['clear_all_text'].format(chat_name=chat['chat_title'])
    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(strings['clearall_btn_yes'], callback_data='clean_all_notes_cb'))
    buttons.add(InlineKeyboardButton(strings['clearall_btn_no'], callback_data='cancel'))
    await message.reply(text, reply_markup=buttons)
Пример #3
0
async def del_fed_cmd(message, fed, strings):
    fed_name = html.escape(fed['fed_name'], False)
    fed_id = fed['fed_id']
    fed_owner = fed['creator']

    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(text=strings['delfed_btn_yes'], callback_data=delfed_cb.new(fed_id=fed_id,
                                                                                                 creator_id=fed_owner)))
    buttons.add(InlineKeyboardButton(text=strings['delfed_btn_no'], callback_data=f'cancel_{fed_owner}'))

    await message.reply(strings['delfed'] % fed_name, reply_markup=buttons)
Пример #4
0
async def warn_func(message, chat, user, text, strings, filter_action=False):
    chat_id = chat['chat_id']
    chat_title = chat['chat_title']
    by_id = BOT_ID if filter_action is True else message.from_user.id
    user_id = user['user_id'] if filter_action is False else user

    if user_id == BOT_ID:
        await message.reply(strings['warn_sofi'])
        return

    if not filter_action:
        if user_id == message.from_user.id:
            await message.reply(strings['warn_self'])
            return

    if await is_user_admin(chat_id, user_id):
        if not filter_action:
            await message.reply(strings['warn_admin'])
        return

    reason = text
    warn_id = str((await db.warns.insert_one({
        'user_id': user_id,
        'chat_id': chat_id,
        'reason': str(reason),
        'by': by_id
    })).inserted_id)

    admin = await get_user_link(by_id)
    member = await get_user_link(user_id)
    text = strings['warn'].format(admin=admin,
                                  user=member,
                                  chat_name=chat_title)

    if reason:
        text += strings['warn_rsn'].format(reason=reason)

    warns_count = await db.warns.count_documents({
        'chat_id': chat_id,
        'user_id': user_id
    })

    buttons = InlineKeyboardMarkup().add(
        InlineKeyboardButton("тЪая╕П Remove warn",
                             callback_data='remove_warn_{}'.format(warn_id)))

    if await db.rules.find_one({'chat_id': chat_id}):
        buttons.insert(
            InlineKeyboardButton("ЁЯУЭ Rules",
                                 url=await
                                 get_start_link(f'btn_rules_{chat_id}')))

    if warn_limit := await db.warnlimit.find_one({'chat_id': chat_id}):
        max_warn = int(warn_limit['num'])
Пример #5
0
async def enable_all(message, chat, strings):
    # Ensure that something is disabled
    if not await db.disabled_v2.find_one({'chat_id': chat['chat_id']}):
        await message.reply(strings['not_disabled_anything'].format(chat_title=chat['chat_title']))
        return

    text = strings['enable_all_text'].format(chat_name=chat['chat_title'])
    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(strings['enable_all_btn_yes'], callback_data='enable_all_notes_cb'))
    buttons.add(InlineKeyboardButton(strings['enable_all_btn_no'], callback_data='cancel'))
    await message.reply(text, reply_markup=buttons)
Пример #6
0
async def get_start_func(message, strings, edit=False):
    msg = message.message if hasattr(message, 'message') else message
    task = msg.edit_text if edit else msg.reply
    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(strings['btn_help'], callback_data='get_help'),
                InlineKeyboardButton(strings['btn_lang'], callback_data='lang_btn'))
    buttons.add(InlineKeyboardButton(strings['btn_chat'], url='https://t.me/BotLabTeam'),
                InlineKeyboardButton(strings['btn_channel'], url='https://t.me/NaoUpdates'))
    buttons.add(InlineKeyboardButton(strings['btn_add'], url=f'https://telegram.me/NaoTomoriRobot?startgroup=true'))
    # Handle error when user click the button 2 or more times simultaneously
    with suppress(MessageNotModified):
        await task(strings['start_hi'], reply_markup=buttons)
Пример #7
0
    async def get_missing_katas(cls, user, offset=0):
        conn = await asyncpg.connect(POSTGRES_URI)
        records = await conn.fetch(
            """
            SELECT name, slug
            FROM katas
            WHERE id in (
                SELECT id
                FROM katas

                EXCEPT

                SELECT kata_id
                FROM solved_katas
                WHERE user_id = $1
            )
            LIMIT 10 OFFSET $2;
        """, user.id, offset)
        count = await conn.fetchrow(
            """
            SELECT COUNT(*)
            FROM katas
            WHERE id in (
                SELECT id
                FROM katas

                EXCEPT

                SELECT kata_id
                FROM solved_katas
                WHERE user_id = $1
            );
        """, user.id)
        await conn.close()
        markup = InlineKeyboardMarkup()
        for r in records:
            btn = InlineKeyboardButton(
                text=r.get('name'),
                url=f"{CODEWARS_BASE_KATA_URL}/{r.get('slug')}/")
            markup.add(btn)
        buttons = []
        if not count.get('count') - offset <= 10:
            buttons.append(
                InlineKeyboardButton(text='Далее',
                                     callback_data=f'next_{offset + 10}'))
        if offset > 0:
            buttons.append(
                InlineKeyboardButton(text='Назад',
                                     callback_data=f'next_{offset - 10}'))
        if buttons:
            markup.add(*buttons)
        return markup, count.get('count')
Пример #8
0
def choice_method_add_wallet_inl(bch):
    keyboard = InlineKeyboardMarkup(row_width=1)
    keyboard.add(
        InlineKeyboardButton(_('Добавить адрес кошелька'),
                             callback_data=f'{bch}_add_bch_wallet'),
        InlineKeyboardButton(_('Импортировать приватный ключ'),
                             callback_data=f'{bch}_import_private_key'),
        # InlineKeyboardButton(_('Импортировать seed-фразу'),
        #                 callback_data=f'{bch}_import_seed_phrase'),
        InlineKeyboardButton(_('Сгенерировать новый кошелек'),
                             callback_data=f'{bch}_generate_wallet'),
        InlineKeyboardButton(_('Назад'), callback_data=f'{bch}_view'))
    return keyboard
Пример #9
0
async def delall_filters(message: Message, strings: dict):
    if not await is_chat_creator(message, message.chat.id,
                                 message.from_user.id):
        return await message.reply(strings['not_chat_creator'])
    buttons = InlineKeyboardMarkup()
    buttons.add(*[
        InlineKeyboardButton(strings['confirm_yes'],
                             callback_data=filter_delall_yes_cb.new(
                                 chat_id=message.chat.id)),
        InlineKeyboardButton(strings['confirm_no'],
                             callback_data="filter_delall_no_cb")
    ])
    return await message.reply(strings['delall_header'], reply_markup=buttons)
Пример #10
0
def get_start(chat_id):
    strings = get_strings(chat_id, module='pm_menu')

    text = strings["start_hi"]
    buttons = InlineKeyboardMarkup()
    buttons.add(InlineKeyboardButton(strings["btn_help"], callback_data='get_help'))
    buttons.add(InlineKeyboardButton(strings["btn_lang"], callback_data='set_lang'))

    buttons.add(
        InlineKeyboardButton(strings["btn_chat"], url='https://t.me/YanaBotGrou'),
        InlineKeyboardButton(strings["btn_channel"], url='https://t.me/SophieNEWS'),
    )

    return text, buttons
Пример #11
0
async def select_time(state, strings, action, chat_id, msg_id):
    async with state.proxy() as data:
        data['time_sel_msg'] = msg_id

    await NewFilter.time.set()  # For manual select time

    text = strings['select_time']
    text += strings['select_time_tip']
    text += strings['select_time_btns']
    buttons = InlineKeyboardMarkup(row_width=2).add(
        InlineKeyboardButton(strings['time_f'],
                             callback_data=new_filter_time_cb.new(time=False)),
        InlineKeyboardButton(strings['time_2h'],
                             callback_data=new_filter_time_cb.new(time='2h')),
        InlineKeyboardButton(strings['time_5h'],
                             callback_data=new_filter_time_cb.new(time='5h')),
        InlineKeyboardButton(strings['time_24h'],
                             callback_data=new_filter_time_cb.new(time='24h')),
        InlineKeyboardButton(strings['time_2d'],
                             callback_data=new_filter_time_cb.new(time='2d')),
        InlineKeyboardButton(strings['time_1w'],
                             callback_data=new_filter_time_cb.new(time='7d')))

    buttons.add(
        InlineKeyboardButton(strings['back'],
                             callback_data='add_filter_actions'))

    buttons.add(InlineKeyboardButton(strings['exit'], callback_data='cancel'))

    await bot.edit_message_text(text, chat_id, msg_id, reply_markup=buttons)
    return
Пример #12
0
def kb_schedule_days() -> InlineKeyboardMarkup:
    """Display keyboard with days of week choice."""
    return InlineKeyboardMarkup(inline_keyboard=[
        [
            InlineKeyboardButton(
                DayOfWeek.EVERY.title,
                callback_data=cd_schedule_days.new(days=DayOfWeek.EVERY.cron),
            )
        ],
        [
            InlineKeyboardButton(
                DayOfWeek.WORK.title,
                callback_data=cd_schedule_days.new(days=DayOfWeek.WORK.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.END.title,
                callback_data=cd_schedule_days.new(days=DayOfWeek.END.cron),
            ),
        ],
        [
            InlineKeyboardButton(
                DayOfWeek.MON.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.MON.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.TUE.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.TUE.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.WED.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.WED.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.THU.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.THU.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.FRI.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.FRI.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.SAT.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.SAT.cron),
            ),
            InlineKeyboardButton(
                DayOfWeek.SUN.short,
                callback_data=cd_schedule_days.new(days=DayOfWeek.SUN.cron),
            ),
        ],
    ])
Пример #13
0
def DonateMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    isDeleteButton = DBH.GetSetting(chatID, "deleteButton", chatType)
    dictLang = ButtonTexts[lang]
    DonateMU = InlineKeyboardMarkup()
    DonateMU.add(
        InlineKeyboardButton(
            dictLang['donate'],
            url="https://secure.wayforpay.com/payment/s3641f64becae",
            callback_data="donate"))
    if isDeleteButton:
        DonateMU.add(
            InlineKeyboardButton(dictLang['delete'], callback_data="delete"))
    return DonateMU
Пример #14
0
def CurrenciesMainMenuMarkup(chatID: str,
                             chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    CurrenciesMainMenuMU = InlineKeyboardMarkup()
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['cur_menu'],
                             callback_data="cur_curmenu"))
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['crypto_menu'],
                             callback_data="cur_cryptomenu"))
    CurrenciesMainMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return CurrenciesMainMenuMU
Пример #15
0
async def release_new_build(message):
    await ReleaseState.sel_build_type.set()

    text = "<b>Releasing new OrangeFox build</b>"
    text += "\nSelect build type:"
    buttons = InlineKeyboardMarkup(row_width=2).add(
        InlineKeyboardButton(
            "Stable", callback_data=build_type_cp.new(build_type='stable')),
        InlineKeyboardButton(
            "Beta/RC", callback_data=build_type_cp.new(build_type='beta')))

    buttons.add(InlineKeyboardButton("Exit", callback_data='cancel'))

    await message.reply(text, reply_markup=buttons)
Пример #16
0
async def change_device_info(message, device, edit=False):
    await ChangeDeviceState.list_info.set()
    codename = device['codename']
    text = "Device name: " + device['fullname']
    text += "\nCodename: " + codename
    text += "\nMaintainer: " + device['maintainer']
    text += "\nStatus: " + device['status']
    if 'default_bugs' in device:
        text += "\nDefault builds bugs:\n" + device['default_bugs']
    if 'default_notes' in device:
        text += "\nDefault builds notes:\n" + device['default_notes']

    buttons = InlineKeyboardMarkup(row_width=2).add(
        InlineKeyboardButton(
            "Change maintainer",
            callback_data=fox_change_maintainer_cp.new(codename=codename)),
        InlineKeyboardButton(
            "Change development status",
            callback_data=fox_change_status_cp.new(codename=codename)))

    if 'default_bugs' not in device:
        buttons.add(
            InlineKeyboardButton(
                "Add default bugs",
                callback_data=fox_change_def_bugs_cp.new(codename=codename)))
    else:
        buttons.add(
            InlineKeyboardButton(
                "Edit default bugs",
                callback_data=fox_change_def_bugs_cp.new(codename=codename)),
            InlineKeyboardButton(
                "Delete default bugs",
                callback_data=fox_del_def_bugs_cp.new(codename=codename)))

    if 'default_notes' not in device:
        buttons.add(
            InlineKeyboardButton(
                "Add default notes",
                callback_data=fox_change_def_notes_cp.new(codename=codename)))
    else:
        buttons.add(
            InlineKeyboardButton(
                "Edit default notes",
                callback_data=fox_change_def_notes_cp.new(codename=codename)),
            InlineKeyboardButton(
                "Delete default notes",
                callback_data=fox_del_def_notes_cp.new(codename=codename)))

    buttons.add(InlineKeyboardButton("Done", callback_data='cancel'))

    if edit is True:
        await message.edit_text(text, reply_markup=buttons)
    else:
        await message.reply(text, reply_markup=buttons)
Пример #17
0
def help_markup(modules):
    markup = InlineKeyboardMarkup()
    for module in modules:
        markup.insert(
            InlineKeyboardButton(module,
                                 callback_data=helpmenu_cb.new(mod=module)))
    return markup
Пример #18
0
async def change_lang(message, lang, strings, e=False):
    await change_chat_lang(message.chat.id, lang)

    lang_info = LANGUAGES[lang]['language_info']

    text = strings['lang_changed'].format(lang_name=lang_info['flag'] + " " +
                                          lang_info['name'])
    text += strings['help_us_translate']

    markup = InlineKeyboardMarkup()

    if 'translators' in lang_info:
        markup.add(
            InlineKeyboardButton(
                strings['see_translators'],
                callback_data=translators_lang_cb.new(lang=lang)))

    if e:
        await message.edit_text(text,
                                reply_markup=markup,
                                disable_web_page_preview=True)
    else:
        await message.reply(text,
                            reply_markup=markup,
                            disable_web_page_preview=True)
Пример #19
0
def CryptoMenuMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    dictLang = ButtonTexts[lang]
    CryptoMenuMU = InlineKeyboardMarkup()
    AllCrypto = ListsCache.GetListOfCrypto()
    TurnedOnCrypto = DBH.GetAllCrypto(chatID)
    for i in AllCrypto:
        if i in TurnedOnCrypto:
            CryptoMenuMU.add(
                InlineKeyboardButton(i + " ✅", callback_data="cur_" + i))
        else:
            CryptoMenuMU.add(
                InlineKeyboardButton(i + " ❌", callback_data="cur_" + i))
    CryptoMenuMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="cur_menu"))
    return CryptoMenuMU
Пример #20
0
def FlagsMarkup(chatID: str, chatType: str) -> InlineKeyboardMarkup:
    lang = DBH.GetSetting(chatID, "lang", chatType)
    AllSettings = DBH.GetAllSettings(chatID, chatType)
    dictLang = ButtonTexts[lang]
    FlagsMU = InlineKeyboardMarkup()
    if AllSettings['flags']:
        FlagsMU.add(
            InlineKeyboardButton(dictLang['flags_button'] + " ✅",
                                 callback_data="flags_button"))
    else:
        FlagsMU.add(
            InlineKeyboardButton(dictLang['flags_button'] + " ❌",
                                 callback_data="flags_button"))
    FlagsMU.add(
        InlineKeyboardButton(dictLang['back'], callback_data="settings"))
    return FlagsMU
Пример #21
0
async def connect_to_chat_direct(message, strings):
    user_id = message.from_user.id
    chat_id = message.chat.id

    if user_id == 1087968824:
        # just warn the user that connections with admin rights doesn't work
        return await message.reply(
            strings["anon_admin_conn"],
            reply_markup=InlineKeyboardMarkup().add(
                InlineKeyboardButton(
                    strings["click_here"], callback_data="anon_conn_cb"
                )
            ),
        )

    chat = await db.chat_list.find_one({"chat_id": chat_id})
    chat_title = chat["chat_title"] if chat is not None else message.chat.title
    text = strings["pm_connected"].format(chat_name=chat_title)

    try:
        await bot.send_message(user_id, text)
        await def_connect_chat(message, user_id, chat_id, chat_title)
    except (BotBlocked, CantInitiateConversation):
        await message.reply(strings["connected_pm_to_me"].format(chat_name=chat_title))
        redis.set("AuraX_connected_start_state:" + str(user_id), 1)
Пример #22
0
async def clear_all_notes(message, chat, strings):
    # Ensure notes count
    if not await db.notes.find_one({"chat_id": chat["chat_id"]}):
        await message.reply(
            strings["notelist_no_notes"].format(chat_title=chat["chat_title"]))
        return

    text = strings["clear_all_text"].format(chat_name=chat["chat_title"])
    buttons = InlineKeyboardMarkup()
    buttons.add(
        InlineKeyboardButton(strings["clearall_btn_yes"],
                             callback_data="clean_all_notes_cb"))
    buttons.add(
        InlineKeyboardButton(strings["clearall_btn_no"],
                             callback_data="cancel"))
    await message.reply(text, reply_markup=buttons)
Пример #23
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)
Пример #24
0
async def do_welcomesecurity(message, strings, from_id, chat_id):
    welcome_security = mongodb.welcome_security.find_one({'chat_id': chat_id})

    if 'new_chat_members' in message:
        from_id = message.new_chat_members[0].id

    if welcome_security and welcome_security['security'] == 'soft':

        time_val = int(time.time() + 60 * 60)  # Mute 1 hour
        try:
            await mute_user(message, int(from_id), chat_id, time_val)
        except CantDemoteChatCreator:
            return

    elif welcome_security and welcome_security['security'] == 'hard':

        buttons = InlineKeyboardMarkup().add(
            InlineKeyboardButton(strings['clik2tlk_btn'],
                                 callback_data='wlcm_{}_{}'.format(
                                     from_id, chat_id)))
        try:
            await mute_user(message, int(from_id), chat_id, None)
        except CantDemoteChatCreator:
            return

        text = strings['wlcm_sec'].format(
            mention=await user_link_html(from_id))
        await message.reply(text, reply_markup=buttons)
Пример #25
0
async def del_filter(message, chat, strings):
    handler = get_args_str(message)
    chat_id = chat["chat_id"]
    filters = await db.filters.find({
        "chat_id": chat_id,
        "handler": handler
    }).to_list(9999)
    if not filters:
        await message.reply(
            strings["no_such_filter"].format(chat_name=chat["chat_title"]))
        return

    # Remove filter in case if we found only 1 filter with same header
    filter = filters[0]
    if len(filters) == 1:
        await db.filters.delete_one({"_id": filter["_id"]})
        await update_handlers_cache(chat_id)
        await message.reply(
            strings["del_filter"].format(handler=filter["handler"]))
        return

    # Build keyboard row for select which exactly filter user want to remove
    buttons = InlineKeyboardMarkup(row_width=1)
    text = strings["select_filter_to_remove"].format(handler=handler)
    for filter in filters:
        action = FILTERS_ACTIONS[filter["action"]]
        buttons.add(
            InlineKeyboardButton(
                # If module's filter support custom del btn names else just show action name
                "" + action["del_btn_name"](message, filter)
                if "del_btn_name" in action else filter["action"],
                callback_data=filter_remove_cp.new(id=str(filter["_id"])),
            ))

    await message.reply(text, reply_markup=buttons)
Пример #26
0
async def del_fed_cmd(message, fed, strings):
    fed_name = html.escape(fed["fed_name"], False)
    fed_id = fed["fed_id"]
    fed_owner = fed["creator"]

    buttons = InlineKeyboardMarkup()
    buttons.add(
        InlineKeyboardButton(
            text=strings["delfed_btn_yes"],
            callback_data=delfed_cb.new(fed_id=fed_id, creator_id=fed_owner),
        ))
    buttons.add(
        InlineKeyboardButton(text=strings["delfed_btn_no"],
                             callback_data=f"cancel_{fed_owner}"))

    await message.reply(strings["delfed"] % fed_name, reply_markup=buttons)
Пример #27
0
async def help_cb(event, strings):
    button = help_markup(MOD_HELP)
    button.add(
        InlineKeyboardButton(strings["back"], callback_data="go_to_start"))
    with suppress(MessageNotModified):
        await event.message.edit_text(strings["help_header"],
                                      reply_markup=button)
Пример #28
0
async def enable_all(message, chat, strings):
    # Ensure that something is disabled
    if not await db.disabled.find_one({"chat_id": chat["chat_id"]}):
        await message.reply(strings["not_disabled_anything"].format(
            chat_title=chat["chat_title"]))
        return

    text = strings["enable_all_text"].format(chat_name=chat["chat_title"])
    buttons = InlineKeyboardMarkup()
    buttons.add(
        InlineKeyboardButton(strings["enable_all_btn_yes"],
                             callback_data="enable_all_notes_cb"))
    buttons.add(
        InlineKeyboardButton(strings["enable_all_btn_no"],
                             callback_data="cancel"))
    await message.reply(text, reply_markup=buttons)
Пример #29
0
async def change_captcha(event, strings, state=None, **kwargs):
    message = event.message
    async with state.proxy() as data:
        data['regen_num'] = 1 if 'regen_num' not in data else data[
            'regen_num'] + 1
        regen_num = data['regen_num']

        if regen_num > 3:
            img, num = generate_captcha(number=data['captcha_num'])
            text = strings['last_chance']
            await message.edit_media(InputMediaPhoto(img, caption=text))
            return

        img, num = generate_captcha()
        data['captcha_num'] = num

    text = strings['ws_captcha_text'].format(
        user=await get_user_link(event.from_user.id))

    buttons = InlineKeyboardMarkup().add(
        InlineKeyboardButton(strings['regen_captcha_btn'],
                             callback_data='regen_captcha'))

    await message.edit_media(InputMediaPhoto(img, caption=text),
                             reply_markup=buttons)
Пример #30
0
async def change_device_status(query, callback_data, state):
    codename = callback_data['codename']
    await ChangeDeviceState.change_status.set()

    buttons = InlineKeyboardMarkup(row_width=1).add(
        InlineKeyboardButton("Maintained", callback_data=fox_change_status_btn_cp.new(
            codename=codename, status=1)),
        InlineKeyboardButton("Maintained without device on hands", callback_data=fox_change_status_btn_cp.new(
            codename=codename, status=2)),
        InlineKeyboardButton("Testing only", callback_data=fox_change_status_btn_cp.new(
            codename=codename, status=3)),
        InlineKeyboardButton("Unmaintained", callback_data=fox_change_status_btn_cp.new(
            codename=codename, status=4)),
    )

    await query.message.edit_text("Select device status:", reply_markup=buttons)