feat(handlers): add a message handler
Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
1 file changed
+17
-1
@@ -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()
|
||||
Reference in new issue
Block a user