Skip to content

alicebot.adapter.cqhttp.message

CQHTTP 适配器消息。

class CQHTTPMessage

Bases: alicebot.message.Message

CQHTTP 消息。

method __init__(self, *messages) {#Message.__init__}

初始化。

  • Arguments

    • *messages (Union[List[~MessageSegmentT], ~MessageSegmentT, str, Mapping[str, Any]]) - 可以被转化为消息的数据。
  • Returns

    Type: None

method get_segment_class() {#CQHTTPMessage.get_segment_class}

获取消息字段类。

  • Returns

    Type: Type[CQHTTPMessageSegment]

    消息字段类。

class CQHTTPMessageSegment

Bases: alicebot.message.MessageSegment[CQHTTPMessage]

CQHTTP 消息字段。

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 anonymous(ignore = None)

匿名发消息

  • Returns

    Type: typing_extensions.Self

method at(qq)

@某人

  • Returns

    Type: typing_extensions.Self

method contact(type_, id_)

推荐好友/推荐群

  • Arguments

    • id_ (int)
  • Returns

    Type: typing_extensions.Self

method contact_friend(id_) {#CQHTTPMessageSegment.contact_friend}

推荐好友

  • Returns

    Type: typing_extensions.Self

method contact_group(id_) {#CQHTTPMessageSegment.contact_group}

推荐好友

  • Returns

    Type: typing_extensions.Self

method dice()

掷骰子魔法表情

  • Returns

    Type: typing_extensions.Self

method face(id_)

QQ 表情

  • Returns

    Type: typing_extensions.Self

method from_str(msg) {#CQHTTPMessageSegment.from_str}

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

  • Returns

    Type: typing_extensions.Self

    str 转换的消息字段。

method get_cqcode(self) {#CQHTTPMessageSegment.get_cqcode}

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

  • Returns

    Type: str

    此消息字段的 CQ 码形式。

method get_message_class() {#CQHTTPMessageSegment.get_message_class}

获取消息类。

  • Returns

    Type: Type[alicebot.adapter.cqhttp.message.CQHTTPMessage]

    消息类。

method image(file, type_ = None, cache = True, proxy = True, timeout = None)

图片

  • Arguments

    • type_ (Optional[Literal['flash']])

    • cache (bool)

    • proxy (bool)

    • timeout (Optional[int])

  • Returns

    Type: typing_extensions.Self

method json_message(data) {#CQHTTPMessageSegment.json_message}

JSON 消息

  • Returns

    Type: typing_extensions.Self

method location(lat, lon, title, content = None)

位置

  • Arguments

    • lon (float)

    • title (Optional[str])

    • content (Optional[str])

  • Returns

    Type: typing_extensions.Self

method music(type_, id_)

音乐分享

  • Arguments

    • id_ (int)
  • Returns

    Type: typing_extensions.Self

method music_custom(url, audio, title, content = None, image = None) {#CQHTTPMessageSegment.music_custom}

音乐自定义分享

  • Arguments

    • audio (str)

    • title (str)

    • content (Optional[str])

    • image (Optional[str])

  • Returns

    Type: typing_extensions.Self

method node(id_)

合并转发节点

  • Returns

    Type: typing_extensions.Self

method node_custom(user_id, nickname, content) {#CQHTTPMessageSegment.node_custom}

合并转发自定义节点

  • Arguments

    • nickname (str)

    • content (CQHTTPMessage)

  • Returns

    Type: typing_extensions.Self

method poke(type_, id_)

戳一戳

  • Arguments

    • id_ (int)
  • Returns

    Type: typing_extensions.Self

method record(file, magic = False, cache = True, proxy = True, timeout = None)

语音

  • Arguments

    • magic (bool)

    • cache (bool)

    • proxy (bool)

    • timeout (Optional[int])

  • Returns

    Type: typing_extensions.Self

method reply(id_)

回复

  • Returns

    Type: typing_extensions.Self

method rps()

猜拳魔法表情

  • Returns

    Type: typing_extensions.Self

method shake()

窗口抖动 (戳一戳)

  • Returns

    Type: typing_extensions.Self

method share(url, title, content = None, image = None)

链接分享

  • Arguments

    • title (str)

    • content (Optional[str])

    • image (Optional[str])

  • Returns

    Type: typing_extensions.Self

method text(text)

纯文本

  • Returns

    Type: typing_extensions.Self

method video(file, cache = True, proxy = True, timeout = None)

短视频

  • Arguments

    • cache (bool)

    • proxy (bool)

    • timeout (Optional[int])

  • Returns

    Type: typing_extensions.Self

method xml_message(data) {#CQHTTPMessageSegment.xml_message}

XML 消息

  • Returns

    Type: typing_extensions.Self

function escape(string, *, escape_comma = True)

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

  • Arguments

    • string (str) - 待转义的字符串。

    • escape_comma (bool) - 是否转义 ,

  • Returns

    Type: str

    转义后的字符串。

Released under the MIT License.