implemented turtle hello
This commit is contained in:
		| @@ -1,13 +1,33 @@ | |||||||
|  | import os | ||||||
|  | from pathlib import Path | ||||||
| from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler | from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler | ||||||
| from telegram import InlineKeyboardButton, InlineKeyboardMarkup | from telegram import InlineKeyboardButton, InlineKeyboardMarkup | ||||||
|  | from telegram import Update | ||||||
|  |  | ||||||
| from .basehandler import BaseHandler | 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): | class TurtleHandler(BaseHandler): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|  |         self.entry_string = "Variation of hallo" | ||||||
|         self.handler = MessageHandler(filters.Regex(r"Hallo|hallo"), self.entry_point) |         self.handler = MessageHandler(filters.Regex(r"Hallo|hallo"), self.entry_point) | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     async def entry_point(self, update, context): |     async def entry_point(self, update: Update, context): | ||||||
|         await super().entry_point(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) | ||||||
|  |          | ||||||
| @@ -5,7 +5,9 @@ import logging | |||||||
| import models | import models | ||||||
| from commands import journal, status | from commands import journal, status | ||||||
| from commands.list import list | from commands.list import list | ||||||
|  | from commands import turtle | ||||||
| from cronjob import chat_photo | from cronjob import chat_photo | ||||||
|  |  | ||||||
| logging.basicConfig( | logging.basicConfig( | ||||||
|     format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", |     format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", | ||||||
|     level=logging.INFO |     level=logging.INFO | ||||||
| @@ -27,6 +29,7 @@ def main() -> None: | |||||||
|     application.add_handler(journal.JournalHandler("journal", models).handler) |     application.add_handler(journal.JournalHandler("journal", models).handler) | ||||||
|     application.add_handler(list.ListHandler("list", models).handler) |     application.add_handler(list.ListHandler("list", models).handler) | ||||||
|     application.add_handler(status.StatusHandler("status", models).handler) |     application.add_handler(status.StatusHandler("status", models).handler) | ||||||
|  |     application.add_handler(turtle.TurtleHandler().handler) | ||||||
|     # application.add_handler(CommandHandler("help", help_command)) |     # application.add_handler(CommandHandler("help", help_command)) | ||||||
|     # on non command i.e message - echo the message on Telegram |     # on non command i.e message - echo the message on Telegram | ||||||
|     # application.add_handler(InlineQueryHandler(inline_query)) |     # application.add_handler(InlineQueryHandler(inline_query)) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lia Schöneweiß
					Lia Schöneweiß