def main(): START_HANDLER = CommandHandler("start", start) HELP_HANDLER = CommandHandler("help", help) dispatcher.add_handler(START_HANDLER) dispatcher.add_handler(HELP_HANDLER) if WEBHOOK: logger.info("Using webhooks.") updater.start_webhook(listen=LISTEN, 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.idle()
from skitt_bot import logger def __list_all_modules(): from os.path import dirname, basename, isfile import glob 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: %s", str(ALL_MODULES)) __all__ = ALL_MODULES + ["ALL_MODULES"]
"Try this command again in a private message.") def main(): START_HANDLER = CommandHandler("start", start) HELP_HANDLER = CommandHandler("help", help) dispatcher.add_handler(START_HANDLER) dispatcher.add_handler(HELP_HANDLER) if WEBHOOK: logger.info("Using webhooks.") updater.start_webhook(listen=LISTEN, 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.idle() if __name__ == '__main__': logger.info("Successfully loaded modules: " + str(ALL_MODULES)) main()