# This file is part of python-cinema-club-bot # contributed in 2024 by Mikhail Kirillov (~w96k) # To the extent possible under law, the author(s) have dedicated all copyright # and related and neighboring rights to this software to the public domain # worldwide. This software is distributed without any warranty. # You should have received a copy of the CC0 Public Domain Dedication along # with this software. If not, see: # from telegram import Update, error from telegram.ext import ContextTypes from strings import ANNOUNCEMENT_TEMPLATE, ANNOUNCEMENT_FINISHED_EVENT from utils import context_init, create_users_string, choose_next_user from predicates import has_unfinished_event async def create_announcement( update: Update, context: ContextTypes.DEFAULT_TYPE ) -> None: context_init(context) intro = " ".join(context.args) events = context.chat_data["events"] movies = context.chat_data["movies"] if has_unfinished_event(context): last_event = events[-1] last_movie = movies[-1] genres = " #".join(last_movie["genres"]) await update.message.reply_markdown( ANNOUNCEMENT_TEMPLATE.format( intro=intro, movie_title=last_movie["title"], movie_id=last_movie["id"], movie_runtime=last_movie["runtime"][0], when=last_event["when"], where=last_event["where"], user=last_movie["user"], rating=last_movie["rating"], genres=genres, ) ) return await update.message.reply_text(ANNOUNCEMENT_FINISHED_EVENT)