Changeset 1f94544


Ignore:
Timestamp:
Oct 10, 2024, 6:53:36 AM (5 weeks ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
5ba045c
Parents:
23bddf3
Message:

Remove /movies_remove command.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • commands/__init__.py

    r23bddf3 r1f94544  
    1313from .users import set_users, add_users, list_users, remove_users, \
    1414    chooser_user, who_is_next
    15 from .movie import movie, movies, remove_movies
     15from .movie import movie, movies
    1616from .event import create_event, list_events
    1717from .announce import create_announcement
  • commands/movie.py

    r23bddf3 r1f94544  
    7373       context.chat_data["movies"][-1]["user"] == username:
    7474        context.chat_data["movies"][-1] = movie_dict
     75
     76        last_event = context.chat_data["events"][-1] \
     77            if len(context.chat_data["events"]) > 0 else None
     78
     79        if last_event and context.chat_data["events"][-1]["user"] == username:
     80            last_event["title"] = movie_dict["title"]
     81            context.chat_data["events"][-1] = last_event
    7582    else:
    7683        context.chat_data["movies"].append(movie_dict)
     
    103110    await update.message.reply_text(movies_formatted)
    104111
    105 
    106 async def remove_movies(
    107         update: Update,
    108         context: ContextTypes.DEFAULT_TYPE
    109 ) -> None:
    110     context_init(context)
    111 
    112     if context.args == []:
    113         raise error.TelegramError(MOVIE_NOT_PROVIDED)
    114 
    115     movies = context.chat_data["movies"]
    116 
    117     for movie_id in context.args:
    118         for movie in movies:
    119             if movie["id"] == movie_id:
    120                 context.chat_data["movies"].remove(movie)
    121                 await update.message.reply_text(
    122                     MOVIE_REMOVE.format(title=movie["title"], id=movie["id"])
    123                 )
  • main.py

    r23bddf3 r1f94544  
    6464    app.add_handler(CommandHandler("movie", commands.movie))
    6565    app.add_handler(CommandHandler("movies", commands.movies))
    66     app.add_handler(CommandHandler("movies_remove", commands.remove_movies))
    6766
    6867    # Users commands
Note: See TracChangeset for help on using the changeset viewer.