From 69dd60cc024063daf1591168a64a32e771bd7f1b Mon Sep 17 00:00:00 2001 From: Mikhail Kirillov Date: Fri, 11 Oct 2024 01:53:24 +0400 Subject: Task #30. Allow anyone create or edit upcoming event --- commands/announce.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'commands/announce.py') diff --git a/commands/announce.py b/commands/announce.py index 733e8d8..46e6500 100644 --- a/commands/announce.py +++ b/commands/announce.py @@ -12,7 +12,8 @@ from telegram import Update, error from telegram.ext import ContextTypes -from strings import ANNOUNCEMENT_TEMPLATE, ANNOUNCEMENT_FINISHED_EVENT +from strings import ANNOUNCEMENT_TEMPLATE, ANNOUNCEMENT_FINISHED_EVENT, \ + ANNOUNCEMENT_EVENT_NEEDS_EDITING from utils import context_init, create_users_string, choose_next_user from predicates import has_unfinished_event @@ -31,7 +32,10 @@ async def create_announcement( last_event = events[-1] last_movie = movies[-1] - genres = " #".join(last_movie["genres"]) + if last_event["when"] is None or last_event["where"] is None or last_event["movie"] is None: + raise error.TelegramError(ANNOUNCEMENT_EVENT_NEEDS_EDITING) + + genres ="#" + " #".join(last_movie["genres"]) await update.message.reply_markdown( ANNOUNCEMENT_TEMPLATE.format( -- cgit v1.2.3