Skip to content
On this page

alicebot.adapter.dingtalk.event

DingTalk 适配器事件。

class UserInfo

Bases: pydantic.main.BaseModel

用户信息

  • Attributes

    • dingtalkId (str)

    • staffId (Optional[str])

method __init__(__pydantic_self__, **data) {#BaseModel.__init__}

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

  • Arguments

    • data (Any)
  • Returns

    Type: None

class Text

Bases: pydantic.main.BaseModel

文本消息

  • Attributes

    • content (str)

method __init__(__pydantic_self__, **data) {#BaseModel.__init__}

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

  • Arguments

    • data (Any)
  • Returns

    Type: None

class DingTalkEvent

Bases: alicebot.event.MessageEvent[DingTalkAdapter]

DingTalk 事件基类

  • Attributes

    • type (Optional[str])

    • msgtype (str)

    • msgId (str)

    • createAt (str)

    • conversationType (Literal['1', '2'])

    • conversationId (str)

    • conversationTitle (Optional[str])

    • senderId (str)

    • senderNick (str)

    • senderCorpId (Optional[str])

    • sessionWebhook (str)

    • sessionWebhookExpiredTime (int)

    • isAdmin (Optional[bool])

    • chatbotCorpId (Optional[str])

    • isInAtList (Optional[bool])

    • senderStaffId (Optional[str])

    • chatbotUserId (str)

    • atUsers (List[alicebot.adapter.dingtalk.event.UserInfo])

    • text (Text)

    • response_msg (Union[NoneType, str, Dict[str, Any], alicebot.adapter.dingtalk.message.DingTalkMessage])

    • response_at (Union[NoneType, Dict[str, Any], alicebot.adapter.dingtalk.message.DingTalkMessage])

method __init__(__pydantic_self__, **data) {#BaseModel.__init__}

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

__init__ uses __pydantic_self__ instead of the more common self for the first arg to allow self as a field name.

  • Arguments

    • data (Any)
  • Returns

    Type: None

method get_plain_text(self) {#DingTalkEvent.get_plain_text}

获取消息的纯文本内容。

  • Returns

    Type: str

    消息的纯文本内容。

async method is_same_sender(self, other) {#DingTalkEvent.is_same_sender}

判断自身和另一个事件是否是同一个发送者。

  • Arguments

    • other (typing_extensions.Self) - 另一个事件。
  • Returns

    Type: bool

    是否是同一个发送者。

readonly property message

Type: alicebot.adapter.dingtalk.message.DingTalkMessage

返回 message 字段。

async method reply(self, message, at = None)

回复消息。

  • Arguments

    • message (Union[str, Dict[str, Any], alicebot.adapter.dingtalk.message.DingTalkMessage]) - 回复消息的内容,可以是 str, DictDingTalkMessage

    • at (Union[NoneType, Dict[str, Any], alicebot.adapter.dingtalk.message.DingTalkMessage]) - 回复消息时 At 的对象,必须时 at 类型的 DingTalkMessage,或者符合标准的 Dict

  • Returns

    Type: Dict[str, Any]

    调用 Webhook 地址后钉钉服务器的响应。

  • Raises

    • WebhookExpiredError - 当前事件的 Webhook 地址已经过期。

    • ... - 同 DingTalkAdapter.send() 方法。

Released under the MIT License.