Changeset 23bddf3 in python-cinema-club-bot for commands/users.py


Ignore:
Timestamp:
Oct 10, 2024, 6:20:52 AM (5 weeks ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
1f94544
Parents:
8d2d5ac
Message:

Task #10. /announce command

File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands/users.py

    r8d2d5ac r23bddf3  
    1717    EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE, ADD_MORE_USERS, \
    1818    NEXT_MOVIE_USER, USER_NOT_FOUND, USER_CHOOSE, NO_USERS, \
    19     EVENT_USER_HAD_EVENT
    20 from utils import context_init, create_users_string, normalize_username, \
    21     choose_next_user
     19    EVENT_USER_HAD_EVENT, NEXT_MOVIE
     20from utils import context_init, create_users_string, choose_next_user
    2221from predicates import has_finished_event
     22
    2323
    2424async def set_users(
     
    8787        users = context.chat_data["users"] = choose_next_user(users)
    8888
    89     await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0]))
     89    next_user_string = NEXT_MOVIE_USER.format(user=users[0])
     90
     91    last_movie = context.chat_data["movies"][0] \
     92        if context.chat_data["movies"] != [] else None
     93
     94    if last_movie and last_movie["user"] == users[0]:
     95        next_user_string += NEXT_MOVIE.format(movie=last_movie["title"])
     96
     97    await update.message.reply_text(next_user_string)
    9098
    9199
Note: See TracChangeset for help on using the changeset viewer.