Skip to content

alicebot.adapter.cqhttp.event

CQHTTP 适配器事件。

class Sender

Bases: pydantic.main.BaseModel

发送人信息

  • Attributes

    • user_id (Optional[int])

    • nickname (Optional[str])

    • card (Optional[str])

    • sex (Optional[Literal['male', 'female', 'unknown']])

    • age (Optional[int])

    • area (Optional[str])

    • level (Optional[str])

    • role (Optional[str])

    • title (Optional[str])

class Anonymous

Bases: pydantic.main.BaseModel

匿名信息

  • Attributes

    • id (int)

    • name (str)

    • flag (str)

class File

Bases: pydantic.main.BaseModel

文件信息

  • Attributes

    • id (str)

    • name (str)

    • size (int)

    • busid (int)

class Status

Bases: pydantic.main.BaseModel

状态信息

  • Attributes

    • online (bool)

    • good (bool)

class CQHTTPEvent

Bases: alicebot.event.Event[CQHTTPAdapter]

CQHTTP 事件基类

  • Attributes

    • type (Optional[str])

    • time (int)

    • self_id (int)

    • post_type (str)

method get_event_type()

获取事件类型。

  • Returns

    Type: tuple[typing.Optional[str], typing.Optional[str], typing.Optional[str]]

    事件类型。

readonly property to_me

Type: bool

当前事件的 user_id 是否等于 self_id

class MessageEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent, alicebot.event.MessageEvent[CQHTTPAdapter]

消息事件

  • Attributes

    • post_type (Literal['message'])

    • message_type (Literal['private', 'group'])

    • sub_type (str)

    • message_id (int)

    • user_id (int)

    • message (alicebot.adapter.cqhttp.message.CQHTTPMessage)

    • raw_message (str)

    • font (int)

    • sender (Sender)

method get_plain_text(self)

获取消息的纯文本内容。

  • Returns

    Type: str

    消息的纯文本内容。

method get_sender_id(self)

获取消息的发送者的唯一标识符。

  • Returns

    Type: Optional[int]

    消息的发送者的唯一标识符。

async method reply(self, message)

回复消息。

  • Arguments

    • message (Union[list[alicebot.adapter.cqhttp.message.CQHTTPMessageSegment], alicebot.adapter.cqhttp.message.CQHTTPMessageSegment, str, collections.abc.Mapping[str, Any]]) - 回复消息的内容,同 call_api() 方法。
  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class PrivateMessageEvent

Bases: alicebot.adapter.cqhttp.event.MessageEvent

私聊消息

  • Attributes

    • message_type (Literal['private'])

    • sub_type (Literal['friend', 'group', 'other'])

async method reply(self, message)

回复消息。

  • Arguments

    • message (Union[list[alicebot.adapter.cqhttp.message.CQHTTPMessageSegment], alicebot.adapter.cqhttp.message.CQHTTPMessageSegment, str, collections.abc.Mapping[str, Any]]) - 回复消息的内容,同 call_api() 方法。
  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class GroupMessageEvent

Bases: alicebot.adapter.cqhttp.event.MessageEvent

群消息

  • Attributes

    • message_type (Literal['group'])

    • sub_type (Literal['normal', 'anonymous', 'notice'])

    • group_id (int)

    • anonymous (Optional[alicebot.adapter.cqhttp.event.Anonymous])

async method reply(self, message)

回复消息。

  • Arguments

    • message (Union[list[alicebot.adapter.cqhttp.message.CQHTTPMessageSegment], alicebot.adapter.cqhttp.message.CQHTTPMessageSegment, str, collections.abc.Mapping[str, Any]]) - 回复消息的内容,同 call_api() 方法。
  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class NoticeEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

通知事件

  • Attributes

    • post_type (Literal['notice'])

    • notice_type (str)

class GroupUploadNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群文件上传

  • Attributes

    • notice_type (Literal['group_upload'])

    • user_id (int)

    • group_id (int)

    • file (File)

class GroupAdminNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群管理员变动

  • Attributes

    • notice_type (Literal['group_admin'])

    • sub_type (Literal['set', 'unset'])

    • user_id (int)

    • group_id (int)

class GroupDecreaseNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群成员减少

  • Attributes

    • notice_type (Literal['group_decrease'])

    • sub_type (Literal['leave', 'kick', 'kick_me'])

    • group_id (int)

    • operator_id (int)

    • user_id (int)

class GroupIncreaseNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群成员增加

  • Attributes

    • notice_type (Literal['group_increase'])

    • sub_type (Literal['approve', 'invite'])

    • group_id (int)

    • operator_id (int)

    • user_id (int)

class GroupBanNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群禁言

  • Attributes

    • notice_type (Literal['group_ban'])

    • sub_type (Literal['ban', 'lift_ban'])

    • group_id (int)

    • operator_id (int)

    • user_id (int)

    • duration (int)

class FriendAddNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

好友添加

  • Attributes

    • notice_type (Literal['friend_add'])

    • user_id (int)

class GroupRecallNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群消息撤回

  • Attributes

    • notice_type (Literal['group_recall'])

    • group_id (int)

    • operator_id (int)

    • user_id (int)

    • message_id (int)

class FriendRecallNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

好友消息撤回

  • Attributes

    • notice_type (Literal['friend_recall'])

    • user_id (int)

    • message_id (int)

class NotifyEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

提醒事件

  • Attributes

    • notice_type (Literal['notify'])

    • sub_type (str)

    • user_id (int)

class PokeNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

戳一戳

  • Attributes

    • sub_type (Literal['poke'])

    • target_id (int)

    • group_id (Optional[int])

class GroupLuckyKingNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

群红包运气王

  • Attributes

    • sub_type (Literal['lucky_king'])

    • group_id (int)

    • target_id (int)

class GroupHonorNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

群成员荣誉变更

  • Attributes

    • sub_type (Literal['honor'])

    • group_id (int)

    • honor_type (Literal['talkative', 'performer', 'emotion'])

class RequestEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

请求事件

  • Attributes

    • post_type (Literal['request'])

    • request_type (str)

async method approve(self)

同意请求。

  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

async method refuse(self)

拒绝请求。

  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class FriendRequestEvent

Bases: alicebot.adapter.cqhttp.event.RequestEvent

加好友请求

  • Attributes

    • request_type (Literal['friend'])

    • user_id (int)

    • comment (str)

    • flag (str)

async method approve(self, remark = '')

同意请求。

  • Arguments

    • remark (str) - 好友备注。
  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

async method refuse(self)

拒绝请求。

  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class GroupRequestEvent

Bases: alicebot.adapter.cqhttp.event.RequestEvent

加群请求 / 邀请

  • Attributes

    • request_type (Literal['group'])

    • sub_type (Literal['add', 'invite'])

    • group_id (int)

    • user_id (int)

    • comment (str)

    • flag (str)

async method approve(self)

同意请求。

  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

async method refuse(self, reason = '')

拒绝请求。

  • Arguments

    • reason (str) - 拒绝原因。
  • Returns

    Type: dict[str, typing.Any]

    API 请求响应。

class MetaEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

元事件

  • Attributes

    • post_type (Literal['meta_event'])

    • meta_event_type (str)

class LifecycleMetaEvent

Bases: alicebot.adapter.cqhttp.event.MetaEvent

生命周期

  • Attributes

    • meta_event_type (Literal['lifecycle'])

    • sub_type (Literal['enable', 'disable', 'connect'])

class HeartbeatMetaEvent

Bases: alicebot.adapter.cqhttp.event.MetaEvent

心跳

  • Attributes

    • meta_event_type (Literal['heartbeat'])

    • status (Status)

    • interval (int)

Released under the MIT License.