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])

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 Anonymous

Bases: pydantic.main.BaseModel

匿名信息

  • Attributes

    • id (int)

    • name (str)

    • flag (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 File

Bases: pydantic.main.BaseModel

文件信息

  • Attributes

    • id (str)

    • name (str)

    • size (int)

    • busid (int)

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 Status

Bases: pydantic.main.BaseModel

状态信息

  • Attributes

    • online (bool)

    • good (bool)

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 CQHTTPEvent

Bases: alicebot.event.Event[CQHTTPAdapter]

CQHTTP 事件基类

  • Attributes

    • type (Optional[str])

    • time (int)

    • self_id (int)

    • post_type (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

method get_event_type() {#CQHTTPEvent.get_event_type}

获取事件类型。

  • Returns

    Type: Tuple[Optional[str], Optional[str], Optional[str]]

    事件类型。

readonly property to_me {#CQHTTPEvent.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 __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) {#MessageEvent.get_plain_text}

获取消息的纯文本内容。

  • Returns

    Type: str

    消息的纯文本内容。

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

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

  • Arguments

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

    Type: bool

    是否是同一个发送者。

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: Dict[str, Any]

    API 请求响应。

class PrivateMessageEvent

Bases: alicebot.adapter.cqhttp.event.MessageEvent

私聊消息

  • Attributes

    • message_type (Literal['private'])

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

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

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: Dict[str, 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])

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

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: Dict[str, Any]

    API 请求响应。

class NoticeEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

通知事件

  • Attributes

    • post_type (Literal['notice'])

    • notice_type (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 GroupUploadNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群文件上传

  • Attributes

    • notice_type (Literal['group_upload'])

    • user_id (int)

    • group_id (int)

    • file (File)

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 GroupAdminNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

群管理员变动

  • Attributes

    • notice_type (Literal['group_admin'])

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

    • user_id (int)

    • group_id (int)

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 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)

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 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)

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 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)

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 FriendAddNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

好友添加

  • Attributes

    • notice_type (Literal['friend_add'])

    • user_id (int)

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 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)

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 FriendRecallNoticeEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

好友消息撤回

  • Attributes

    • notice_type (Literal['friend_recall'])

    • user_id (int)

    • message_id (int)

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 NotifyEvent

Bases: alicebot.adapter.cqhttp.event.NoticeEvent

提醒事件

  • Attributes

    • notice_type (Literal['notify'])

    • sub_type (str)

    • group_id (Optional[int])

    • user_id (int)

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 PokeNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

戳一戳

  • Attributes

    • sub_type (Literal['poke'])

    • target_id (int)

    • group_id (Optional[int])

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 GroupLuckyKingNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

群红包运气王

  • Attributes

    • sub_type (Literal['lucky_king'])

    • group_id (int)

    • target_id (int)

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 GroupHonorNotifyEvent

Bases: alicebot.adapter.cqhttp.event.NotifyEvent

群成员荣誉变更

  • Attributes

    • sub_type (Literal['honor'])

    • group_id (int)

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

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 RequestEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

请求事件

  • Attributes

    • post_type (Literal['request'])

    • request_type (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

async method approve(self)

同意请求。

  • Returns

    Type: Dict[str, Any]

    API 请求响应。

async method refuse(self)

拒绝请求。

  • Returns

    Type: Dict[str, Any]

    API 请求响应。

class FriendRequestEvent

Bases: alicebot.adapter.cqhttp.event.RequestEvent

加好友请求

  • Attributes

    • request_type (Literal['friend'])

    • user_id (int)

    • comment (str)

    • flag (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

async method approve(self, remark = '')

同意请求。

  • Arguments

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

    Type: Dict[str, Any]

    API 请求响应。

async method refuse(self)

拒绝请求。

  • Returns

    Type: Dict[str, 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)

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

async method approve(self)

同意请求。

  • Returns

    Type: Dict[str, Any]

    API 请求响应。

async method refuse(self, reason = '')

拒绝请求。

  • Arguments

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

    Type: Dict[str, Any]

    API 请求响应。

class MetaEvent

Bases: alicebot.adapter.cqhttp.event.CQHTTPEvent

元事件

  • Attributes

    • post_type (Literal['meta_event'])

    • meta_event_type (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 LifecycleMetaEvent

Bases: alicebot.adapter.cqhttp.event.MetaEvent

生命周期

  • Attributes

    • meta_event_type (Literal['lifecycle'])

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

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 HeartbeatMetaEvent

Bases: alicebot.adapter.cqhttp.event.MetaEvent

心跳

  • Attributes

    • meta_event_type (Literal['heartbeat'])

    • status (Status)

    • interval (int)

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

Released under the MIT License.