跳转至

addressing

feishu.agent.addressing

addressed_group_messages

Python
addressed_group_messages(*, client: Any | None = None, bot_open_id: str | None = None, bot_union_id: str | None = None, wake_on_app_reply: bool = True) -> MessageFilter

Create a filter that wakes on direct chats, bot mentions, or replies to app messages.

源代码位于: feishu/agent/addressing.py
Python
def addressed_group_messages(
    *,
    client: Any | None = None,
    bot_open_id: str | None = None,
    bot_union_id: str | None = None,
    wake_on_app_reply: bool = True,
) -> MessageFilter:
    r"""Create a filter that wakes on direct chats, bot mentions, or replies to app messages."""

    async def allows(event: Any) -> bool:
        message = _message(event)
        if not _looks_like_group_message(message):
            return True
        if (bot_open_id or bot_union_id) and is_mentioned(dict(message), open_id=bot_open_id, union_id=bot_union_id):
            return True
        if wake_on_app_reply and client is not None and await _replies_to_app_message(client, message):
            return True
        return False

    return allows