feat(handlers): add a message handler

Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
Amogh Lele 2024-05-25 12:40:59 +05:30
parent 894d840e94
commit 98809e62a4
Signed by: sphericalkat
GPG Key ID: 1C022B9CED2425B4

18
main.py
View File

@ -1,7 +1,13 @@
import logging
from telegram import Update
from telegram.ext import ContextTypes, ApplicationBuilder, CommandHandler
from telegram.ext import (
ContextTypes,
ApplicationBuilder,
CommandHandler,
MessageHandler,
filters,
)
from settings import Settings
@ -20,9 +26,19 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
)
async def message_handler(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(
chat_id=update.effective_chat.id,
text="I'm sorry, I'm a bot and I can't understand that.",
)
if __name__ == "__main__":
app = ApplicationBuilder().token(settings.bot_token).build()
start_handler = CommandHandler("start", start)
message_handler = MessageHandler(filters.ALL, message_handler)
app.add_handler(start_handler)
app.add_handler(message_handler)
app.run_polling()