iamai.adapter.gensokyo.message module#

GSK 适配器消息。

class iamai.adapter.gensokyo.message.GSKMessage(*messages: List[MessageSegmentT] | MessageSegmentT | str | Mapping[str, Any])[source]#

Bases: Message[GSKMessageSegment]

GSK 消息。

classmethod get_segment_class() Type[GSKMessageSegment][source]#

获取消息字段类。

Returns:

消息字段类。

class iamai.adapter.gensokyo.message.GSKMessageSegment(*, type: str, data: Dict[str, Any] = None)[source]#

Bases: MessageSegment[GSKMessage]

GSK 消息字段。

classmethod anonymous(ignore: bool | None = None) Self[source]#

匿名发消息

classmethod at(qq: int | Literal['all']) Self[source]#

@某人

classmethod contact(type_: Literal['qq', 'group'], id_: int) Self[source]#

推荐好友/推荐群

classmethod contact_friend(id_: int) Self[source]#

推荐好友

classmethod contact_group(id_: int) Self[source]#

推荐好友

classmethod dice() Self[source]#

掷骰子魔法表情

classmethod face(id_: int) Self[source]#

QQ 表情

classmethod from_str(msg: str) Self[source]#

用于将 str 转换为消息字段。

Parameters:

msg – 要解析为消息字段的数据。

Returns:

str 转换的消息字段。

get_cqcode() str[source]#

获取此消息字段的 CQ 码形式。

Returns:

此消息字段的 CQ 码形式。

classmethod get_message_class() Type[GSKMessage][source]#

获取消息类。

Returns:

消息类。

classmethod image(file: str, type_: Literal['flash'] | None = None, cache: bool = True, proxy: bool = True, timeout: int | None = None) Self[source]#

图片

classmethod json_message(data: str) Self[source]#

JSON 消息

classmethod location(lat: float, lon: float, title: str | None, content: str | None = None) Self[source]#

位置

model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'data': FieldInfo(annotation=Dict[str, Any], required=False, default_factory=dict), 'type': FieldInfo(annotation=str, required=True)}#

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

classmethod music(type_: Literal['qq', '163', 'xm'], id_: int) Self[source]#

音乐分享

classmethod music_custom(url: str, audio: str, title: str, content: str | None = None, image: str | None = None) Self[source]#

音乐自定义分享

classmethod node(id_: int) Self[source]#

合并转发节点

classmethod node_custom(user_id: int, nickname: str, content: GSKMessage) Self[source]#

合并转发自定义节点

classmethod poke(type_: str, id_: int) Self[source]#

戳一戳

classmethod record(file: str, magic: bool = False, cache: bool = True, proxy: bool = True, timeout: int | None = None) Self[source]#

语音

classmethod reply(id_: int) Self[source]#

回复

classmethod rps() Self[source]#

猜拳魔法表情

classmethod shake() Self[source]#

窗口抖动 (戳一戳)

classmethod share(url: str, title: str, content: str | None = None, image: str | None = None) Self[source]#

链接分享

classmethod text(text: str) Self[source]#

纯文本

classmethod video(file: str, cache: bool = True, proxy: bool = True, timeout: int | None = None) Self[source]#

短视频

classmethod xml_message(data: str) Self[source]#

XML 消息

iamai.adapter.gensokyo.message.escape(string: str, *, escape_comma: bool = True) str[source]#

对 CQ 码中的特殊字符进行转义。

Parameters:
  • string – 待转义的字符串。

  • escape_comma – 是否转义 ,

Returns:

转义后的字符串。