Пирограмма - inline_query.id -> AttributeError: объект int не имеет атрибута write
AttributeError: объект 'int' не имеет атрибута 'write'. Эта ошибка, с которой я не знаком, на самом деле я совершенно не знаю, почему эта ошибка TwT (обучение пиротехнике) что-то не так с inline_query.id? или это неправильно?
Полный код
@bot.on_inline_query()
async def inline_handler(client, inline_query: InlineQuery):
await client.answer_inline_query(
inline_query.id,
results=[
(
InlineQueryResultArticle(
title="Menu",
reply_markup=InlineKeyboardMarkup(help_menu(0, CMD_LIST, 'help')),
input_message_content=content,
)
)
],
cache_time=0
)
#ERROR FULL TRACE BACK:
Traceback (most recent call last):
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\dispatcher.py", line 208, in handler_worker
await handler.callback(self.client, *args)
File "E:\Zeda-UserBot\system\plugins\inline.py", line 71, in inline_handler
await client.answer_inline_query(
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\methods\bots\answer_inline_query.py", line 97, in
answer_inline_query
return await self.send(
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\methods\advanced\send.py", line 77, in send
r = await self.session.send(
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\session\session.py", line 425, in send
return await self._send(data, timeout=timeout)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\session\session.py", line 354, in _send
message = self.msg_factory(data)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\session\internals\msg_factory.py", line 37, in __call__
len(body)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\core\tl_object.py", line 85, in __len__
return len(self.write())
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\functions\messages\set_inline_bot_results.py", line 97, in write
data.write(Vector(self.results))
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\core\primitives\vector.py", line 51, in __new__
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\core\primitives\vector.py", line 51, in <listcomp>
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\types\input_bot_inline_result.py", line 116, in write
data.write(self.send_message.write())
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\types\input_bot_inline_message_text.py", line
84, in write
data.write(Vector(self.entities))
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\core\primitives\vector.py", line 51, in __new__
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\core\primitives\vector.py", line 51, in <listcomp>
+ [cast(bytes, t(i)) if t else i.write() for i in value]
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-packages\pyrogram\raw\types\input_message_entity_mention_name.py", line 78, in write
data.write(self.user_id.write())
AttributeError: 'int' object has no attribute 'write'
1 ответ
@ColinShark, вот код меню помощи
def help_menu(pg_num, setv: list, prefix):
rows = 2
columns = 1
s = [x for x in os.listdir("system/plugins/") if x.endswith(".py") and not x.startswith("__")]
for p in s:
setv.append(p)
plugins = [
InlineKeyboardButton(
text="{} {} {}".format("⨵", x, "⨵"),
callback_data="_lightning_plugins_{}".format(x, pg_num),
)
for x in setv
]
pairs = list(zip(plugins[::columns], plugins[1::columns]))
if len(plugins) % columns == 1:
pairs.append((plugins[-1],))
max_num_pages = ceil(len(pairs) / rows)
page = pg_num % max_num_pages
if len(pairs) > rows:
pairs = pairs[
page * rows : rows * (page + 1)
] + [
(
InlineKeyboardButton(
text="Previous",
callback_data="{}_prev({})".format(prefix, pg_num),),
InlineKeyboardButton(
text="Next",
callback_data="{}_next({})".format(prefix, setv),
),
)
]
return pairs```
Содержание:
content = InputTextMessageContent("**Black Lightning ASSISTANT Help Menu for User** [{}]({})".format(USER[1:], fucking_sucking.id))