From 9be02d9141c14a3e3ca28567dbaff671de83200f Mon Sep 17 00:00:00 2001 From: Mikhail Kirillov Date: Thu, 10 Oct 2024 04:12:00 +0400 Subject: Fix #9. Add events commands --- utils.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index 93ad3ed..2acdb01 100644 --- a/utils.py +++ b/utils.py @@ -10,7 +10,7 @@ # from telegram.ext import ContextTypes - +from collections import deque def context_init(context: ContextTypes.DEFAULT_TYPE): """ @@ -23,6 +23,9 @@ def context_init(context: ContextTypes.DEFAULT_TYPE): if "movies" not in context.chat_data: context.chat_data["movies"]: list[dict] = [] + if "events" not in context.chat_data: + context.chat_data["events"]: list[dict] = [] + return context @@ -32,3 +35,10 @@ def normalize_username(username: str): def create_users_string(users: list[str]) -> str: return "`" + ", ".join(users) + "`" + + +def choose_next_user(users: list[dict]) -> list[dict]: + users = deque(users) + users.rotate(-1) # -1 moves list to left by 1 element + + return list(users) -- cgit v1.2.3