Changeset 9be02d9 in python-cinema-club-bot for utils.py


Ignore:
Timestamp:
Oct 10, 2024, 4:12:00 AM (5 weeks ago)
Author:
Mikhail Kirillov <w96k@…>
Branches:
master
Children:
8d2d5ac
Parents:
6623428
Message:

Fix #9. Add events commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • utils.py

    r6623428 r9be02d9  
    1111
    1212from telegram.ext import ContextTypes
    13 
     13from collections import deque
    1414
    1515def context_init(context: ContextTypes.DEFAULT_TYPE):
     
    2424        context.chat_data["movies"]: list[dict] = []
    2525
     26    if "events" not in context.chat_data:
     27        context.chat_data["events"]: list[dict] = []
     28
    2629    return context
    2730
     
    3336def create_users_string(users: list[str]) -> str:
    3437    return "`" + ", ".join(users) + "`"
     38
     39
     40def choose_next_user(users: list[dict]) -> list[dict]:
     41    users = deque(users)
     42    users.rotate(-1)  # -1 moves list to left by 1 element
     43
     44    return list(users)
Note: See TracChangeset for help on using the changeset viewer.