diff options
author | Mikhail Kirillov <w96k@runbox.com> | 2024-10-10 06:53:36 +0400 |
---|---|---|
committer | Mikhail Kirillov <w96k@runbox.com> | 2024-10-10 06:53:36 +0400 |
commit | 1f94544ff6c9357b2911dfa5ca50f3e007963332 (patch) | |
tree | a5d275ef99729de0469c655b96a850c8e3961b85 | |
parent | 23bddf358dc615d18ed4470f33f383f1eac9ac63 (diff) |
Remove /movies_remove command.
-rw-r--r-- | commands/__init__.py | 2 | ||||
-rw-r--r-- | commands/movie.py | 26 | ||||
-rw-r--r-- | main.py | 1 |
3 files changed, 8 insertions, 21 deletions
diff --git a/commands/__init__.py b/commands/__init__.py index 7081c89..17abd8c 100644 --- a/commands/__init__.py +++ b/commands/__init__.py @@ -12,7 +12,7 @@ from .meta import about from .users import set_users, add_users, list_users, remove_users, \ chooser_user, who_is_next -from .movie import movie, movies, remove_movies +from .movie import movie, movies from .event import create_event, list_events from .announce import create_announcement diff --git a/commands/movie.py b/commands/movie.py index 256156f..adb05ac 100644 --- a/commands/movie.py +++ b/commands/movie.py @@ -72,6 +72,13 @@ async def movie( if len(context.chat_data["movies"]) > 0 and \ context.chat_data["movies"][-1]["user"] == username: context.chat_data["movies"][-1] = movie_dict + + last_event = context.chat_data["events"][-1] \ + if len(context.chat_data["events"]) > 0 else None + + if last_event and context.chat_data["events"][-1]["user"] == username: + last_event["title"] = movie_dict["title"] + context.chat_data["events"][-1] = last_event else: context.chat_data["movies"].append(movie_dict) @@ -102,22 +109,3 @@ async def movies( await update.message.reply_text(movies_formatted) - -async def remove_movies( - update: Update, - context: ContextTypes.DEFAULT_TYPE -) -> None: - context_init(context) - - if context.args == []: - raise error.TelegramError(MOVIE_NOT_PROVIDED) - - movies = context.chat_data["movies"] - - for movie_id in context.args: - for movie in movies: - if movie["id"] == movie_id: - context.chat_data["movies"].remove(movie) - await update.message.reply_text( - MOVIE_REMOVE.format(title=movie["title"], id=movie["id"]) - ) @@ -63,7 +63,6 @@ if __name__ == "__main__": # Movie commands app.add_handler(CommandHandler("movie", commands.movie)) app.add_handler(CommandHandler("movies", commands.movies)) - app.add_handler(CommandHandler("movies_remove", commands.remove_movies)) # Users commands app.add_handler(CommandHandler("set", commands.set_users)) |