nonebot.adapters.onebot.utils
OneBot 辅助函数。
def rich_escape(s, escape_comma=True)
说明: 对字符串进行富文本转义。
参数
s(str): 需要转义的字符串escape_comma(bool): 是否转义逗号(,)。
返回
- str
def rich_unescape(s)
说明: 对字符串进行富文本去转义。
参数
s(str): 需要去转义的字符串
返回
- str
def iter_rich_message(msg)
参数
msg(str)
返回
- Iterable[tuple[str, str]]
def highlight_rich_message(msg)
参数
msg(str)
返回
- Iterable[str]
def get_auth_bearer(access_token=None)
参数
access_token(str | None)
返回
- str | None
def b2s(b)
说明: 转换布尔值为字符串。
参数
b(bool | None)
返回
- str | None
def f2s(file)
参数
file(str | bytes | BytesIO | Path)
返回
- str
def truncate(s, length=70, kill_words=True, end="...")
说明: 将给定字符串截断到指定长度。
参数
s(str): 需要截取的字符串length(int): 截取长度kill_words(bool): 是否不保留完整单词end(str): 截取字符串的结尾字符
返回
- str: 截取后的字符串
