增加了message参数对于md/html部分富文本语法的支持和改进了HEX着色

This commit is contained in:
Nanaloveyuki
2025-07-28 21:21:21 +08:00
parent d5f157bdf3
commit 9b5d7cdfad
3 changed files with 123 additions and 31 deletions

View File

@@ -57,13 +57,15 @@ def set_bg_color(text: str|None, color: str|None) -> str:
ansi = ansi.replace("38;", "48;")
return f"{ansi}{text}\033[0m"
def set_style(text: str|None, bold: bool = False, underline: bool = False, reverse: bool = False) -> str:
def set_style(text: str|None, bold: bool = False, italic: bool = False, underline: bool = False, strikethrough: bool = False, reverse: bool = False) -> str:
"""
设置文本样式
Set text style
:param text: 文本内容 Text content
:param bold: 是否加粗 Is bold
:param italic: 是否斜体 Is italic
:param underline: 是否下划线 Is underline
:param strikethrough: 是否划线 Is strikethrough
:param reverse: 是否反相 Is reverse
:return: 格式化后的文本 Formatted text
"""
@@ -72,8 +74,12 @@ def set_style(text: str|None, bold: bool = False, underline: bool = False, rever
ansi = ""
if bold:
ansi += "\033[1m"
if italic:
ansi += "\033[3m"
if underline:
ansi += "\033[4m"
if strikethrough:
ansi += "\033[9m"
if reverse:
ansi += "\033[7m"
return f"{ansi}{text}\033[0m"