From d058059eb1559850c03e73662bab5daeab42f22c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=BF=E8=B6=8A=E7=94=B5=E7=BA=BF?= Date: Tue, 23 Aug 2022 17:48:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5hoshinobot=E6=95=8F=E6=84=9F?= =?UTF-8?q?=E8=AF=8D=E5=BA=93=EF=BC=8C=E4=BB=A5=E9=98=B2bot=E8=A2=AB?= =?UTF-8?q?=E6=81=B6=E6=84=8F=E5=88=A9=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __init__.py | 4 ++-- create_img.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index f096aaf..55c2ac0 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ import json import random from nonebot import get_bot, on_command -from hoshino import priv +from hoshino import priv, util from hoshino.typing import NoticeSession, MessageSegment from .pcrclient import pcrclient, ApiException, bsdkclient from asyncio import Lock @@ -218,7 +218,7 @@ async def on_query_arena(bot, ev): last_login_str = time.strftime('%Y-%m-%d %H:%M:%S',last_login_date) await bot.finish(ev, -f'''昵称:{res['user_info']["user_name"]} +f'''昵称:{util.filt_message(str(res['user_info']["user_name"]))} jjc排名:{res['user_info']["arena_rank"]} pjjc排名:{res['user_info']["grand_arena_rank"]} 最后登录:{last_login_str}''', at_sender=False) diff --git a/create_img.py b/create_img.py index c25e540..b29b1fa 100644 --- a/create_img.py +++ b/create_img.py @@ -5,6 +5,7 @@ from pathlib import Path import zhconv from hoshino.aiorequests import run_sync_func +from hoshino import util path = Path(__file__).parent # 获取文件所在目录的绝对路径 font_cn_path = str(path / 'fonts' / 'SourceHanSansCN-Medium.otf') # Path是路径对象,必须转为str之后ImageFont才能读取 @@ -68,12 +69,17 @@ def _generate_info_pic_internal(data, uid): # 资料卡 个人信息 user_name_text = _TraditionalToSimplified(data["user_info"]["user_name"]) + user_name_text = util.filt_message(str(user_name_text)) team_level_text = _TraditionalToSimplified(data["user_info"]["team_level"]) + team_level_text = util.filt_message(str(team_level_text)) total_power_text = _TraditionalToSimplified( data["user_info"]["total_power"]) + total_power_text = util.filt_message(str(total_power_text)) clan_name_text = _TraditionalToSimplified(data["clan_name"]) - user_comment_arr = _cut_str(_TraditionalToSimplified( - data["user_info"]["user_comment"]), 25) + clan_name_text = util.filt_message(str(clan_name_text)) + user_comment_arr = _TraditionalToSimplified(data["user_info"]["user_comment"]) + user_comment_arr = util.filt_message(str(user_comment_arr)) + user_comment_arr = _cut_str(user_comment_arr, 25) last_login_time_text = _TraditionalToSimplified(time.strftime( "%Y/%m/%d %H:%M:%S", time.localtime(data["user_info"]["last_login_time"]))).split(' ')