Exemplo n.º 1
0
async def open_in_pm_message(locale):
    """ generate open in pm message """
    message = LOCALIZE.get_text(locale, "open_in_pm")
    buttons = [
        Button.url(LOCALIZE.get_text(locale, "click_here"),
                   f"https://t.me/{BOT_INFO['username']}?start=help")
    ]
    return message, buttons
Exemplo n.º 2
0
async def welcome_in_pm_message(locale):
    """ Generate telegram message of welcome in pm """
    message = LOCALIZE.get_text(locale, "open_in_pm")
    buttons = [
        [Button.url(LOCALIZE.get_text(locale, "click_here"),
                    f"https://t.me/{BOT_INFO['username']}?start=start")]
    ]
    return message, buttons
Exemplo n.º 3
0
async def vendor_update_message(codename, update, locale):
    """ Generate telegram message of vendor update """
    message = LOCALIZE.get_text(locale, "vendor_update").replace(
        "{codename}", codename)
    buttons = [[Button.url(f"{update}", f"{XFU_WEBSITE}/vendor/{codename}/")],
               [
                   Button.url(LOCALIZE.get_text(locale, "MIUIVendorUpdater"),
                              "https://t.me/MIUIVendorUpdater")
               ]]
    return message, buttons
Exemplo n.º 4
0
async def lang_help(event):
    """language help callback handler"""
    locale = DATABASE.get_locale(event.chat_id)
    try:
        await event.edit(await lang_settings_message(locale), buttons=[
            [Button.inline(LOCALIZE.get_text(locale, "change_language"),
                           data="change_language")],
            [Button.inline(LOCALIZE.get_text(locale, "Back"), data="settings")]
        ])
    except (MessageNotModifiedError, ChannelPrivateError, ChatWriteForbiddenError):
        pass
async def archive_message(device, codenames_names, locale):
    """ Generate telegram message of archive command """
    message = LOCALIZE.get_text(locale, "miui_archive").replace(
        "{codenames_names[device]}", codenames_names[device]).replace("{device}", device)
    buttons = [
        [Button.url(LOCALIZE.get_text(locale, "roms_archive"),
                    url=f"{XFU_WEBSITE}/archive/miui/{device}/"),
         Button.url(LOCALIZE.get_text(locale, "MIUIUpdatesTracker"),
                    url="https://t.me/MIUIUpdatesTracker")]
    ]
    return message, buttons
Exemplo n.º 6
0
async def codename_message(device, names_codenames, locale):
    """ Generate telegram message of whatis command """
    message = ""
    info = await get_codename(device, names_codenames)
    if len(info) > 8:
        message = LOCALIZE.get_text(locale, "too_much_codenames").replace(
            "{device}", device)
        return message
    for name, codename in info.items():
        message += LOCALIZE.get_text(locale, "codename_message").replace(
            "{name}", name).replace("{codename}", codename)
    return message
Exemplo n.º 7
0
async def firmware_update_message(codename, update, locale):
    """ Generate telegram message of firmware update """
    message = LOCALIZE.get_text(locale, "firmware_update").replace(
        "{codename}", codename)
    buttons = [
        [Button.url(f"{update}", f"{XFU_WEBSITE}/firmware/{codename}/")],
        [
            Button.url(LOCALIZE.get_text(locale, "XiaomiFirmwareUpdater"),
                       "https://t.me/XiaomiFirmwareUpdater")
        ]
    ]
    return message, buttons
Exemplo n.º 8
0
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
async def latest_miui_message(device, updates, codenames_names, locale):
    """ Generate telegram message for latest command """
    data = await get_miui(device, updates)
    message = LOCALIZE.get_text(locale, "latest_message").replace(
        "{codenames_names[device]}", codenames_names[device]).replace(
        "{device}", device) + ":\n"
    for i in data:
        version = i['version']
        download = i['download']
        filename = download.split('/')[-1]
        branch = LOCALIZE.get_text(locale, await get_branch(version))
        region = LOCALIZE.get_text(locale, await get_region(filename, i['codename'], version))
        message += f"{region} {branch}: `{version}`\n"
    return message
Exemplo n.º 10
0
async def miui_update_message(data, codenames_names, locale):
    """ Generate telegram message of miui update """
    rom_type = LOCALIZE.get_text(locale, await get_type(str(data)))
    device = data['codename'].split('_')[0]
    filename = data['download'].split('/')[-1]
    region = LOCALIZE.get_text(locale,
                               await get_region(filename, device, data['version']))
    message = LOCALIZE.get_text(locale, "miui_update").replace(
        "{device}", device).replace(
        "{codenames_names[device]}", codenames_names[device]).replace(
        "{rom_type}", rom_type) + f"\n**{LOCALIZE.get_text(locale, 'Region')}:** {region}\n"
    buttons = [Button.url(f"{data['version']} | {data['android']}", url=data['download']),
               Button.url(LOCALIZE.get_text(locale, "MIUIUpdatesTracker"),
                          url="https://t.me/MIUIUpdatesTracker")]
    return message, buttons
Exemplo n.º 11
0
async def firmware_message(device, codenames_names, locale):
    """ Generate telegram message of firmware command """
    message = f'**{LOCALIZE.get_text(locale, "available_firmware")} {codenames_names[device]}** ' \
              f'(`{device}`)\n'
    buttons = [[
        Button.url(LOCALIZE.get_text(locale, "latest_firmware"),
                   f"{XFU_WEBSITE}/firmware/{device}/"),
        Button.url(LOCALIZE.get_text(locale, "archive_firmware"),
                   f"{XFU_WEBSITE}/archive/firmware/{device}/")
    ],
               [
                   Button.url(
                       LOCALIZE.get_text(locale, "XiaomiFirmwareUpdater"),
                       "https://t.me/XiaomiFirmwareUpdater")
               ]]
    return message, buttons
Exemplo n.º 12
0
async def settings_main_message(locale):
    """ Generate telegram message of settings command """
    message = "**" + LOCALIZE.get_text(locale, "settings_message") + "**"
    buttons = [[
        Button.inline(LOCALIZE.get_text(locale, "Subscriptions"),
                      data="subscriptions_settings")
    ],
               [
                   Button.inline(LOCALIZE.get_text(locale, "bot_lang"),
                                 data="lang_settings")
               ],
               [
                   Button.inline(LOCALIZE.get_text(locale, "preferred_device"),
                                 data="device_settings")
               ]]
    return message, buttons
Exemplo n.º 13
0
async def vendor_message(device, codenames_names, locale):
    """ Generate telegram message of vendor command """
    message = LOCALIZE.get_text(locale, "vendor_message").replace(
        "{device}", device).replace("{codenames_names[device]}",
                                    codenames_names[device])
    buttons = [[
        Button.url(LOCALIZE.get_text(locale, "latest_vendor"),
                   f"{XFU_WEBSITE}/vendor/{device}/"),
        Button.url(LOCALIZE.get_text(locale, "archive_vendor"),
                   f"{XFU_WEBSITE}/archive/vendor/{device}/")
    ],
               [
                   Button.url(LOCALIZE.get_text(locale, "MIUIVendorUpdater"),
                              "https://t.me/MIUIVendorUpdater")
               ]]
    return message, buttons
Exemplo n.º 14
0
async def preferred_device_message(device, codenames_names, locale):
    """ Generate preferred device message"""
    if device:
        message = f"**" + LOCALIZE.get_text(locale, "your_preferred_device") + ":**\n" +\
            f"{codenames_names[device]} (`{device}`)"
    else:
        message = f"**{LOCALIZE.get_text(locale, 'no_subscriptions')}**"
    return message
Exemplo n.º 15
0
async def oss_inline(event, device, locale):
    """ Generate telegram result of oss inline query """
    builder = event.builder
    message = await oss_message(device, locale)
    result = builder.article(LOCALIZE.get_text(locale, "oss_inline").replace(
        "{device}", device),
                             text=message)
    return result
Exemplo n.º 16
0
async def guides_inline(event, locale):
    """ Generate telegram result of guides inline query """
    builder = event.builder
    message, buttons = await guides_message(locale)
    result = builder.article(LOCALIZE.get_text(locale, 'guides_inline'),
                             text=message,
                             buttons=buttons,
                             link_preview=False)
    return result
Exemplo n.º 17
0
async def twrp_message(device, twrp_data, locale):
    """ Generate telegram message of twrp command """
    data = await get_twrp(device, twrp_data)
    message = LOCALIZE.get_text(locale, "twrp_message").replace(
        "{data['name']}", data['name']).replace("{data['date']}", data['date'])
    buttons = [[
        Button.url(f'{data["dl_file"]} - {data["size"]}', url=data["dl_link"])
    ]]
    return message, buttons
Exemplo n.º 18
0
async def latest_miui_inline(event, device, updates, codenames_names, locale):
    """ Generate telegram result of latest inline query """
    builder = event.builder
    message = await latest_miui_message(device, updates, codenames_names, locale)
    result = builder.article(
        LOCALIZE.get_text(locale, "latest_inline").replace(
            "{codenames_names[device]}", codenames_names[device]).replace(
            "{device}", device), text=message)
    return result
Exemplo n.º 19
0
async def subscriptions_message(subscriptions, locale):
    """ Generate subscriptions message"""
    message = f"**" + LOCALIZE.get_text(locale, "your_subscriptions") + ":**\n"
    if subscriptions:
        for subscription in subscriptions:
            message += f"{subscription[1]} ({subscription[0]})\n"
    else:
        message = f"**{LOCALIZE.get_text(locale, 'no_subscriptions')}**"
    return message
Exemplo n.º 20
0
async def info_help_message(locale):
    """ Generate telegram message of info help"""
    example = LOCALIZE.get_text(locale, "Example")
    return f"/models `codename`: {LOCALIZE.get_text(locale, 'models_help')}\n" \
           f"__{example}:__ `/models whyred`\n\n" \
           f"/whatis `codename`: {LOCALIZE.get_text(locale, 'whatis_help')}\n" \
           f"__{example}:__ `/whatis whyred`\n\n" \
           f"/codename `codename`: {LOCALIZE.get_text(locale, 'codename_help')}\n" \
           f"__{example}:__ `/codename mi 9t`"
Exemplo n.º 21
0
async def twrp_inline(event, device, twrp_data, locale):
    """ Generate telegram result of twrp inline query """
    builder = event.builder
    message, buttons = await twrp_message(device, twrp_data, locale)
    result = builder.article(LOCALIZE.get_text(locale, "twrp_inline"),
                             text=message,
                             buttons=buttons,
                             link_preview=False)
    return result
Exemplo n.º 22
0
async def unlockbl_inline(event, locale):
    """ Generate telegram result of unlockbl inline query """
    builder = event.builder
    message, buttons = await unlockbl_message(locale)
    result = builder.article(LOCALIZE.get_text(locale, "unlock_bl_inline"),
                             text=message,
                             buttons=buttons,
                             link_preview=False)
    return result
Exemplo n.º 23
0
async def custom_recovery_help_message(locale):
    """ Generate telegram message of custom_recovery help"""
    example = LOCALIZE.get_text(locale, "Example")
    return f"/twrp `codename`: {LOCALIZE.get_text(locale, 'twrp_help')}\n" \
           f"__{example}:__ `/twrp whyred`\n\n" \
           f"/of `codename`: {LOCALIZE.get_text(locale, 'of_help')}\n" \
           f"__{example}:__ `/of whyred`\n\n" \
           f"/pb `codename`: {LOCALIZE.get_text(locale, 'pb_help')}\n" \
           f"__{example}:__ `/pb sagit`"
Exemplo n.º 24
0
async def pitchblack_message(device, pitchblack_data, locale):
    """ Generate telegram message of pitchblack command """
    data = await get_pitchblack(device, pitchblack_data)
    message = LOCALIZE.get_text(locale, "pitchblack_message").replace(
        "{device}", device) + ':\n'
    buttons = []
    for file, link in data.items():
        buttons.append([Button.url(f'{file}', url=link)])
    return message, buttons
Exemplo n.º 25
0
async def models_message(device, models_data, locale):
    """ Generate telegram message of models command """
    message = '**' + LOCALIZE.get_text(locale, "device_models").replace(
        "{models_data[device]['name']}", models_data[device]['name']).replace(
            "{device}", device).replace(
                "{models_data[device]['internal_name']}",
                models_data[device]['internal_name']) + ':**\n\n'
    for model, model_name in models_data[device]["models"].items():
        message += f"{model}: {model_name}\n"
    return message
async def latest_miui_message(device, updates, codenames_names, locale):
    """ Generate telegram message for latest command """
    data = await get_miui(device, "Recovery", updates)
    message = LOCALIZE.get_text(locale, "latest_message").replace(
        "{codenames_names[device]}", codenames_names[device]).replace(
            "{device}", device) + ":\n"
    for i in data:
        version = i['version']
        message += f"{i['name']} {i['branch']}: `{version}`\n"
    return message
Exemplo n.º 27
0
async def subscriptions_help(event):
    """subscriptions settings callback handler"""
    locale = DATABASE.get_locale(event.chat_id)
    subscriptions = DATABASE.get_chat_subscriptions(event.chat_id)
    try:
        await event.edit(await subscriptions_message(subscriptions, locale), buttons=[
            [Button.inline(LOCALIZE.get_text(locale, "Back"), data="settings")],
        ])
    except (MessageNotModifiedError, ChannelPrivateError, ChatWriteForbiddenError):
        pass
Exemplo n.º 28
0
async def subscriptions_help_message(locale):
    """ Generate telegram message of subscriptions help"""
    example = LOCALIZE.get_text(locale, "Example")
    return "/subscribe `firmware`|`miui`|`vendor` `codename`: " \
           f"\n{LOCALIZE.get_text(locale, 'subscribe_help')}\n" \
           f"__{example}:__ `/subscribe firmware whyred`\n\n" \
           f"/unsubscribe `firmware`|`miui`|`vendor` `codename`: " \
           f"\n{LOCALIZE.get_text(locale, 'unsubscribe_help')}\n" \
           f"__{example}:__ `/unsubscribe firmware whyred`\n\n" \
           f"/subscription: {LOCALIZE.get_text(locale, 'subscription_help')}"
Exemplo n.º 29
0
async def orangefox_inline(event, device, locale):
    """ Generate telegram result of orangefox inline query """
    builder = event.builder
    message, buttons = await orangefox_message(device, locale)
    result = builder.article(LOCALIZE.get_text(locale,
                                               "orangefox_inline").replace(
                                                   "{device}", device),
                             text=message,
                             buttons=buttons,
                             link_preview=False)
    return result
Exemplo n.º 30
0
async def miui_help_message(locale):
    """ Generate telegram message of miui help"""
    example = LOCALIZE.get_text(locale, "Example")
    return f"/recovery `codename`: {LOCALIZE.get_text(locale, 'recovery_help')}\n" \
           f"__{example}:__ `/recovery whyred`\n\n" \
           f"/fastboot `codename`: {LOCALIZE.get_text(locale, 'fastboot_help')}\n" \
           f"__{example}:__ `/fastboot whyred`\n\n" \
           f"/latest `codename`: {LOCALIZE.get_text(locale, 'latest_help')}\n" \
           f"__{example}:__ `/latest sagit`\n\n" \
           f"/archive `codename`: {LOCALIZE.get_text(locale, 'archive_help')}\n" \
           f"__{example}:__ `/archive mido`"