Skip to content

Ошибка в реализации модели BotXAPIAllMention #549

Description

@niceguy135

Используется pybotx версии 0.76.5

Была попытка воспользоваться механизмом упоминания всех участников в чате. Но при отправке сообщения возникает ошибка:

failed with code 400 and payload:
b'{"reason":"malformed_request","status":"error","errors":[],"error_data":{"notification":{"mentions":{"mention_data":"missing"}}}}'

В ходе исследования выяснилось, что модель BotXAPIAllMention не содержит обязательного поля mention_data, которое всегда должно быть None для данной модели.


Пример monkey патча модели, который мне помог:

class PatchedBotXAPIAllMention(UnverifiedPayloadBaseModel):
    mention_type: Literal[BotAPIMentionTypes.ALL]
    mention_id: UUID
    mention_data: None = None

    def to_botx_embed_mention_format(self) -> str:
        return f"@{{mention:{self.mention_id}}}"

import pybotx.models.message.mentions
pybotx.models.message.mentions.BotXAPIAllMention = PatchedBotXAPIAllMention

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions