diff options
Diffstat (limited to 'commands/users.py')
-rw-r--r-- | commands/users.py | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/commands/users.py b/commands/users.py index affdb53..413b681 100644 --- a/commands/users.py +++ b/commands/users.py @@ -13,11 +13,23 @@ from telegram import Update, error from telegram.ext import ContextTypes from collections import deque -from strings import USER_NOT_PROVIDED, USER_ADDED, USER_REMOVED, EXPECTED_ONE_USER +from strings import USER_NOT_PROVIDED, USERS_ADDED, USERS_REMOVED, \ + EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE from utils import context_init -from rich import inspect +async def set_users( + update: Update, + context: ContextTypes.DEFAULT_TYPE +) -> None: + context_init(context) + + if context.args == []: + raise error.TelegramError(USER_NOT_PROVIDED) + + context.chat_data["users"] = context.args + + await update.message.reply_text(USER_SET) async def add_users( update: Update, @@ -26,14 +38,13 @@ async def add_users( context_init(context) if context.args == []: - await update.message.reply_text(USER_NOT_PROVIDED) raise error.TelegramError(USER_NOT_PROVIDED) for user in context.args: context.chat_data["users"].append(user) - await update.message.reply_text(USER_ADDED.format(user=user)) + await update.message.reply_text(USER_ADD.format(user=user)) - await update.message.reply_text(context.chat_data["users"]) + await update.message.reply_text(USERS_ADDED) async def list_users( @@ -52,7 +63,6 @@ async def remove_users( context_init(context) if context.args == []: - await update.message.reply_text(USER_NOT_PROVIDED) raise error.TelegramError(USER_NOT_PROVIDED) for user in context.args: @@ -61,9 +71,9 @@ async def remove_users( break context.chat_data["users"].remove(user) - await update.message.reply_text(USER_REMOVED.format(user=user)) + await update.message.reply_text(USER_REMOVE.format(user=user)) - await update.message.reply_text(context.chat_data["users"]) + await update.message.reply_text(USERS_REMOVED) async def chooser_user( @@ -73,11 +83,9 @@ async def chooser_user( context_init(context) if context.args == []: - await update.message.reply_text(USER_NOT_PROVIDED) raise error.TelegramError(USER_NOT_PROVIDED) if len(context.args) > 1: - await update.message.reply_text(EXPECTED_ONE_USER) raise error.TelegramError(EXPECTED_ONE_USER) chooser = context.args[0] @@ -88,4 +96,4 @@ async def chooser_user( context.chat_data["users"] = list(users) - await update.message.reply_text(context.chat_data) + await update.message.reply_text(context.chat_data["users"]) |