mirror of
https://github.com/Nanaloveyuki/py-logiliteal.git
synced 2025-10-19 16:46:23 +00:00
✨ 增加了message
参数对于md/html部分富文本语法的支持和改进了HEX着色
This commit is contained in:
@@ -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"
|
||||
|
Reference in New Issue
Block a user