Fixed error in custom_welcome_msg and message_builder

This commit is contained in:
NovaNo1r 2022-02-23 21:45:53 -08:00
parent c674d581b7
commit 76df21036a
3 changed files with 3 additions and 3 deletions

View File

@ -75,7 +75,7 @@ async def custom_group_welcome(
await AsyncHttpx.download_file( await AsyncHttpx.download_file(
img, DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg" img, DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg"
) )
img_result = image(abspath=DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg") img_result = image(DATA_PATH / "custom_welcome_msg" / f"{group_id}.jpg")
logger.info(f"USER {user_id} GROUP {group_id} 更换群欢迎消息图片") logger.info(f"USER {user_id} GROUP {group_id} 更换群欢迎消息图片")
except Exception as e: except Exception as e:
logger.error(f"GROUP {group_id} 替换群消息失败 e:{e}") logger.error(f"GROUP {group_id} 替换群消息失败 e:{e}")

View File

@ -129,7 +129,7 @@ async def _(bot: Bot, event: GroupIncreaseNoticeEvent):
at_flag = True at_flag = True
if (DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg").exists(): if (DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg").exists():
img = image( img = image(
abspath=DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg" DATA_PATH / "custom_welcome_msg" / f"{event.group_id}.jpg"
) )
if msg or img: if msg or img:
msg = msg.strip() + img msg = msg.strip() + img

View File

@ -25,7 +25,7 @@ def image(
""" """
if abspath: if abspath:
if isinstance(abspath, Path): if isinstance(abspath, Path):
return MessageSegment.image(file) return MessageSegment.image(abspath)
return ( return (
MessageSegment.image("file:///" + abspath) MessageSegment.image("file:///" + abspath)
if os.path.exists(abspath) if os.path.exists(abspath)