код:
import random
from aiogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from aiogram.filters.callback_data import CallbackData
from data.config import support_ids
from loader import dp
# Правильний синтаксис CallbackData для Aiogram 3.x
support_callback = CallbackData("ask_support", "messages", "user_id", "as_user", prefix="your_prefix")
cancel_support_callback = CallbackData("cancel_support", "user_id", prefix="your_prefix")
async def check_support_available(support_id):
state = dp.current_state(chat=support_id, user=support_id)
state_str = str(await state.get_state())
if state_str == "in_support":
return None
else:
return support_id
async def get_support_manager():
random.shuffle(support_ids)
for support_id in support_ids:
support_id = await check_support_available(support_id)
if support_id:
return support_id
return None
async def support_keyboard(messages, user_id=None):
if user_id:
contact_id = int(user_id)
as_user = "no"
text = "ttt"
else:
contact_id = await get_support_manager()
as_user = "yes"
if messages == "many" and contact_id is None:
return False
elif messages == "one" and contact_id is None:
contact_id = random.choice(support_ids)
if messages == "one":
text = "ttt"
else:
text = "ttt"
keyboard = InlineKeyboardMarkup()
keyboard.add(
InlineKeyboardButton(
text=text,
callback_data=support_callback.new(
messages=messages,
user_id=contact_id,
as_user=as_user
)
)
)
if messages == "many":
keyboard.add(
InlineKeyboardButton(
text="ttt",
callback_data=cancel_support_callback.new(user_id=contact_id)
)
)
return keyboard
def cancel_support(user_id):
return InlineKeyboardMarkup(
inline_keyboard=[[InlineKeyboardButton(
text="ttt",
callback_data=cancel_support_callback.new(user_id=user_id)
)]]
)
Ошибка:
Traceback (most recent call last):
File "G:\BotSupport23.#1.01\app.py", line 6, in <module>
from handlers import dp
File "G:\BotSupport23.#1.01\handlers\__init__.py", line 2, in <module>
from .users import dp
File "G:\BotSupport23.#1.01\handlers\users\__init__.py", line 1, in <module>
from .support import dp
File "G:\BotSupport23.#1.01\handlers\users\support.py", line 5, in <module>
from keyboards.inline.support import support_keyboard, support_callback
File "G:\BotSupport23.#1.01\keyboards\inline\support.py", line 10, in <module>
support_callback = CallbackData("ask_support", "messages", "user_id", "as_user", prefix="your_prefix")
TypeError: BaseModel.__init__() takes 1 positional argument but 5 were given