- Timestamp:
- Oct 11, 2024, 1:53:24 AM (5 weeks ago)
- Branches:
- master
- Children:
- ac7b16a
- Parents:
- 694d823
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
utils.py
r694d823 r69dd60c 12 12 from telegram.ext import ContextTypes 13 13 from collections import deque 14 from typing import Optional 14 15 15 16 def context_init(context: ContextTypes.DEFAULT_TYPE): … … 38 39 39 40 40 def choose_next_user( users: list[dict]) -> list[dict]:41 users = deque( users)41 def choose_next_user(context: ContextTypes.DEFAULT_TYPE) -> list[dict]: 42 users = deque(context.chat_data["users"]) 42 43 users.rotate(-1) # -1 moves list to left by 1 element 43 44 45 init_new_event(context, users[0]) 46 44 47 return list(users) 48 49 50 def init_new_event(context: ContextTypes.DEFAULT_TYPE, user: dict, movie: Optional[str] = None): 51 events = context.chat_data["events"] 52 53 last_event = events[-1] if events != [] else None 54 55 init_event = dict( 56 when=None, 57 where=None, 58 movie=movie, 59 user=user 60 ) 61 62 if last_event and last_event["movie"] is None: 63 events[-1] = init_event 64 else: 65 events.append(init_event)
Note:
See TracChangeset
for help on using the changeset viewer.