Example #1
0
async def miui(event):
    """Send a message when the command /recovery or /fastboot is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/recovery') \
                or event.message.message.endswith('/fastboot'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    if device not in list(PROVIDER.miui_codenames):
        await event.reply(await error_message(device, locale))
        return
    method = "Recovery" if "recovery" in event.pattern_match.string else "Fastboot"
    message, buttons = await miui_message(device, method,
                                          PROVIDER.miui_updates,
                                          PROVIDER.codenames_names, locale)
    try:
        await event.reply(message, buttons=buttons, link_preview=False)
    except ChatWriteForbiddenError:
        pass
    raise events.StopPropagation
async def set_codename_help(event):
    """preferred device settings callback handler"""
    locale = DATABASE.get_locale(event.chat_id)
    device = DATABASE.get_codename(event.chat_id)
    try:
        await event.edit(await preferred_device_message(device, PROVIDER.codenames_names, locale), buttons=[
            [Button.inline(LOCALIZE.get_text(locale, "change_preferred_device"),
                           data="preferred_device_help")],
            [Button.inline(LOCALIZE.get_text(locale, "Back"), data="settings")]
        ])
    except (MessageNotModifiedError, ChannelPrivateError, ChatWriteForbiddenError):
        pass
Example #3
0
async def orangefox(event):
    """Send a message when the command /of is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/of'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    try:
        message, buttons = await orangefox_message(device, locale)
        await event.reply(message, buttons=buttons, link_preview=False)
    except TypeError:
        await event.reply(await error_message(device, locale))
    raise events.StopPropagation
Example #4
0
async def firmware(event):
    """Send a message when the command /archive is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/archive'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    if device not in PROVIDER.miui_codenames:
        await event.reply(await error_message(device, locale))
        return
    message, buttons = await archive_message(device, PROVIDER.codenames_names, locale)
    await event.reply(message, buttons=buttons, link_preview=False)
    raise events.StopPropagation
Example #5
0
async def latest(event):
    """Send a message when the command /latest is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/latest'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    if device not in list(PROVIDER.miui_codenames):
        await event.reply(await error_message(device, locale))
        return
    message = await latest_miui_message(device, PROVIDER.miui_updates,
                                        PROVIDER.codenames_names, locale)
    await event.reply(message)
    raise events.StopPropagation
async def xiaomi_eu(event):
    """Send a message when the command /eu is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/eu'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    if device not in list(PROVIDER.eu_codenames.keys()):
        await event.reply(await error_message(device, locale))
        return
    try:
        message, buttons = await eu_message(device, PROVIDER.eu_data, PROVIDER.eu_codenames, locale)
        await event.reply(message, buttons=buttons, link_preview=False)
    except TypeError:
        pass
    raise events.StopPropagation
Example #7
0
async def twrp(event):
    """Send a message when the command /twrp is sent."""
    try:
        device = event.pattern_match.group(1).lower()
    except (IndexError, AttributeError):
        if event.message.message.endswith('/twrp'):
            device = DATABASE.get_codename(event.chat_id)
        else:
            return
    if not device:
        return
    locale = DATABASE.get_locale(event.chat_id)
    if device not in list(PROVIDER.twrp_data.keys()):
        await event.reply(await error_message(device, locale))
        return
    message, buttons = await twrp_message(device, PROVIDER.twrp_data, locale)
    try:
        await event.reply(message, buttons=buttons, link_preview=False)
    except (ChannelPrivateError, ChatWriteForbiddenError):
        pass
    raise events.StopPropagation