summaryrefslogtreecommitdiff
path: root/commands/users.py
diff options
context:
space:
mode:
Diffstat (limited to 'commands/users.py')
-rw-r--r--commands/users.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/commands/users.py b/commands/users.py
index 413b681..497d7dd 100644
--- a/commands/users.py
+++ b/commands/users.py
@@ -14,8 +14,9 @@ from telegram.ext import ContextTypes
from collections import deque
from strings import USER_NOT_PROVIDED, USERS_ADDED, USERS_REMOVED, \
- EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE
-from utils import context_init
+ EXPECTED_ONE_USER, USER_SET, USER_ADD, USER_REMOVE, ADD_MORE_USERS, \
+ NEXT_MOVIE_USER, USER_NOT_FOUND, USER_CHOOSE
+from utils import context_init, create_users_string
async def set_users(
@@ -53,7 +54,23 @@ async def list_users(
) -> None:
context_init(context)
- await update.message.reply_text(context.chat_data["users"])
+ users = context.chat_data["users"]
+
+ await update.message.reply_markdown(create_users_string(users))
+
+
+async def who_is_next(
+ update: Update,
+ context: ContextTypes.DEFAULT_TYPE
+) -> None:
+ context_init(context)
+
+ users = context.chat_data["users"]
+
+ if len(users) > 0:
+ await update.message.reply_text(NEXT_MOVIE_USER.format(user=users[0]))
+ else:
+ await update.message.reply_text(ADD_MORE_USERS)
async def remove_users(
@@ -91,9 +108,16 @@ async def chooser_user(
chooser = context.args[0]
users = deque(context.chat_data["users"])
- chooser_index = users.index(chooser)
+ try:
+ chooser_index = users.index(chooser)
+ except ValueError:
+ raise error.TelegramError(USER_NOT_FOUND.format(user=chooser))
+
users.rotate(-chooser_index)
+ users = list(users)
+
+ context.chat_data["users"] = users
- context.chat_data["users"] = list(users)
+ await update.message.reply_text(USER_CHOOSE.format(user=users[0]))
- await update.message.reply_text(context.chat_data["users"])
+ await update.message.reply_markdown(create_users_string(users))