mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🎨 为是否开启错误转图片添加开关 (#16)
This commit is contained in:
parent
3a81a6af17
commit
ee28df892f
@ -5,6 +5,7 @@ from PIL import Image, ImageDraw
|
|||||||
|
|
||||||
from gsuid_core.utils.fonts.fonts import core_font
|
from gsuid_core.utils.fonts.fonts import core_font
|
||||||
from gsuid_core.utils.image.convert import convert_img
|
from gsuid_core.utils.image.convert import convert_img
|
||||||
|
from gsuid_core.utils.plugins_config.gs_config import core_plugins_config
|
||||||
from gsuid_core.utils.image.image_tools import (
|
from gsuid_core.utils.image.image_tools import (
|
||||||
get_color_bg,
|
get_color_bg,
|
||||||
draw_center_text_by_line,
|
draw_center_text_by_line,
|
||||||
@ -27,6 +28,7 @@ UPDATE_HINT = '''更新失败!更多错误信息请查看控制台...
|
|||||||
>> [gs强行强制更新](超级危险)!'''
|
>> [gs强行强制更新](超级危险)!'''
|
||||||
|
|
||||||
TEXT_PATH = Path(__file__).parent / 'image' / 'texture2d'
|
TEXT_PATH = Path(__file__).parent / 'image' / 'texture2d'
|
||||||
|
is_pic_error = core_plugins_config.get_config('ChangeErrorToPic').data
|
||||||
|
|
||||||
|
|
||||||
def get_error(retcode: Union[int, str]) -> str:
|
def get_error(retcode: Union[int, str]) -> str:
|
||||||
@ -76,10 +78,13 @@ def get_error_type(retcode: Union[int, str]) -> str:
|
|||||||
return 'Api错误'
|
return 'Api错误'
|
||||||
|
|
||||||
|
|
||||||
async def get_error_img(retcode: Union[int, str]) -> bytes:
|
async def get_error_img(retcode: Union[int, str]) -> Union[bytes, str]:
|
||||||
error_message = get_error(retcode)
|
error_message = get_error(retcode)
|
||||||
error_type = get_error_type(retcode)
|
if is_pic_error:
|
||||||
return await draw_error_img(retcode, error_message, error_type)
|
error_type = get_error_type(retcode)
|
||||||
|
return await draw_error_img(retcode, error_message, error_type)
|
||||||
|
else:
|
||||||
|
return error_message
|
||||||
|
|
||||||
|
|
||||||
async def draw_error_img(
|
async def draw_error_img(
|
||||||
|
@ -53,4 +53,5 @@ CONIFG_DEFAULT: Dict[str, GSC] = {
|
|||||||
'RandomText': GsStrConfig(
|
'RandomText': GsStrConfig(
|
||||||
'随机字符串列表', '随机字符串列表', 'abcdefghijklmnopqrstuvwxyz'
|
'随机字符串列表', '随机字符串列表', 'abcdefghijklmnopqrstuvwxyz'
|
||||||
),
|
),
|
||||||
|
'ChangeErrorToPic': GsBoolConfig('错误提示转换为图片', '将一部分报错提示转换为图片', True),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user