bug fixes
This commit is contained in:
		| @@ -2,12 +2,21 @@ from datetime import date | |||||||
| from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler, CallbackContext | from telegram.ext import ConversationHandler, CommandHandler, MessageHandler, filters, CallbackQueryHandler, CallbackContext | ||||||
| from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, InputMediaPhoto | from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update, InputMediaPhoto | ||||||
| import random | import random | ||||||
|  | import os | ||||||
|  | from pathlib import Path | ||||||
| # ACTION_CHOICE, DATE_ENTRY, ADD_CONTENT = range(3) | # ACTION_CHOICE, DATE_ENTRY, ADD_CONTENT = range(3) | ||||||
| ACTION, TUERCHEN_CHOICE = range(2) | ACTION, TUERCHEN_CHOICE = range(2) | ||||||
|  |  | ||||||
|  |  | ||||||
| from .basehandler import BaseHandler | from .basehandler import BaseHandler | ||||||
|  |  | ||||||
|  | MEDIA_DIR = Path(os.getenv("MEDIA_DIR")) | ||||||
|  | GIF_LOCATION = MEDIA_DIR / "advent" / "gifs" | ||||||
|  | GIFS = list(GIF_LOCATION.glob("*.mp4")) | ||||||
|  | STICKER_LOCATION = MEDIA_DIR / "advent" / "stickers" | ||||||
|  | STICKERS = list(STICKER_LOCATION.glob("*.tgs")) | ||||||
|  | PICTURE_LOCATION = MEDIA_DIR / "advent" / "pretty_pictures" | ||||||
|  | PICTURES = list(PICTURE_LOCATION.glob("*.jpg")) | ||||||
|  |  | ||||||
| class AdventsHandler(BaseHandler): | class AdventsHandler(BaseHandler): | ||||||
|     def __init__(self, entry_string): |     def __init__(self, entry_string): | ||||||
|         self.entry_string = entry_string |         self.entry_string = entry_string | ||||||
| @@ -66,7 +75,7 @@ class AdventsHandler(BaseHandler): | |||||||
|         keyboard = [[InlineKeyboardButton("Bubo Küsschen", callback_data="kuss")], [InlineKeyboardButton("Türchen öffnen", callback_data="tuer")], [InlineKeyboardButton("Pretty Bubo Picture", callback_data="picture")]] |         keyboard = [[InlineKeyboardButton("Bubo Küsschen", callback_data="kuss")], [InlineKeyboardButton("Türchen öffnen", callback_data="tuer")], [InlineKeyboardButton("Pretty Bubo Picture", callback_data="picture")]] | ||||||
|  |  | ||||||
|         reply_markup = InlineKeyboardMarkup(keyboard) |         reply_markup = InlineKeyboardMarkup(keyboard) | ||||||
|         await update.message.reply_sticker(sticker=open(".bot_storage\stickers\stickerwhat.tgs", "rb")) |         await update.message.reply_sticker(sticker=STICKER_LOCATION/"stickerwhat.tgs") | ||||||
|         await update.message.reply_text(text="Hallo, mein süßer Weihnachts-Bubo! Ich bin dein Adventskalender ^^. Was möchtest du tun?", reply_markup=reply_markup) |         await update.message.reply_text(text="Hallo, mein süßer Weihnachts-Bubo! Ich bin dein Adventskalender ^^. Was möchtest du tun?", reply_markup=reply_markup) | ||||||
|  |  | ||||||
|         return ACTION |         return ACTION | ||||||
| @@ -79,7 +88,7 @@ class AdventsHandler(BaseHandler): | |||||||
|         keyboard = [[InlineKeyboardButton("Kalendertürchen öffnen", callback_data="tuer")], [InlineKeyboardButton("Noch ein Küsschen!", callback_data="kuss")], [InlineKeyboardButton("Pretty Bubo Picture", callback_data="picture")], [InlineKeyboardButton("Bis zum nächsten Mal!", callback_data="bye")]] |         keyboard = [[InlineKeyboardButton("Kalendertürchen öffnen", callback_data="tuer")], [InlineKeyboardButton("Noch ein Küsschen!", callback_data="kuss")], [InlineKeyboardButton("Pretty Bubo Picture", callback_data="picture")], [InlineKeyboardButton("Bis zum nächsten Mal!", callback_data="bye")]] | ||||||
|         reply_markup = InlineKeyboardMarkup(keyboard) |         reply_markup = InlineKeyboardMarkup(keyboard) | ||||||
|  |  | ||||||
|         await update.effective_message.reply_sticker(sticker=open(".bot_storage\stickers\stickerkiss.tgs", "rb")) |         await update.effective_message.reply_sticker(sticker=STICKER_LOCATION/"stickerkiss.tgs") | ||||||
|         await update.effective_message.reply_text(text="Mua!", reply_markup=reply_markup) |         await update.effective_message.reply_text(text="Mua!", reply_markup=reply_markup) | ||||||
|  |  | ||||||
|         return ACTION |         return ACTION | ||||||
| @@ -101,7 +110,8 @@ class AdventsHandler(BaseHandler): | |||||||
|         reply_markup = InlineKeyboardMarkup(keyboard) |         reply_markup = InlineKeyboardMarkup(keyboard) | ||||||
|  |  | ||||||
|         picture_number = random.randint(1,31) |         picture_number = random.randint(1,31) | ||||||
|         await update.effective_message.reply_photo(photo=open(".bot_storage\pretty_pictures\photo_"+f"{picture_number}"+"_2023-11-25_14-25-53.jpg", "rb"), caption="So ein cutes Foto!", reply_markup=reply_markup) |         #print(picture_number-1) | ||||||
|  |         await update.effective_message.reply_photo(photo=PICTURES[picture_number-1], caption="So ein cutes Foto!", reply_markup=reply_markup) | ||||||
|  |  | ||||||
|         return ACTION |         return ACTION | ||||||
|      |      | ||||||
| @@ -118,9 +128,9 @@ class AdventsHandler(BaseHandler): | |||||||
|          |          | ||||||
|         #if tuer_nummer <= int(date.today().strftime("%d")): |         #if tuer_nummer <= int(date.today().strftime("%d")): | ||||||
|         if (tuer_nummer <= int(date.today().strftime("%d"))) and (int(date.today().strftime("%m"))==12): |         if (tuer_nummer <= int(date.today().strftime("%d"))) and (int(date.today().strftime("%m"))==12): | ||||||
|             await update.message.reply_document(document=open(".bot_storage\gifs\gif"+f"{tuer_nummer}"+".mp4", "rb"),caption=f"Türchen für den {tuer_nummer}. Dezember: \n" + self.tuerchen_texte[tuerchen], reply_markup=reply_markup) |             await update.message.reply_document(document=GIFS[tuer_nummer-1], caption=f"Türchen für den {tuer_nummer}. Dezember: \n" + self.tuerchen_texte[tuerchen], reply_markup=reply_markup) | ||||||
|         else: |         else: | ||||||
|             await update.message.reply_sticker(sticker=open(".bot_storage\stickers\stickerangry.tgs", "rb")) |             await update.message.reply_sticker(sticker=STICKER_LOCATION/"stickerangry.tgs") | ||||||
|             await update.message.reply_text(text="Hey, nicht schummeln! Dieses Türchen darfst du noch nicht sehen.", reply_markup=reply_markup) |             await update.message.reply_text(text="Hey, nicht schummeln! Dieses Türchen darfst du noch nicht sehen.", reply_markup=reply_markup) | ||||||
|  |  | ||||||
|         return ACTION |         return ACTION | ||||||
| @@ -129,7 +139,7 @@ class AdventsHandler(BaseHandler): | |||||||
|         query = update.callback_query |         query = update.callback_query | ||||||
|         await query.answer() |         await query.answer() | ||||||
|  |  | ||||||
|         await update.effective_message.reply_sticker(sticker=open(".bot_storage\stickers\stickerbye.tgs", "rb")) |         await update.effective_message.reply_sticker(sticker=STICKER_LOCATION/"stickerbye.tgs") | ||||||
|         await update.effective_message.reply_text(text="Bye bye, Bubo! Hab dich ganz doll lieb! 😘") |         await update.effective_message.reply_text(text="Bye bye, Bubo! Hab dich ganz doll lieb! 😘") | ||||||
|  |  | ||||||
|         return ConversationHandler.END |         return ConversationHandler.END | ||||||
|   | |||||||
| @@ -12,7 +12,7 @@ class RandomMemoryJob(): | |||||||
|          |          | ||||||
|         if os.getenv("DOCKERIZED", "false") != "true": |         if os.getenv("DOCKERIZED", "false") != "true": | ||||||
|             # when running locally, annoy the programmer every 60 seconds <3 |             # when running locally, annoy the programmer every 60 seconds <3 | ||||||
|             job_queue.run_repeating(self.callback_memory, interval=60) |             job_queue.run_repeating(self.callback_memory, interval=3600) | ||||||
|             self.min_age = 0 # do not filter messages: show them all |             self.min_age = 0 # do not filter messages: show them all | ||||||
|         else: |         else: | ||||||
|             # set the message sending time; include UTC shift +2 |             # set the message sending time; include UTC shift +2 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lia Schöneweiß
					Lia Schöneweiß