Exemple #1
0
def __list_all_modules():
    from os.path import dirname, basename, isfile
    import glob
    # This generates a list of modules in this folder for the * in __main__ to work.
    mod_paths = glob.glob(dirname(__file__) + "/*.py")
    all_modules = [
        basename(f)[:-3] for f in mod_paths
        if isfile(f) and f.endswith(".py") and not f.endswith('__init__.py')
    ]

    if LOAD or NO_LOAD:
        to_load = LOAD
        if to_load:
            if not all(
                    any(mod == module_name for module_name in all_modules)
                    for mod in to_load):
                LOGGER.error("Invalid loadorder names. Quitting.")
                quit(1)

        else:
            to_load = all_modules

        if NO_LOAD:
            LOGGER.info("Not loading: {}".format(NO_LOAD))
            return [item for item in to_load if item not in NO_LOAD]

        return to_load

    return all_modules
Exemple #2
0
def main():
    test_handler = CommandHandler("test", test)
    start_handler = CommandHandler("start", start, pass_args=True)

    help_handler = CommandHandler("help", get_help)
    help_callback_handler = CallbackQueryHandler(help_button, pattern=r"help_")

    settings_handler = CommandHandler("settings", get_settings)
    settings_callback_handler = CallbackQueryHandler(settings_button,
                                                     pattern=r"stngs_")

    source_handler = CommandHandler("source", source)
    M_CONNECT_BTN_HANDLER = CallbackQueryHandler(m_connect_button,
                                                 pattern=r"main_connect")
    M_SETLANG_BTN_HANDLER = CallbackQueryHandler(m_change_langs,
                                                 pattern=r"main_setlang")

    # dispatcher.add_handler(test_handler)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(help_handler)
    dispatcher.add_handler(settings_handler)
    dispatcher.add_handler(help_callback_handler)
    dispatcher.add_handler(settings_callback_handler)
    dispatcher.add_handler(source_handler)
    dispatcher.add_handler(M_CONNECT_BTN_HANDLER)
    dispatcher.add_handler(M_SETLANG_BTN_HANDLER)

    # dispatcher.add_error_handler(error_callback)

    if WEBHOOK:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen="127.0.0.1", port=PORT, url_path=TOKEN)

        if CERT_PATH:
            updater.bot.set_webhook(url=URL + TOKEN,
                                    certificate=open(CERT_PATH, 'rb'))
        else:
            updater.bot.set_webhook(url=URL + TOKEN)

    else:
        LOGGER.info("Using long polling.")
        # updater.start_polling(timeout=15, read_latency=4)
        updater.start_polling(poll_interval=0.0,
                              timeout=10,
                              clean=True,
                              bootstrap_retries=-1,
                              read_latency=3.0)

    updater.idle()
Exemple #3
0
    dispatcher.add_handler(M_CONNECT_BTN_HANDLER)
    dispatcher.add_handler(M_SETLANG_BTN_HANDLER)

    # dispatcher.add_error_handler(error_callback)

    if WEBHOOK:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen="127.0.0.1", port=PORT, url_path=TOKEN)

        if CERT_PATH:
            updater.bot.set_webhook(url=URL + TOKEN,
                                    certificate=open(CERT_PATH, 'rb'))
        else:
            updater.bot.set_webhook(url=URL + TOKEN)

    else:
        LOGGER.info("Using long polling.")
        # updater.start_polling(timeout=15, read_latency=4)
        updater.start_polling(poll_interval=0.0,
                              timeout=10,
                              clean=True,
                              bootstrap_retries=-1,
                              read_latency=3.0)

    updater.idle()


if __name__ == '__main__':
    LOGGER.info("Successfully loaded modules: " + str(ALL_MODULES))
    main()
Exemple #4
0
from fortizers.modules.helper_funcs.alternate import send_message

LOADED_LANGS_ID = []
LANGS_TEXT = {}
FUNC_LANG = {}

for x in os.listdir('fortizers/modules/langs'):
    if os.path.isdir('fortizers/modules/langs/' + x):
        continue
    x = x.replace('.py', '')
    LOADED_LANGS_ID.append(x)
    imported_langs = importlib.import_module("fortizers.modules.langs." + x)
    FUNC_LANG[x] = imported_langs
    LANGS_TEXT[x] = imported_langs.__lang__

LOGGER.info("{} languages loaded: {}".format(len(LOADED_LANGS_ID),
                                             LOADED_LANGS_ID))


def tl(message, text):
    if type(message) == int or type(message) == str and message[1:].isdigit():
        getlang = sql.get_lang(message)
        if getlang == 'None' or not getlang:
            getlang = 'en'
    else:
        getlang = sql.get_lang(message.chat.id)
        if getlang == 'None' or not getlang:
            if message.from_user.language_code:
                if message.from_user.language_code in LOADED_LANGS_ID:
                    sql.set_lang(message.chat.id,
                                 message.from_user.language_code)
                    getlang = message.from_user.language_code
Exemple #5
0
    mod_paths = glob.glob(dirname(__file__) + "/*.py")
    all_modules = [
        basename(f)[:-3] for f in mod_paths
        if isfile(f) and f.endswith(".py") and not f.endswith('__init__.py')
    ]

    if LOAD or NO_LOAD:
        to_load = LOAD
        if to_load:
            if not all(
                    any(mod == module_name for module_name in all_modules)
                    for mod in to_load):
                LOGGER.error("Invalid loadorder names. Quitting.")
                quit(1)

        else:
            to_load = all_modules

        if NO_LOAD:
            LOGGER.info("Not loading: {}".format(NO_LOAD))
            return [item for item in to_load if item not in NO_LOAD]

        return to_load

    return all_modules


ALL_MODULES = sorted(__list_all_modules())
LOGGER.info("Modules to load: %s", str(ALL_MODULES))
__all__ = ALL_MODULES + ["ALL_MODULES"]
Exemple #6
0
from telegram.ext import CommandHandler, run_async
from telegram.error import BadRequest

from fortizers import dispatcher, LOGGER, spamcheck
from fortizers.modules.languages import tl

# DO NOT DELETE THIS, PLEASE.
# Originally made by @RealAkito on GitHub and Telegram
# This module was inspired by Android Helper Bot by Vachounet.

# This module has been modified by @HitaloSama on GitHub
# Command /magisk /twrp and /device were obtained thanks to corsicanu bot (originally kanged from UserBot PaperplaneExtended)
# Command /specs was only possible thanks to the help of AvinashReddy3108

LOGGER.info(
    "Original Android Modules by @RealAkito on Telegram, modified by @HitaloSama on GitHub"
)

WIKI = 'https://xiaomiwiki.github.io/wiki'
GITHUB = 'https://github.com'
DEVICES_DATA = 'https://raw.githubusercontent.com/androidtrackers/certified-android-devices/master/by_device.json'


@spamcheck
@run_async
def device(update, context):
    args = context.args
    if len(args) == 0:
        reply = 'No codename provided, write a codename for fetching informations.'
        update.effective_message.reply_text("{}".format(reply),
                                            parse_mode=ParseMode.MARKDOWN,