Changeset 0d48ea2 in python-cinema-club-bot for commands/users.py
- Timestamp:
- Oct 9, 2024, 3:40:27 AM (5 weeks ago)
- Branches:
- master
- Children:
- 6623428
- Parents:
- cc34991
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands/users.py
rcc34991 r0d48ea2 14 14 from collections import deque 15 15 16 from strings import USER_NOT_PROVIDED, USER_ADDED, USER_REMOVED, EXPECTED_ONE_USER 16 from strings import USER_NOT_PROVIDED, USERS_ADDED, USERS_REMOVED, \ 17 EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE 17 18 from utils import context_init 18 19 19 from rich import inspect20 20 21 async def set_users( 22 update: Update, 23 context: ContextTypes.DEFAULT_TYPE 24 ) -> None: 25 context_init(context) 26 27 if context.args == []: 28 raise error.TelegramError(USER_NOT_PROVIDED) 29 30 context.chat_data["users"] = context.args 31 32 await update.message.reply_text(USER_SET) 21 33 22 34 async def add_users( … … 27 39 28 40 if context.args == []: 29 await update.message.reply_text(USER_NOT_PROVIDED)30 41 raise error.TelegramError(USER_NOT_PROVIDED) 31 42 32 43 for user in context.args: 33 44 context.chat_data["users"].append(user) 34 await update.message.reply_text(USER_ADD ED.format(user=user))45 await update.message.reply_text(USER_ADD.format(user=user)) 35 46 36 await update.message.reply_text( context.chat_data["users"])47 await update.message.reply_text(USERS_ADDED) 37 48 38 49 … … 53 64 54 65 if context.args == []: 55 await update.message.reply_text(USER_NOT_PROVIDED)56 66 raise error.TelegramError(USER_NOT_PROVIDED) 57 67 … … 62 72 63 73 context.chat_data["users"].remove(user) 64 await update.message.reply_text(USER_REMOVE D.format(user=user))74 await update.message.reply_text(USER_REMOVE.format(user=user)) 65 75 66 await update.message.reply_text( context.chat_data["users"])76 await update.message.reply_text(USERS_REMOVED) 67 77 68 78 … … 74 84 75 85 if context.args == []: 76 await update.message.reply_text(USER_NOT_PROVIDED)77 86 raise error.TelegramError(USER_NOT_PROVIDED) 78 87 79 88 if len(context.args) > 1: 80 await update.message.reply_text(EXPECTED_ONE_USER)81 89 raise error.TelegramError(EXPECTED_ONE_USER) 82 90 … … 89 97 context.chat_data["users"] = list(users) 90 98 91 await update.message.reply_text(context.chat_data )99 await update.message.reply_text(context.chat_data["users"])
Note:
See TracChangeset
for help on using the changeset viewer.