iamai.adapter.kook package#
Subpackages#
- iamai.adapter.kook.api package
- Submodules
- iamai.adapter.kook.api.client module
- iamai.adapter.kook.api.handle module
- iamai.adapter.kook.api.model module
Attachments
BaseMessage
BlackList
BlackListsReturn
Channel
ChannelMessage
ChannelMessagesReturn
ChannelRoleInfo
ChannelRoleReturn
ChannelsReturn
DirectMessage
DirectMessagesReturn
Emoji
GuilRoleReturn
Guild
GuildEmoji
GuildEmojisReturn
GuildUsersRetrun
GuildsReturn
IntimacyImg
IntimacyIndexReturn
Invite
InvitesReturn
ListReturn
MentionInfo
MessageCreateReturn
Meta
PermissionOverwrite
PermissionUser
Quote
Reaction
ReactionUser
Role
RolesReturn
TargetInfo
URL
User
UserChat
UserChatsReturn
- Module contents
- Submodules
Submodules#
- iamai.adapter.kook.config module
Config
Config.adapter_type
Config.reconnect_interval
Config.api_timeout
Config.access_token
Config.compress
Config.show_raw
Config.access_token
Config.adapter_type
Config.api_timeout
Config.compress
Config.model_computed_fields
Config.model_config
Config.model_fields
Config.reconnect_interval
Config.report_self_message
Config.show_raw
- iamai.adapter.kook.event module
Attachment
Attachments
AttrDict
BaseMessage
BaseMessage.attachments
BaseMessage.content
BaseMessage.create_at
BaseMessage.embeds
BaseMessage.id_
BaseMessage.image_name
BaseMessage.mention_info
BaseMessage.model_computed_fields
BaseMessage.model_config
BaseMessage.model_fields
BaseMessage.quote
BaseMessage.reactions
BaseMessage.read_status
BaseMessage.type
BaseMessage.updated_at
BlackList
BlackListsReturn
CartBtnClickNoticeEvent
ChannelAddReactionEvent
ChannelAddedEvent
ChannelDeleteEvent
ChannelDeleteMessageEvent
ChannelDeletedReactionEvent
ChannelMessage
ChannelMessageEvent
ChannelMessagesReturn
ChannelNoticeEvent
ChannelPinnedMessageEvent
ChannelRoleInfo
ChannelRoleReturn
ChannelUnpinnedMessageEvent
ChannelUpdatedEvent
ChannelUpdatedMessageEvent
ChannelsReturn
DirectMessage
DirectMessagesReturn
EventMessage
EventMessage.attachments
EventMessage.author
EventMessage.channel_name
EventMessage.code
EventMessage.content
EventMessage.guild_id
EventMessage.kmarkdown
EventMessage.mention
EventMessage.mention_all
EventMessage.mention_here
EventMessage.mention_roles
EventMessage.model_computed_fields
EventMessage.model_config
EventMessage.model_fields
EventMessage.nav_channels
EventMessage.type
EventTypes
Extra
GuilRoleReturn
GuildAddBlockListNoticeEvent
GuildDeleteBlockListNoticeEvent
GuildDeleteNoticeEvent
GuildEmoji
GuildEmojisReturn
GuildMemberDecreaseNoticeEvent
GuildMemberIncreaseNoticeEvent
GuildMemberNoticeEvent
GuildMemberOfflineNoticeEvent
GuildMemberOnlineNoticeEvent
GuildMemberUpdateNoticeEvent
GuildNoticeEvent
GuildRoleAddNoticeEvent
GuildRoleDeleteNoticeEvent
GuildRoleNoticeEvent
GuildRoleUpdateNoticeEvent
GuildUpdateNoticeEvent
GuildUsersRetrun
GuildsReturn
HeartbeatMetaEvent
IntimacyImg
IntimacyIndexReturn
Invite
InvitesReturn
Kmarkdown
KookEvent
KookEvent.author_id
KookEvent.channel_type
KookEvent.content
KookEvent.extra
KookEvent.model_computed_fields
KookEvent.model_config
KookEvent.model_fields
KookEvent.msg_id
KookEvent.msg_timestamp
KookEvent.nonce
KookEvent.post_type
KookEvent.self_id
KookEvent.target_id
KookEvent.type_
KookEvent.user_id
LifecycleMetaEvent
ListReturn
MentionInfo
MessageCreateReturn
MessageEvent
Meta
MetaEvent
NoticeEvent
OriginEvent
PermissionOverwrite
PermissionUser
PrivateAddReactionEvent
PrivateDeleteMessageEvent
PrivateDeleteReactionEvent
PrivateMessageEvent
PrivateNoticeEvent
PrivateUpdateMessageEvent
Quote
Reaction
ReactionUser
ResultStore
RolesReturn
SelfExitGuildNoticeEvent
SelfJoinGuildNoticeEvent
SignalTypes
TargetInfo
URL
UserChat
UserChatsReturn
UserInfoUpdateNoticeEvent
UserJoinAudioChannelEvent
UserJoinAudioChannelNoticeEvent
UserNoticeEvent
get_event_class()
- iamai.adapter.kook.exceptions module
- iamai.adapter.kook.message module
KookMessage
KookMessageSegment
KookMessageSegment.Card()
KookMessageSegment.KMarkdown()
KookMessageSegment.at()
KookMessageSegment.audio()
KookMessageSegment.file()
KookMessageSegment.image()
KookMessageSegment.model_computed_fields
KookMessageSegment.model_config
KookMessageSegment.model_fields
KookMessageSegment.quote()
KookMessageSegment.text()
KookMessageSegment.video()
escape_kmarkdown()
unescape_kmarkdown()
Module contents#
Kook 协议适配器。
本适配器适配了 Kook 协议。 协议详情请参考: [Kook 开发者平台](https://developer.kookapp.cn/) 。
- class iamai.adapter.kook.KookAdapter(bot: Bot)[source]#
Bases:
WebSocketAdapter
[KookEvent
,Config
]Kook 协议适配器。
- class Config(*, adapter_type: Literal['ws', 'wb'] = 'ws', reconnect_interval: int = 3, api_timeout: int = 1000, access_token: str = '', compress: Literal[0, 1] = 0, show_raw: bool = False, report_self_message: bool = False, **extra_data: Any)#
Bases:
ConfigModel
Kook 配置类,将在适配器被加载时被混入到机器人主配置中。
- adapter_type#
适配器类型,需要和协议端配置相同。
- Type:
Literal[‘ws’, ‘wb’]
- reconnect_interval#
重连等待时间。
- Type:
int
- api_timeout#
进行 API 调用时等待返回响应的超时时间。
- Type:
int
- access_token#
鉴权。
- Type:
str
- compress#
是否启用压缩,默认为 0,不启用。
- Type:
Literal[0, 1]
- show_raw#
是否显示原始数据,默认为 False,不显示。
- Type:
bool
- access_token: str#
- adapter_type: Literal['ws', 'wb']#
- api_timeout: int#
- compress: Literal[0, 1]#
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {'access_token': FieldInfo(annotation=str, required=False, default=''), 'adapter_type': FieldInfo(annotation=Literal['ws', 'wb'], required=False, default='ws'), 'api_timeout': FieldInfo(annotation=int, required=False, default=1000), 'compress': FieldInfo(annotation=Literal[0, 1], required=False, default=0), 'reconnect_interval': FieldInfo(annotation=int, required=False, default=3), 'report_self_message': FieldInfo(annotation=bool, required=False, default=False), 'show_raw': FieldInfo(annotation=bool, required=False, default=False)}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- reconnect_interval: int#
- report_self_message: bool#
- show_raw: bool#
- api_root = 'https://www.kookapp.cn/api/v3/'#
- name: str = 'kook'#
- async send(message_: T_KookMSG, message_type: Literal['GROUP', 'PERSON'], id_: int) Dict[str, Any] [source]#
发送消息,调用 message/create 或 direct-message/create API 发送消息。
- Parameters:
message – 消息内容,可以是 str, Mapping, Iterable[Mapping], ‘KookMessageSegment’, ‘KookMessage’。 将使用 KookMessage 进行封装。
message_type – 消息类型。应该是 GROUP 或者 PERSON。
id – 发送对象的 ID ,Kook 用户码或者Kook频道码。
- Returns:
API 响应。
- Raises:
TypeError – message_type 不是 ‘PERSON’ 或 ‘GROUP’。
... – 同 call_api() 方法。