From c7646b59f6e30c04cf3cee0389b652d93bf39704 Mon Sep 17 00:00:00 2001 From: Fedor Borshev Date: Thu, 20 Jun 2024 22:22:00 +0300 Subject: [PATCH] Added ping cmd --- bot.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bot.py b/bot.py index bdd8fc0..755f1d9 100644 --- a/bot.py +++ b/bot.py @@ -54,6 +54,14 @@ async def introduce_myself(update: Update, context: ContextTypes.DEFAULT_TYPE) - ) +async def ping(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: + if update.effective_chat is not None: + await context.bot.send_message( + chat_id=update.effective_chat.id, + text='pong!', + ) + + def delete_messages_that_match(*filters: BaseFilter) -> MessageHandler: """Sugar for quick adding delete message callbacks""" return MessageHandler(callback=delete, filters=with_default_filters(*filters)) @@ -72,6 +80,7 @@ def delete_messages_that_match(*filters: BaseFilter) -> MessageHandler: bot = Application.builder().token(bot_token).build() bot.add_handler(CommandHandler('start', introduce_myself)) + bot.add_handler(CommandHandler('ping', ping)) bot.add_handler(delete_messages_that_match(ContainsTelegramContact())) bot.add_handler(delete_messages_that_match(ContainsLink()))