mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2025-04-12 23:29:37 +08:00
增加敏感词过滤,fix bug
This commit is contained in:
parent
a249f751d5
commit
e7f26925ed
@ -23,6 +23,7 @@ from utils.auth_util import check_cookie, FreqLimiter
|
|||||||
from utils.decorator import exception_handler
|
from utils.decorator import exception_handler
|
||||||
from utils.enka_util import PlayerInfo
|
from utils.enka_util import PlayerInfo
|
||||||
from utils.message_util import get_uid_in_msg, uid_userId_to_dict, replace_all, transform_uid, get_message_id
|
from utils.message_util import get_uid_in_msg, uid_userId_to_dict, replace_all, transform_uid, get_message_id
|
||||||
|
from utils.message_util import MessageBuild as MsgBd
|
||||||
from .draw_abyss_info import draw_abyss_card
|
from .draw_abyss_info import draw_abyss_card
|
||||||
from .draw_daily_note import draw_daily_note_card
|
from .draw_daily_note import draw_daily_note_card
|
||||||
from .draw_month_info import draw_monthinfo_card
|
from .draw_month_info import draw_monthinfo_card
|
||||||
@ -339,7 +340,7 @@ async def _(event: MessageEvent, state: T_State):
|
|||||||
state['choice'] = match_alias
|
state['choice'] = match_alias
|
||||||
else:
|
else:
|
||||||
if not match_alias:
|
if not match_alias:
|
||||||
await ysc.finish(f'没有找到叫{name}的角色哦~', at_sender=True)
|
await ysc.finish(MsgBd.Text(f'没有找到叫{name}的角色哦~'), at_sender=True)
|
||||||
elif 'choice' not in state:
|
elif 'choice' not in state:
|
||||||
msg = f'你要找的角色是哪个呀:\n'
|
msg = f'你要找的角色是哪个呀:\n'
|
||||||
# 将字典中每个键拼接到msg中,并添加序号
|
# 将字典中每个键拼接到msg中,并添加序号
|
||||||
@ -397,7 +398,7 @@ async def ysb_handler(event: MessageEvent, msg: Message = CommandArg()):
|
|||||||
# 获取方法:登录网页版米游社,在地址栏粘贴代码:\njavascript:(function(){prompt(document.domain,document.cookie)})(
|
# 获取方法:登录网页版米游社,在地址栏粘贴代码:\njavascript:(function(){prompt(document.domain,document.cookie)})(
|
||||||
# );\n复制弹窗出来的字符串(手机要via或chrome浏览器才行)\n然后添加派蒙私聊发送ysb接刚刚复制的字符串,例如:ysb
|
# );\n复制弹窗出来的字符串(手机要via或chrome浏览器才行)\n然后添加派蒙私聊发送ysb接刚刚复制的字符串,例如:ysb
|
||||||
# UM_distinctid=17d131d...\ncookie是账号重要安全信息,请确保机器人持有者可信赖! '''
|
# UM_distinctid=17d131d...\ncookie是账号重要安全信息,请确保机器人持有者可信赖! '''
|
||||||
res = '获取cookie的教程在这里哦:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后,添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
|
res = '获取cookie的教程:\ndocs.qq.com/doc/DQ3JLWk1vQVllZ2Z1\n获取到后,添加派蒙好友私聊发送ysb接复制到的cookie就行啦~'
|
||||||
await ysb.finish(res, at_sender=True)
|
await ysb.finish(res, at_sender=True)
|
||||||
else:
|
else:
|
||||||
cookie_info, mys_id = await get_bind_game(cookie)
|
cookie_info, mys_id = await get_bind_game(cookie)
|
||||||
@ -419,7 +420,7 @@ async def ysb_handler(event: MessageEvent, msg: Message = CommandArg()):
|
|||||||
msg = f'{nickname}绑定成功啦!使用ys/ysa等指令和派蒙互动吧!'
|
msg = f'{nickname}绑定成功啦!使用ys/ysa等指令和派蒙互动吧!'
|
||||||
if event.message_type != 'private':
|
if event.message_type != 'private':
|
||||||
msg += '\n当前是在群聊里绑定,建议旅行者把cookie撤回哦!'
|
msg += '\n当前是在群聊里绑定,建议旅行者把cookie撤回哦!'
|
||||||
await ysb.finish(msg, at_sender=True)
|
await ysb.finish(MsgBd.Text(msg), at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@add_public_ck.handle()
|
@add_public_ck.handle()
|
||||||
@ -586,7 +587,7 @@ async def _(event: MessageEvent, state: T_State):
|
|||||||
player_info = PlayerInfo(uid)
|
player_info = PlayerInfo(uid)
|
||||||
roles_list = player_info.get_roles_list()
|
roles_list = player_info.get_roles_list()
|
||||||
if role not in roles_list:
|
if role not in roles_list:
|
||||||
await role_info.finish(f'派蒙还没有你{role}的信息哦,请先把该角色放在游戏内展柜中,然后使用 更新角色信息 命令更新~', at_sender=True)
|
await role_info.finish(MsgBd.Text(f'派蒙还没有你{role}的信息哦,请先把该角色放在游戏内展柜中,然后使用 更新角色信息 命令更新~'), at_sender=True)
|
||||||
else:
|
else:
|
||||||
role_data = player_info.get_roles_info(role)
|
role_data = player_info.get_roles_info(role)
|
||||||
img = await draw_role_card(uid, role_data)
|
img = await draw_role_card(uid, role_data)
|
||||||
|
@ -68,7 +68,7 @@ async def genshinAttribute(event: MessageEvent):
|
|||||||
img = MessageBuild.Text(f'没有找到{name}的参考面板')
|
img = MessageBuild.Text(f'没有找到{name}的参考面板')
|
||||||
await attribute.finish(img)
|
await attribute.finish(img)
|
||||||
else:
|
else:
|
||||||
await attribute.finish(f'没有找到{name}的参考面板', at_sender=True)
|
await attribute.finish(MessageBuild.Text(f'没有找到{name}的参考面板'), at_sender=True)
|
||||||
|
|
||||||
|
|
||||||
@daily_material.handle()
|
@daily_material.handle()
|
||||||
@ -145,7 +145,7 @@ def create_choice_command(endswith: str, type_: str, url: str, tips: str = None,
|
|||||||
await MessageBuild.StaticImage(url=url.format(match_alias[0]), tips=tips.format(match_alias[0])))
|
await MessageBuild.StaticImage(url=url.format(match_alias[0]), tips=tips.format(match_alias[0])))
|
||||||
else:
|
else:
|
||||||
if not match_alias:
|
if not match_alias:
|
||||||
await command.finish(f'没有{state["name"]}的{endswith}哦~', at_sender=True)
|
await command.finish(MessageBuild.Text(f'没有{state["name"]}的{endswith}哦~'), at_sender=True)
|
||||||
else:
|
else:
|
||||||
if isinstance(match_alias, dict):
|
if isinstance(match_alias, dict):
|
||||||
match_alias = list(match_alias.keys())
|
match_alias = list(match_alias.keys())
|
||||||
|
@ -65,9 +65,6 @@
|
|||||||
|
|
||||||
## 丨更新日志
|
## 丨更新日志
|
||||||
> README只展示最近2条更新,全部更新日志详见[这里](https://github.com/CMHopeSunshine/LittlePaimon/blob/nonebot2/UPDATE_LOG.md)
|
> README只展示最近2条更新,全部更新日志详见[这里](https://github.com/CMHopeSunshine/LittlePaimon/blob/nonebot2/UPDATE_LOG.md)
|
||||||
+ 6.19
|
|
||||||
- 新增`米游币商品兑换`功能,私聊机器人发送`myb`跟着一步步指引来做,目前该功能还没有机会做测试,出现问题请提issue
|
|
||||||
- `ysb`绑定cookie的方法增加腾讯文档
|
|
||||||
+ 6.21
|
+ 6.21
|
||||||
- 适配`nonebot2 beta4`插件元数据,请更新nb版本`pip install nonebot2 --upgrade`
|
- 适配`nonebot2 beta4`插件元数据,请更新nb版本`pip install nonebot2 --upgrade`
|
||||||
- `Paimon_Chat`现在可以发图片、视频等,可自行添加
|
- `Paimon_Chat`现在可以发图片、视频等,可自行添加
|
||||||
@ -76,6 +73,9 @@
|
|||||||
- 增加部分注释文档
|
- 增加部分注释文档
|
||||||
- 更换原神日历样式[@nicklly](https://github.com/nicklly) ,需用到htmlrender插件`pip install nonebot-plugin-htmlrender`
|
- 更换原神日历样式[@nicklly](https://github.com/nicklly) ,需用到htmlrender插件`pip install nonebot-plugin-htmlrender`
|
||||||
- 添加`pyproject.toml`和`poetry.lock`
|
- 添加`pyproject.toml`和`poetry.lock`
|
||||||
|
+ 6.22
|
||||||
|
- 增加文本敏感词过滤
|
||||||
|
- fix `原神日历`和发送图片bug
|
||||||
|
|
||||||
## 丨功能列表
|
## 丨功能列表
|
||||||
|
|
||||||
|
@ -42,4 +42,7 @@
|
|||||||
- 对对联功能api更换
|
- 对对联功能api更换
|
||||||
- 增加部分注释文档
|
- 增加部分注释文档
|
||||||
- 更换原神日历样式[@nicklly](https://github.com/nicklly) ,需用到htmlrender插件`pip install nonebot-plugin-htmlrender`
|
- 更换原神日历样式[@nicklly](https://github.com/nicklly) ,需用到htmlrender插件`pip install nonebot-plugin-htmlrender`
|
||||||
- 添加`pyproject.toml`和`poetry.lock`
|
- 添加`pyproject.toml`和`poetry.lock`
|
||||||
|
+ 6.22
|
||||||
|
- 增加文本敏感词过滤
|
||||||
|
- fix `原神日历`和发送图片bug
|
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ class MessageBuild:
|
|||||||
if mode:
|
if mode:
|
||||||
img = img.convert(mode)
|
img = img.convert(mode)
|
||||||
bio = BytesIO()
|
bio = BytesIO()
|
||||||
img.save(bio, format=img.format or 'JPEG', quality=quality)
|
img.save(bio, format='JPEG' if img.mode == 'RGB' else 'PNG', quality=quality)
|
||||||
return MessageSegment.image(bio)
|
return MessageSegment.image(bio)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -96,19 +96,19 @@ class MessageBuild:
|
|||||||
if mode:
|
if mode:
|
||||||
img = img.convert(mode)
|
img = img.convert(mode)
|
||||||
bio = BytesIO()
|
bio = BytesIO()
|
||||||
img.save(bio, format=img.format or 'JPEG', quality=quality)
|
img.save(bio, format='JPEG' if img.mode == 'RGB' else 'PNG', quality=quality)
|
||||||
return MessageSegment.image(bio)
|
return MessageSegment.image(bio)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def Text(cls, text: str) -> MessageSegment:
|
def Text(cls, text: str) -> MessageSegment:
|
||||||
"""
|
"""
|
||||||
过滤文本中的敏感词
|
过滤文本中的敏感违禁词
|
||||||
:param text: 文本
|
:param text: 文本
|
||||||
:return: MessageSegment.text
|
:return: MessageSegment.text
|
||||||
"""
|
"""
|
||||||
for word in ban_word:
|
for word in ban_word[2:]:
|
||||||
if word in text:
|
if word and word in text:
|
||||||
text = text.replace(word, '*')
|
text = text.replace(word, '*' * len(word))
|
||||||
return MessageSegment.text(text)
|
return MessageSegment.text(text)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user