fix
This commit is contained in:
@@ -31,10 +31,17 @@ class SessionForm(StatesGroup):
|
||||
waiting_for_phrase = State()
|
||||
|
||||
|
||||
def actor_operator_ids(actor: dict[str, Any]) -> set[int]:
|
||||
if "operator_user_ids" in actor:
|
||||
return {int(user_id) for user_id in actor["operator_user_ids"]}
|
||||
return {int(actor["operator_user_id"])}
|
||||
|
||||
|
||||
def build_actor_lookup(config: dict) -> dict[int, dict[str, Any]]:
|
||||
lookup: dict[int, dict[str, Any]] = {}
|
||||
for actor in config["actors"]:
|
||||
lookup[int(actor["operator_user_id"])] = actor
|
||||
for user_id in actor_operator_ids(actor):
|
||||
lookup[user_id] = actor
|
||||
return lookup
|
||||
|
||||
|
||||
@@ -45,7 +52,7 @@ def is_allowed(user_id: int, actor_lookup: dict[int, dict[str, Any]], admin_ids:
|
||||
def build_actor_keyboard(config: dict, user_id: int, admin_ids: set[int]) -> InlineKeyboardBuilder:
|
||||
keyboard = InlineKeyboardBuilder()
|
||||
for actor in config["actors"]:
|
||||
if user_id in admin_ids or int(actor["operator_user_id"]) == user_id:
|
||||
if user_id in admin_ids or user_id in actor_operator_ids(actor):
|
||||
keyboard.button(text=actor["button_text"], callback_data=f"actor:{actor['key']}")
|
||||
keyboard.adjust(2)
|
||||
return keyboard
|
||||
@@ -96,7 +103,7 @@ async def actor_handler(callback: CallbackQuery, settings, actor_lookup: dict, a
|
||||
await callback.answer("Персонаж не найден.", show_alert=True)
|
||||
return
|
||||
|
||||
if user_id not in settings.admin_ids and int(actor["operator_user_id"]) != user_id:
|
||||
if user_id not in settings.admin_ids and user_id not in actor_operator_ids(actor):
|
||||
await callback.answer("Можно менять только свой статус.", show_alert=True)
|
||||
return
|
||||
|
||||
@@ -127,7 +134,7 @@ async def status_handler(
|
||||
await callback.answer("Персонаж не найден.", show_alert=True)
|
||||
return
|
||||
|
||||
if user_id not in settings.admin_ids and int(actor["operator_user_id"]) != user_id:
|
||||
if user_id not in settings.admin_ids and user_id not in actor_operator_ids(actor):
|
||||
await callback.answer("Можно менять только свой статус.", show_alert=True)
|
||||
return
|
||||
|
||||
|
||||
Reference in New Issue
Block a user