feat(handlers): add a message handler
Signed-off-by: Sphericalkat <me@kat.bio>
This commit is contained in:
parent
894d840e94
commit
98809e62a4
18
main.py
18
main.py
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user