diff --git a/core/fun/welcome.py b/core/fun/welcome.py index 656c28b..959418a 100644 --- a/core/fun/welcome.py +++ b/core/fun/welcome.py @@ -34,7 +34,7 @@ async def welcome(event: MemberJoinEvent) -> None: await sendMsgChain( messagechain_builder(text=info, at=personid), grouptarget=event.member.group.id) if os.path.exists(r'./plugin/Petpet/gif.py'): - from plugin import petpet + from plugin.Petpet.gif import petpet await petpet(personid) await sendMsgChain(grouptarget=groupid, msg=messagechain_builder(imgpath=f'./images/PetPet/temp/tempPetPet-{personid}.gif')) diff --git a/plugin/ImgOperation/csgokill.py b/plugin/ImgOperation/csgokill.py index f671479..f149eff 100644 --- a/plugin/ImgOperation/csgokill.py +++ b/plugin/ImgOperation/csgokill.py @@ -90,4 +90,9 @@ async def cskill(event: GroupMessage): elif At in event.message_chain: target_id = event.message_chain.get_first(At).target memberinfo = await bot.get_group_member(group=event.group.id, id_=target_id) - await bot.send(event, await jisha(event.sender.member_name, memberinfo.member_name)) + if not memberinfo: + memberprofile = await bot.member_profile.get(target=event.group.id, member_id=target_id) + membername = memberprofile.nickname + else: + membername = memberinfo.member_name + await bot.send(event, await jisha(event.sender.member_name, membername)) diff --git a/plugin/MajSoulInfo/bot_majsoul.py b/plugin/MajSoulInfo/bot_majsoul.py index f7efb48..57df4b9 100644 --- a/plugin/MajSoulInfo/bot_majsoul.py +++ b/plugin/MajSoulInfo/bot_majsoul.py @@ -329,7 +329,7 @@ async def qhdrawcards(event: GroupMessage): else: result = majsoul.drawcards(userid=event.sender.id, up=False) if result['error']: - return await bot.send(event, messagechain_builder(at=event.sender.id), text=result['resultsmsg']) + return await bot.send(event, messagechain_builder(at=event.sender.id, text=result['resultsmsg'])) mergeimgs( result.get('results'), event.sender.id) await bot.send(event, messagechain_builder( diff --git a/plugin/MajSoulInfo/majsoulinfo.py b/plugin/MajSoulInfo/majsoulinfo.py index 2ae5581..8b98c83 100644 --- a/plugin/MajSoulInfo/majsoulinfo.py +++ b/plugin/MajSoulInfo/majsoulinfo.py @@ -182,7 +182,7 @@ async def asyrecordsrequest(playerid, type, counts) -> list: except asyncio.TimeoutError as e: print(e) ERROR = True - paipuInfo = '牌谱查询超时' + paipuInfo = '牌谱查询超时,请稍后再试' result = dict(msg=paipuInfo, err=ERROR) if not ERROR: result['img64'] = text_to_image(text=paipuInfo, needtobase64=True) @@ -475,7 +475,7 @@ def getrank(playerinfo: dict): msg += paipumsg except asyncio.exceptions.TimeoutError as e: print(f'\n牌谱读取超时:\t{e}\n') - return dict(msg="查询超时,请再试一次", error=True) + return dict(msg="查询超时,请稍后再试", error=True) try: if selecttype == "4": url = f"https://ak-data-5.sapk.ch/api/v2/pl4/player_extended_stats/{playerid}/{selectmontht}/{nextmontht}?mode=16.12.9.15.11.8" @@ -497,7 +497,7 @@ def getrank(playerinfo: dict): msg += infomsg except asyncio.exceptions.TimeoutError as e: print(f'\n玩家详情读取超时:\t{e}\n') - return dict(msg="查询超时,请再试一次", error=True) + return dict(msg="查询超时,请稍后再试", error=True) text_to_image(path=f"MajsoulInfo/yb{playername}.png", text=msg) return dict(msg=msg, error=False) @@ -581,7 +581,7 @@ async def query(self, username: str, selecttype: str = "", selectindex: int = 0) if userinfo['error']: if userinfo['offline']: return dict(msg="牌谱屋服务器离线", error=True) - return dict(msg="查询超时", error=True) + return dict(msg="查询超时,请稍后再试", error=True) prtmsg = username playerid = userinfo['playerid'] if playerid: @@ -650,7 +650,7 @@ async def getcertaininfo(self, username: str, selecttype: str = "4", selectindex playerinfo = await response.json() except asyncio.exceptions.TimeoutError as e: print(f"查询超时\t {e}") - return "查询超时" + return "查询超时,请稍后再试" if len(playerinfo) == 0: return "不存在该玩家" elif len(playerinfo) < selectindex: @@ -1165,7 +1165,7 @@ async def asysearchqh(url, type="3"): return dict(msg=text, error=False) except asyncio.exceptions.TimeoutError as e: print(f"查询超时,{e}") - return dict(msg="查询超时,请再试一次", error=True) + return dict(msg="查询超时,请稍后再试", error=True) def db_init(): cx = sqlite3.connect('./database/MajSoulInfo/majsoul.sqlite') diff --git a/plugin/Setu/setu.py b/plugin/Setu/setu.py index 6f83000..0ed5dac 100644 --- a/plugin/Setu/setu.py +++ b/plugin/Setu/setu.py @@ -7,6 +7,8 @@ import json from io import BytesIO + +from PIL.Image import Image from mirai import GroupMessage, Plain from core import bot, commandpre, commands_map, config from utils.MessageChainBuilder import messagechain_builder @@ -39,16 +41,27 @@ ] -async def download_setu_base64_from_url(url): +async def download_setu_base64_from_url(userid): + url = f'http://q1.qlogo.cn/g?b=qq&nk={userid}&s=640' async with aiohttp.ClientSession() as session: async with session.get(url=url) as resp: img_content = await resp.read() - # 将图片转换为 base64 - img_bytes = BytesIO(img_content) - b_content = img_bytes.getvalue() - imgcontent = base64.b64encode(b_content) - return imgcontent + pic_base64 = base64.b64encode(img_content) + print(pic_base64) + return pic_base64 + + +# async def download_setu_base64_from_url(url): +# async with aiohttp.ClientSession() as session: +# async with session.get(url=url) as resp: +# img_content = await resp.read() +# +# # 将图片转换为 base64 +# img_bytes = BytesIO(img_content) +# b_content = img_bytes.getvalue() +# imgcontent = base64.b64encode(b_content) +# return imgcontent async def getsetuinfo(description: str, num: int) -> dict: @@ -192,7 +205,9 @@ async def getsomesetu(event: GroupMessage): m1.group(2), groupid=event.group.id) if imginfo['FoundError']: return await bot.send(event, messagechain_builder(at=event.sender.id, text=imginfo['ErrorMsg'])) + # imgb64 = download_setu_base64_from_url(imginfo['url']) res = await bot.send(event, messagechain_builder(imgurl=imginfo['url'])) + # res = await bot.send(event,messagechain_builder(imgbase64=imgb64)) if res != -1 and stfinder.recalltime != -1: await asyncio.sleep(stfinder.recalltime) await bot.recall(res) @@ -210,9 +225,14 @@ async def getsomesetu(event: GroupMessage): if settings['setu'] and event.group.id in config['setugroups']: if not cmdbuffer.updategroupcache(groupcommand(event.group.id, event.sender.id, 'setu')): return bot.send(event, messagechain_builder(at=event.sender.id, text="你冲的频率太频繁了,休息一下吧")) + setu_num = m2.group(1) + if not setu_num: + setu_num = 1 + else: + setu_num = int(setu_num) try: imginfo = await stfinder.getsetu( - m2.group(2), event.group.id, int(m2.group(1))) + m2.group(2), event.group.id, setu_num) if imginfo['FoundError']: return await bot.send(event, messagechain_builder(at=event.sender.id, text=imginfo['ErrorMsg'])) res = await bot.send(event, messagechain_builder(imgurl=imginfo['url']))