Skip to content

Commit

Permalink
接入hoshinobot敏感词库,以防bot被恶意利用
Browse files Browse the repository at this point in the history
  • Loading branch information
CYDXDianXian committed Aug 23, 2022
1 parent 2ee97e6 commit d058059
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions create_img.py
Original file line number Diff line number Diff line change
Expand Up @@ -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才能读取
Expand Down Expand Up @@ -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(' ')

Expand Down

0 comments on commit d058059

Please sign in to comment.