From ff3789b85c846dc56cedd5da9d67dbe472e9f072 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 2 Jan 2019 22:19:25 +0100 Subject: [PATCH] Add example /ping command --- telegrambot.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/telegrambot.py b/telegrambot.py index 26fa0d0d..6f6cd9f2 100644 --- a/telegrambot.py +++ b/telegrambot.py @@ -80,6 +80,11 @@ def catch_and_report(func: "function"): return new_func +@catch_and_report +def cmd_ping(bot: Bot, update: Update): + bot.send_message(update.message.chat.id, "🏓 Pong!") + + @catch_and_report def cmd_register(bot: Bot, update: Update): session = db.Session() @@ -568,6 +573,7 @@ def process(arg_discord_connection): logger.info("Creating updater...") u = Updater(config["Telegram"]["bot_token"]) logger.info("Registering handlers...") + u.dispatcher.add_handler(CommandHandler("ping", cmd_ping)) u.dispatcher.add_handler(CommandHandler("register", cmd_register)) u.dispatcher.add_handler(CommandHandler("discord", cmd_discord)) u.dispatcher.add_handler(CommandHandler("cv", cmd_discord))