Skip to content

alicebot.adapter.onebot.event

OneBot 适配器事件。

class BotSelf

Bases: pydantic.main.BaseModel

机器人自身标识

  • Attributes

    • platform (str)

    • user_id (str)

class ImplVersion

Bases: pydantic.main.BaseModel

实现版本

  • Attributes

    • impl (str)

    • version (str)

    • onebot_version (str)

class BotStatus

Bases: pydantic.main.BaseModel

机器人状态

  • Attributes

    • self (BotSelf)

    • online (bool)

class Status

Bases: pydantic.main.BaseModel

运行状态

  • Attributes

    • good (bool)

    • bots (list[alicebot.adapter.onebot.event.BotStatus])

class OneBotEvent

Bases: alicebot.event.Event[OneBotAdapter]

OneBot 事件基类

  • Attributes

    • id (str)

    • time (float)

    • type (Literal['meta', 'message', 'notice', 'request'])

    • detail_type (str)

    • sub_type (str)

method get_event_type()

获取事件类型。

  • Returns

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

    事件类型。

class BotEvent

Bases: alicebot.adapter.onebot.event.OneBotEvent

包含 self 字段的机器人事件

  • Attributes

    • self (BotSelf)

readonly property to_me

Type: bool

是否是发给自己的。

class MetaEvent

Bases: alicebot.adapter.onebot.event.OneBotEvent

元事件

  • Attributes

    • type (Literal['meta'])

class ConnectMetaEvent

Bases: alicebot.adapter.onebot.event.MetaEvent

连接事件

  • Attributes

    • detail_type (Literal['connect'])

    • version (ImplVersion)

class HeartbeatMetaEvent

Bases: alicebot.adapter.onebot.event.MetaEvent

心跳事件

  • Attributes

    • detail_type (Literal['heartbeat'])

    • interval (int)

class StatusUpdateMetaEvent

Bases: alicebot.adapter.onebot.event.MetaEvent

状态更新事件

  • Attributes

    • detail_type (Literal['status_update'])

    • status (Status)

class MessageEvent

Bases: alicebot.adapter.onebot.event.BotEvent, alicebot.event.MessageEvent[OneBotAdapter]

消息事件

  • Attributes

    • type (Literal['message'])

    • message_id (str)

    • message (alicebot.adapter.onebot.message.OneBotMessage)

    • alt_message (str)

    • user_id (str)

method get_plain_text(self)

获取消息的纯文本内容。

  • Returns

    Type: str

    消息的纯文本内容。

method get_sender_id(self)

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

  • Returns

    Type: str

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

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: dict[str, typing.Any]

    API 请求响应。

class PrivateMessageEvent

Bases: alicebot.adapter.onebot.event.MessageEvent

私聊消息事件

  • Attributes

    • detail_type (Literal['private'])

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: dict[str, typing.Any]

    API 请求响应。

class GroupMessageEvent

Bases: alicebot.adapter.onebot.event.MessageEvent

群消息事件

  • Attributes

    • detail_type (Literal['group'])

    • group_id (str)

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: dict[str, typing.Any]

    API 请求响应。

class ChannelMessageEvent

Bases: alicebot.adapter.onebot.event.MessageEvent

频道消息事件

  • Attributes

    • detail_type (Literal['channel'])

    • guild_id (str)

    • channel_id (str)

async method reply(self, message)

回复消息。

  • Arguments

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

    Type: dict[str, typing.Any]

    API 请求响应。

class NoticeEvent

Bases: alicebot.adapter.onebot.event.BotEvent

通知事件

  • Attributes

    • type (Literal['notice'])

class FriendIncreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

好友增加事件

  • Attributes

    • detail_type (Literal['friend_increase'])

    • user_id (str)

class FriendDecreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

好友减少事件

  • Attributes

    • detail_type (Literal['friend_decrease'])

    • user_id (str)

class PrivateMessageDeleteEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

私聊消息删除

  • Attributes

    • detail_type (Literal['private_message_delete'])

    • message_id (str)

    • user_id (str)

class GroupMemberIncreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

群成员增加事件

  • Attributes

    • detail_type (Literal['group_member_increase'])

    • group_id (str)

    • user_id (str)

    • operator_id (str)

class GroupMemberDecreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

群成员减少事件

  • Attributes

    • detail_type (Literal['group_member_decrease'])

    • group_id (str)

    • user_id (str)

    • operator_id (str)

class GroupMessageDeleteEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

群消息删除事件

  • Attributes

    • detail_type (Literal['group_message_delete'])

    • group_id (str)

    • message_id (str)

    • user_id (str)

    • operator_id (str)

class GuildMemberIncreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

群组成员增加事件

  • Attributes

    • detail_type (Literal['guild_member_increase'])

    • guild_id (str)

    • user_id (str)

    • operator_id (str)

class GuildMemberDecreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

群组成员减少事件

  • Attributes

    • detail_type (Literal['guild_member_decrease'])

    • guild_id (str)

    • user_id (str)

    • operator_id (str)

class ChannelMemberIncreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

频道成员增加事件

  • Attributes

    • detail_type (Literal['channel_member_increase'])

    • guild_id (str)

    • channel_id (str)

    • user_id (str)

    • operator_id (str)

class ChannelMemberDecreaseEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

频道成员减少事件

  • Attributes

    • detail_type (Literal['channel_member_decrease'])

    • guild_id (str)

    • channel_id (str)

    • user_id (str)

    • operator_id (str)

class ChannelMessageDeleteEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

频道消息删除事件

  • Attributes

    • detail_type (Literal['channel_message_delete'])

    • guild_id (str)

    • channel_id (str)

    • message_id (str)

    • user_id (str)

    • operator_id (str)

class ChannelCreateEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

频道新建事件

  • Attributes

    • detail_type (Literal['channel_create'])

    • guild_id (str)

    • channel_id (str)

    • operator_id (str)

class ChannelDeleteEvent

Bases: alicebot.adapter.onebot.event.NoticeEvent

频道删除事件

  • Attributes

    • detail_type (Literal['channel_delete'])

    • guild_id (str)

    • channel_id (str)

    • operator_id (str)

class RequestEvent

Bases: alicebot.adapter.onebot.event.BotEvent

请求事件

  • Attributes

    • type (Literal['request'])

Released under the MIT License.