diff options
author | Mikhail Kirillov <w96k@runbox.com> | 2024-10-11 01:53:24 +0400 |
---|---|---|
committer | Mikhail Kirillov <w96k@runbox.com> | 2024-10-11 01:53:24 +0400 |
commit | 69dd60cc024063daf1591168a64a32e771bd7f1b (patch) | |
tree | 9af211858513072175e5611a15e47012b34f349c /commands/announce.py | |
parent | 694d823d4d46ec2914f6e210f8903887e4a72d79 (diff) |
Task #30. Allow anyone create or edit upcoming event
Diffstat (limited to 'commands/announce.py')
-rw-r--r-- | commands/announce.py | 8 |
1 files changed, 6 insertions, 2 deletions
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( |