implemented turtle hello

This commit is contained in:
Lia Schöneweiß 2023-05-04 23:19:29 +02:00
parent e7281da9a2
commit b1525ed5c3
2 changed files with 25 additions and 2 deletions

View File

@ -1,13 +1,33 @@
import os
from pathlib import Path
from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram import Update
from .basehandler import BaseHandler
MEDIA_DIR = Path(os.getenv("MEDIA_DIR"))
TURTLE_VIDEO_LOCATION = MEDIA_DIR / "turtle_reactions"
TURTLE_VIDEOS = list(TURTLE_VIDEO_LOCATION.glob("*.mp4"))
class TurtleHandler(BaseHandler):
def __init__(self):
self.entry_string = "Variation of hallo"
self.handler = MessageHandler(filters.Regex(r"Hallo|hallo"), self.entry_point)
pass
async def entry_point(self, update, context):
async def entry_point(self, update: Update, context):
await super().entry_point(update, context)
update.message.reply_
msgtxt = update.message.text
if "hallo" in msgtxt:
vid = TURTLE_VIDEOS[0]
answertxt = "hallo1"
elif "Hallo" in msgtxt:
vid = TURTLE_VIDEOS[1]
answertxt = "Hallo2"
await update.message.reply_video(video=vid, caption=answertxt)
# await update.message.reply_text(text=answertxt)

View File

@ -5,7 +5,9 @@ import logging
import models
from commands import journal, status
from commands.list import list
from commands import turtle
from cronjob import chat_photo
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO
@ -27,6 +29,7 @@ def main() -> None:
application.add_handler(journal.JournalHandler("journal", models).handler)
application.add_handler(list.ListHandler("list", models).handler)
application.add_handler(status.StatusHandler("status", models).handler)
application.add_handler(turtle.TurtleHandler().handler)
# application.add_handler(CommandHandler("help", help_command))
# on non command i.e message - echo the message on Telegram
# application.add_handler(InlineQueryHandler(inline_query))