Zhamao Framework 3.2.4
A high-performance chatbot + web framework
载入中...
搜索中...
未找到
MessageUtil类 参考

静态 Public 成员函数

static arrayToStr (array $message_segment, bool $encode_text=false)
 
static strToArray (string $msg, bool $assoc_result=false, bool $ignore_space=true, bool $trim_text=false)
 
static convertToArr (MessageSegment|\Stringable|array|string $message)
 
static splitMessage (string $msg, array $includes=[' ', "\t"])
 
static getAltMessage (null|array|string|MessageSegment $message)
 

详细描述

机器人消息处理工具类

成员函数说明

◆ arrayToStr()

static arrayToStr ( array  $message_segment,
bool  $encode_text = false 
)
static

将消息段无损转换为 CatCode 字符串

参数
array$message_segment消息段
bool$encode_text是否对文本进行 CatCode 转义
函数调用图:

◆ convertToArr()

static convertToArr ( MessageSegment|\Stringable|array|string  $message)
static
函数调用图:

◆ getAltMessage()

static getAltMessage ( null|array|string|MessageSegment  $message)
static

◆ splitMessage()

static splitMessage ( string  $msg,
array  $includes = [' ', "\t"] 
)
static

分割消息字符串

参数
array$includes需要进行切割的字符串,默认包含空格及制表符(\t)

◆ strToArray()

static strToArray ( string  $msg,
bool  $assoc_result = false,
bool  $ignore_space = true,
bool  $trim_text = false 
)
static

将含有 CatCode 字符串的消息文本无损转换为消息段数组

参数
string$msg字符串消息(包含 CatCode 的)
bool$assoc_result是否返回关联数组形式。当值为 True 时,返回的是数组形式,否则返回 MessageSegment[] 对象列表形式(默认为 False)
bool$ignore_space是否忽略空行(默认为 True)
bool$trim_text是否去除空格文本(默认为 False)
返回
array|MessageSegment[]
函数调用图:

该类的文档由以下文件生成: