Ejemplo n.º 1
0
def main():
    start_handler = CommandHandler("start",
                                   start,
                                   filters=Filters.user(OWNER_ID),
                                   run_async=True)
    help_handler = CommandHandler("help",
                                  help,
                                  filters=Filters.user(OWNER_ID),
                                  run_async=True)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(help_handler)

    if WEBHOOK and URL:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen=IP_ADDRESS, port=PORT, url_path=API_KEY)

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

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)

    updater.idle()
Ejemplo n.º 2
0
                                   start,
                                   filters=Filters.user(OWNER_ID),
                                   run_async=True)
    help_handler = CommandHandler("help",
                                  help,
                                  filters=Filters.user(OWNER_ID),
                                  run_async=True)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(help_handler)

    if WEBHOOK and URL:
        LOGGER.info("Using webhooks.")
        updater.start_webhook(listen=IP_ADDRESS, port=PORT, url_path=API_KEY)

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

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)

    updater.idle()


if __name__ == "__main__":
    LOGGER.info("Successfully loaded modules: " + str(ALL_MODULES))
    main()
Ejemplo n.º 3
0
from forwarder import LOGGER


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')
    ]

    return all_modules


ALL_MODULES = sorted(__list_all_modules())
LOGGER.info("Modules to load: " + str(ALL_MODULES))
Ejemplo n.º 4
0
                                   start,
                                   filters=Filters.user(OWNER_ID),
                                   run_async=True)
    help_handler = CommandHandler("help",
                                  help,
                                  filters=Filters.user(OWNER_ID),
                                  run_async=True)
    dispatcher.add_handler(start_handler)
    dispatcher.add_handler(help_handler)

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

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

    else:
        LOGGER.info("Using long polling.")
        updater.start_polling(timeout=15, read_latency=4)

    updater.idle()


if __name__ == '__main__':
    LOGGER.info("Plugins cargados con éxito: " + str(ALL_MODULES))
    main()
Ejemplo n.º 5
0
from forwarder import LOGGER


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')
    ]

    return all_modules


ALL_MODULES = sorted(__list_all_modules())
LOGGER.info("Plugins para cargar: " + str(ALL_MODULES))