Changeset 9be02d9 in python-cinema-club-bot for commands/users.py
- Timestamp:
- Oct 10, 2024, 4:12:00 AM (5 weeks ago)
- Branches:
- master
- Children:
- 8d2d5ac
- Parents:
- 6623428
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands/users.py
r6623428 r9be02d9 16 16 from strings import USER_NOT_PROVIDED, USERS_ADDED, USERS_REMOVED, \ 17 17 EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE, ADD_MORE_USERS, \ 18 NEXT_MOVIE_USER, USER_NOT_FOUND, USER_CHOOSE 19 from utils import context_init, create_users_string 20 18 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 22 from predicates import has_finished_event 21 23 22 24 async def set_users( … … 32 34 33 35 await update.message.reply_text(USER_SET) 36 34 37 35 38 async def add_users( … … 57 60 users = context.chat_data["users"] 58 61 59 await update.message.reply_markdown(create_users_string(users)) 62 if users == []: 63 await update.message.reply_text(NO_USERS) 64 else: 65 if has_finished_event(context, users[0]): 66 users = context.chat_data["users"] = choose_next_user(users) 67 68 await update.message.reply_markdown(create_users_string(users)) 60 69 61 70 … … 64 73 context: ContextTypes.DEFAULT_TYPE 65 74 ) -> None: 75 """ 76 This commands sets the next chooser if needed and shows current 77 """ 78 66 79 context_init(context) 67 80 68 81 users = context.chat_data["users"] 69 82 70 if len(users) > 0: 71 await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0])) 72 else: 73 await update.message.reply_text(ADD_MORE_USERS) 83 if users == []: 84 raise error.TelegramError(ADD_MORE_USERS) 85 86 if has_finished_event(context, users[0]): 87 users = context.chat_data["users"] = choose_next_user(users) 88 89 await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0])) 74 90 75 91 … … 119 135 context.chat_data["users"] = users 120 136 137 if has_finished_event(context, users[0]): 138 await update.message.reply_text( 139 EVENT_USER_HAD_EVENT.format(user=users[0]) 140 ) 141 users = context.chat_data["users"] = choose_next_user(users) 142 121 143 await update.message.reply_text(USER_CHOOSE.format(user=users[0])) 122 144
Note:
See TracChangeset
for help on using the changeset viewer.