解决几个cq码注入问题

This commit is contained in:
CMHopeSunshine 2022-04-02 23:05:18 +08:00
parent 28aad9fdd8
commit bd3151c978
6 changed files with 16 additions and 19 deletions

View File

@ -35,13 +35,6 @@ async def main(bot,ev):
if match:
uid = ''
qq = str(match.group(1))
# try:
# qq_info = await bot.get_group_member_info(group_id=ev.group_id,
# user_id=qid)
# except:
# qq_info = await bot.get_guild_member_profile(guild_id=ev.guild_id,
# user_id=qid)
# nickname = qq_info['nickname']
if not uid:
uid = get_uid_by_qq(qq)
if not uid:

View File

@ -1,6 +1,7 @@
import json,os,re
from hoshino import R,MessageSegment,logger, Service
from hoshino.typing import CQEvent, Message
from hoshino.util import filt_message
from ..util import get_uid_by_qq, get_cookie, check_uid_by_qq, update_last_query_to_qq
from ..get_data import get_daily_note_data
from .get_img import draw_daily_note_card
@ -28,7 +29,7 @@ async def main(bot,ev):
await bot.send(ev,'你还没把信息绑定给派蒙哦',at_sender=True)
return
if len(uid) != 9 or not uid.isdigit():
await bot.send(ev,f'uid {uid} 不合规,是不是打错了呀',at_sender=True)
await bot.send(ev,f'uid {filt_message(uid)} 不合规,是不是打错了呀',at_sender=True)
return
cookie = await get_cookie(qq, uid, only_private = True, only_match_uid = True)
update_last_query_to_qq(qq, uid)

View File

@ -5,6 +5,7 @@ from hoshino.typing import CQEvent, Message
from ..character_alias import get_id_by_alias
from .blue import get_blue_pic
from ..util import pil2b64
from hoshino.util import filt_message
sv=hoshino.Service('原神角色wiki')
res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res')
@ -15,7 +16,7 @@ async def genshinguide(bot,ev):
name = ev.message.extract_plain_text().strip()
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的攻略',at_sender=True)
await bot.send(ev,f'没有找到{filt_message(name)}的攻略',at_sender=True)
elif realname[1][0] in ['八重神子', '神里绫华', '神里绫人', '温迪', '七七', '雷电将军']:
path = os.path.join(res_path, 'role_guide',f'{realname[1][0]}.png')
cq_img = f'[CQ:image,file=file:///{path}]'
@ -30,7 +31,7 @@ async def genshinmaterial(bot,ev):
name = ev.message.extract_plain_text().strip()
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的材料',at_sender=True)
await bot.send(ev,f'没有找到{filt_message(name)}的材料',at_sender=True)
else:
path = os.path.join(res_path, 'role_material',f'{realname[1][0]}材料.png')
cq_img = f'[CQ:image,file=file:///{path}]'
@ -43,7 +44,7 @@ async def genshinAttribute(bot,ev):
if name not in ['风主', '岩主', '雷主']:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的参考面板',at_sender=True)
await bot.send(ev,f'没有找到{filt_message(name)}的参考面板',at_sender=True)
return
realname = realname[1][0]
else:
@ -63,7 +64,7 @@ async def genshinAttribute2(bot,ev):
if name not in ['风主', '岩主', '雷主']:
realname = get_id_by_alias(name)
if not realname:
await bot.send(ev,f'没有找到{name}的参考面板',at_sender=True)
await bot.send(ev,f'没有找到{filt_message(name)}的参考面板',at_sender=True)
return
realname = realname[1][0]
else:

View File

@ -1,6 +1,7 @@
import json,os,re,datetime
from hoshino import R,MessageSegment,logger, Service
from hoshino.typing import CQEvent, Message
from hoshino.util import filt_message
from ..util import get_uid_by_qq, get_cookie, check_uid_by_qq, update_last_query_to_qq
from ..get_data import get_monthinfo_data
from .get_img import draw_monthinfo_card
@ -39,7 +40,7 @@ async def main(bot,ev):
await bot.send(ev,'你还没把信息绑定给派蒙哦',at_sender=True)
return
if len(uid) != 9 or not uid.isdigit():
await bot.send(ev,f'uid {uid} 不合规,是不是打错了呀',at_sender=True)
await bot.send(ev,f'uid {filt_message(uid)} 不合规,是不是打错了呀',at_sender=True)
return
cookie = await get_cookie(qq, uid, only_private = True, only_match_uid = True)
update_last_query_to_qq(qq, uid)

View File

@ -1,6 +1,7 @@
import json,os,re
from hoshino import R,MessageSegment,logger, Service
from hoshino.typing import CQEvent, Message
from hoshino.util import filt_message
from ..util import get_uid_by_qq, get_cookie, check_uid_by_qq, update_last_query_to_qq
from ..get_data import get_player_card_data, get_chara_detail_data, get_chara_skill_data
from .get_img import draw_player_card, draw_all_chara_card, draw_chara_card
@ -26,7 +27,7 @@ async def player_card(bot,ev):
await bot.send(ev,'请把uid给派蒙哦比如ys100000001',at_sender=True)
return
if len(uid) != 9 or not uid.isdigit():
await bot.send(ev,f'uid {uid} 不合规,是不是打错了呀',at_sender=True)
await bot.send(ev,f'uid {filt_message(uid)} 不合规,是不是打错了呀',at_sender=True)
return
cookie = await get_cookie(qq, uid)
update_last_query_to_qq(qq, uid)
@ -64,7 +65,7 @@ async def all_characters(bot,ev):
await bot.send(ev,'请把uid给派蒙哦比如ysa100000001',at_sender=True)
return
if len(uid) != 9 or not uid.isdigit():
await bot.send(ev,f'uid {uid} 不合规,是不是打错了呀',at_sender=True)
await bot.send(ev,f'uid {filt_message(uid)} 不合规,是不是打错了呀',at_sender=True)
return
cookie = await get_cookie(qq, uid)
update_last_query_to_qq(qq, uid)
@ -79,7 +80,6 @@ async def all_characters(bot,ev):
await bot.send(ev, f'派蒙出现了问题:{e}',at_sender=True)
#chara_list=['云堇','申鹤','荒泷一斗','五郎','优菈','阿贝多','托马','胡桃','达达利亚','雷电将军','珊瑚宫心海','埃洛伊','宵宫','神里绫华','枫原万叶','温迪','刻晴','莫娜','可莉','琴','迪卢克','七七','魈','钟离','甘雨','旅行者','早柚','九条裟罗','凝光','菲谢尔','班尼特','丽莎','行秋','迪奥娜','安柏','重云','雷泽','芭芭拉','罗莎莉亚','香菱','凯亚','北斗','诺艾尔','砂糖','辛焱','烟绯','八重神子','神里绫人']
@sv.on_prefix('ysc')
async def my_characters(bot,ev):
msg = ev.message.extract_plain_text().strip().split(' ')
@ -96,7 +96,7 @@ async def my_characters(bot,ev):
chara = msg[0]
chara_name = get_id_by_alias(chara)
if not chara_name:
await bot.send(ev,f'没有角色名叫{chara}哦!',at_sender=True)
await bot.send(ev,f'没有角色名叫{filt_message(chara)}哦!',at_sender=True)
return
if ev.message_type == 'guild':
rm = str(ev.message)
@ -111,7 +111,7 @@ async def my_characters(bot,ev):
await bot.send(ev,'请把uid给派蒙哦比如ysc100000001 钟离',at_sender=True)
return
if len(uid) != 9 or not uid.isdigit():
await bot.send(ev,f'uid {uid} 不合规,是不是打错了呀',at_sender=True)
await bot.send(ev,f'uid {filt_message(uid)} 不合规,是不是打错了呀',at_sender=True)
return
cookie = await get_cookie(qq, uid)
update_last_query_to_qq(qq, uid)

View File

@ -1,5 +1,6 @@
import hoshino
from hoshino.typing import CQEvent
from hoshino.util import filt_message
from . import *
from .run import *
@ -12,4 +13,4 @@ sv = hoshino.Service('code', bundle='详细', help_=HELP_MSG, enable_on_default=
@sv.on_prefix('code')
async def code(bot, ev: CQEvent):
res = await run(ev.message.extract_plain_text())
await bot.send(ev, res, at_sender=True)
await bot.send(ev, filt_message(res), at_sender=True)