diff --git a/core/fun/__init__.py b/core/fun/__init__.py index dfd398f..c1b56ba 100644 --- a/core/fun/__init__.py +++ b/core/fun/__init__.py @@ -5,4 +5,5 @@ from core.fun.gethelp import * from core.fun.signin import * from core.fun.roll import * -from core.fun.tarot import * \ No newline at end of file +from core.fun.tarot import * +from .bot_state_in_group import * \ No newline at end of file diff --git a/core/fun/admin_controller.py b/core/fun/admin_controller.py index 033ffaa..dd2e36e 100644 --- a/core/fun/admin_controller.py +++ b/core/fun/admin_controller.py @@ -62,7 +62,7 @@ async def deladmin(event: FriendMessage): else: return await messagechain_sender(event=event, msg=f"{m.group(1)} 不是再管理员了") else: - await bot.send(event, await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True)) + await messagechain_sender(event=event, msg=await messagechain_builder(text="抱歉,您无权这么做哦", rndimg=True)) return @@ -74,8 +74,8 @@ async def getbotinfo(event: FriendMessage): m = re.match(fr"^{commandpre}{commands_map['sys']['getbotinfo']}", msg.strip()) if m: if userid in admin: - return await bot.send(event, - f"机器人设置:{config}\n白名单用户:{_whitelist}\n黑名单用户:{_black_list['user']}\n屏蔽群组:{_black_list['group']}") + return await messagechain_sender(event=event, + msg=f"机器人设置:{config}\n白名单用户:{_whitelist}\n黑名单用户:{_black_list['user']}\n屏蔽群组:{_black_list['group']}") @bot.on(GroupMessage) @@ -90,9 +90,9 @@ async def addwhitelist(event: GroupMessage): _whitelist.append(int(m.group(1))) write_file(content=config, path=r'./config/config.yml') print(m) - return await bot.send(event, "添加成功") + return await messagechain_sender(event=event, msg="添加成功") else: - return await bot.send(event, "添加失败,用户已存在") + return await messagechain_sender(event=event, msg="添加失败,用户已存在") @bot.on(FriendMessage) @@ -104,14 +104,14 @@ async def addblacklist(event: FriendMessage): if m: if userid in admin: if int(m.group(1)) in admin: - return await bot.send(event, "请不要将管理员加入黑名单") + return await messagechain_sender(event=event, msg="请不要将管理员加入黑名单") _black_list['user'].append(int(m.group(1))) write_file(content=config, path=r'./config/config.yml') print(m) - return await bot.send(event, "添加成功") + return await messagechain_sender(event=event, msg="添加成功") else: - return await bot.send(event, "添加失败,用户已存在") + return await messagechain_sender(event=event, msg="添加失败,用户已存在") @bot.on(FriendMessage) @@ -126,9 +126,9 @@ async def delblacklist(event: FriendMessage): _black_list['user'].remove(delperson) write_file(content=config, path=r'./config/config.yml') - return await bot.send(event, "删除成功") + return await messagechain_sender(event=event, msg="删除成功") else: - return await bot.send(event, "删除失败,用户不存在") + return await messagechain_sender(event=event, msg="删除失败,用户不存在") @bot.on(FriendMessage) @@ -138,7 +138,7 @@ async def getsyslog(event: FriendMessage): m = re.match( fr"^{commandpre}{commands_map['sys']['log']}", msg.strip()) if m: - return await bot.send(event, "日志功能开发中") + return await messagechain_sender(event=event, msg="日志功能开发中") @bot.on(GroupMessage) @@ -150,11 +150,12 @@ async def tell_to_master(event: GroupMessage): if m: qqid = event.sender.id if qqid in _black_list: - return await bot.send(event, await messagechain_builder(text='你已被列入黑名单,禁止使用该功能')) + return await messagechain_sender(event=event, msg=await messagechain_builder(text='你已被列入黑名单,禁止使用该功能')) if master != 0: if not cmdbuffer.updategroupcache(LongTimeGroupCommand(event.group.id, event.sender.id, 'tell_master')): - return bot.send(event, await messagechain_builder(text="只能每5分钟发一条消息哦~", at=event.sender.id)) + return messagechain_sender(event=event, + msg=await messagechain_builder(text="只能每5分钟发一条消息哦~", at=event.sender.id)) message = m.group(1) await bot.send_friend_message(master, await messagechain_builder(text=f'qq {qqid} 的人说:{message}')) - await bot.send(event, await messagechain_builder(text='已转告主人')) + await messagechain_sender(event=event, msg=await messagechain_builder(text='已转告主人')) diff --git a/core/fun/bot_state_in_group.py b/core/fun/bot_state_in_group.py new file mode 100644 index 0000000..535a3d9 --- /dev/null +++ b/core/fun/bot_state_in_group.py @@ -0,0 +1,65 @@ +""" +:Author: NekoRabi +:Create: 2023/6/15 3:03 +:Update: / +:Describe: Bot群状态监控工具 +:Version: 0.0.1 +""" + +from mirai.models import BotLeaveEventKick, BotMuteEvent, BotUnmuteEvent, BotJoinGroupEvent + +from core import bot, master +from utils import root_logger +from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender + +__all__ = ['bot_muted', 'bot_unmuted', 'bot_leave_group', 'bot_join_group'] + + +@bot.on(BotLeaveEventKick) +async def bot_leave_group(event: BotLeaveEventKick): + """Bot被踢出群""" + try: + await messagechain_sender(friendtarget=master, msg=await messagechain_builder(text=f"Bot被踢出群{event.group.id}")) + root_logger.error(f'Bot被踢出群聊{event.group.id}') + except Exception as _e: + print(f'Bot被踢出出群聊时发生错误\n{_e}') + root_logger.error(f'Bot被踢出出群聊时发生错误\n{_e}') + return + + +@bot.on(BotMuteEvent) +async def bot_muted(event: BotMuteEvent): + """Bot在x群被禁言""" + try: + await messagechain_sender(friendtarget=master, msg=await messagechain_builder(text=f"Bot被群{event.group.id}禁言了")) + root_logger.error(f'Bot被群聊 {event.group.id} 禁言') + except Exception as _e: + print(f'Bot在被{event.group.id}被禁言时发生错误\n{_e}') + root_logger.error(f'Bot在被{event.group.id}被禁言时发生错误\n{_e}') + return + + +@bot.on(BotUnmuteEvent) +async def bot_unmuted(event: BotUnmuteEvent): + """Bot在x群被解除禁言""" + try: + await messagechain_sender(friendtarget=master, + msg=await messagechain_builder(text=f"Bot在{event.group.id}群解除禁言")) + root_logger.error(f'Bot被群聊 {event.group.id} 解除禁言') + except Exception as _e: + print(f'Bot在群{event.group.id}时被解除禁言发生错误\n{_e}') + root_logger.error(f'Bot在群{event.group.id}时被解除禁言发生错误\n{_e}') + return + +@bot.on(BotJoinGroupEvent) +async def bot_join_group(event: BotJoinGroupEvent): + """Bot加入群""" + try: + await messagechain_sender(friendtarget=master, + msg=await messagechain_builder(text=f"Bot加入群聊 {event.group.id}")) + root_logger.error(f"Bot加入群聊 {event.group.id}") + except Exception as _e: + print(f'Bot加入群聊 {event.group.id} 时发生错误\n{_e}') + root_logger.error(f'Bot加入群聊 {event.group.id} 时发生错误\n{_e}') + return \ No newline at end of file diff --git a/core/fun/gethelp.py b/core/fun/gethelp.py index fb96101..301e28c 100644 --- a/core/fun/gethelp.py +++ b/core/fun/gethelp.py @@ -2,7 +2,7 @@ :Author: NekoRabi :Create: 2022/8/18 2:19 :Update: / -:Describe: 获取机器人帮助,或者说是呼出指令面板 +:Describe: 获取机器人帮助,或者说是呼出指令面板和获取项目地址 :Version: 0.0.1 """ @@ -10,6 +10,7 @@ from mirai import MessageEvent, Plain from core import bot, commandpre, commands_map, config from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender _settings = config.get('settings') @@ -23,8 +24,8 @@ async def getsyshelp(event: MessageEvent): fr"^{commandpre}{commands_map['sys']['help']}", msg.strip()) if m and _settings['help']: # if not cmdbuffer.updategroupcache(groupcommand(event.group.id, event.sender.id, 'help')): - # return bot.send(event, await messagechain_builder()(text="帮助文档刚刚才发过哦~", rndimg=True, at=event.sender.id)) - return await bot.send(event, await messagechain_builder(imgpath="./images/grouphelp.png")) + # return messagechain_sender(event=event,msg= await messagechain_builder()(text="帮助文档刚刚才发过哦~", rndimg=True, at=event.sender.id)) + return await messagechain_sender(event=event, msg=await messagechain_builder(imgpath="./images/grouphelp.png")) @bot.on(MessageEvent) @@ -32,7 +33,7 @@ async def getprojectlink(event: MessageEvent): msg = "".join(map(str, event.message_chain[Plain])) m = re.match(fr"^{commandpre}项目地址\s*$", msg.strip()) if m: - return await bot.send(event, await messagechain_builder(text="Github : https://github.com/NekoRabi/Majsoul-QQBot\n" - "如果觉得好可以点个star⭐")) + return await messagechain_sender(event=event, msg=await messagechain_builder( + text="Github : https://github.com/NekoRabi/Majsoul-QQBot\n如果觉得好用可以帮忙点个star⭐")) # 与机器人互动 diff --git a/core/fun/ping.py b/core/fun/ping.py index cca8b66..c88790f 100644 --- a/core/fun/ping.py +++ b/core/fun/ping.py @@ -21,7 +21,7 @@ async def ping(event: FriendMessage): m = re.match( fr"^{commandpre}{commands_map['sys']['ping']}", msg.strip()) if m: - await bot.send(event, "pong!") + await messagechain_sender(event=event, msg="pong!") return diff --git a/core/fun/signin.py b/core/fun/signin.py index a0ef55a..c53eb36 100644 --- a/core/fun/signin.py +++ b/core/fun/signin.py @@ -21,7 +21,6 @@ os.mkdir("./database/sys") - def db_init(): cx = sqlite3.connect("./database/sys/sys.sqlite") cursor = cx.cursor() @@ -99,12 +98,15 @@ async def sign_in(event: GroupMessage): success, signmsg = signin(event.sender.id) if success: card = tarotcards.drawcards(userid=event.sender.id)[0] - return await bot.send(event, - await messagechain_builder(at=event.sender.id, text=signmsg, imgbase64=card.imgcontent)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(at=event.sender.id, text=signmsg, + imgbase64=card.imgcontent)) # else: # return await messagechain_sender(await messagechain_builder(at=event.sender.id, text=signmsg)) else: - return await bot.send(event, await messagechain_builder(at=event.sender.id, text=signmsg, rndimg=True)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(at=event.sender.id, text=signmsg, + rndimg=True)) # 查询积分 @@ -118,6 +120,7 @@ async def getuserscore(event: GroupMessage): if m: scoremsg = getscore( userid=event.sender.id) - return await bot.send(event, await messagechain_builder(text=scoremsg, rndimg=True)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=scoremsg, rndimg=True)) + db_init() diff --git a/core/fun/silence_toggle.py b/core/fun/silence_toggle.py index 516fe44..e66c638 100644 --- a/core/fun/silence_toggle.py +++ b/core/fun/silence_toggle.py @@ -8,6 +8,7 @@ from mirai import GroupMessage, Plain, FriendMessage from core import bot, config, commandpre, commands_map +from utils.MessageChainSender import messagechain_sender from utils.cfg_loader import write_file settings = config.get('settings') @@ -31,9 +32,11 @@ async def be_silence_from_friend(event: FriendMessage): if m.group(1).lower() == 'on' or m.group(1).lower() == 'true': settings['silence'] = True write_file(content=config, path=r'./config/config.yml') + await messagechain_sender(friendtarget=event.sender.id, msg='我会少说几句的') else: settings['silence'] = False write_file(content=config, path=r'./config/config.yml') + await messagechain_sender(friendtarget=event.sender.id, msg='那我多说几句') # 单群沉默 - 从群聊沉默 @@ -54,7 +57,9 @@ async def be_groupsilence_from_group(event: GroupMessage): if event.group.id not in silencegroup: silencegroup.append(event.group.id) write_file(content=config, path=r'./config/config.yml') + # await messagechain_sender(friendtarget=event.sender.id, msg='吵到了你的话,那我会少说几句的~') else: if event.group.id in silencegroup: silencegroup.remove(event.group.id) write_file(content=config, path=r'./config/config.yml') + # await messagechain_sender(friendtarget=event.sender.id, msg='这么欢迎我,那我多说几句~') diff --git a/core/fun/tarot.py b/core/fun/tarot.py index e10873c..71f9675 100644 --- a/core/fun/tarot.py +++ b/core/fun/tarot.py @@ -248,13 +248,13 @@ async def getsometarots(event: GroupMessage): msgC.append(fmn) # msgC.append(Image(base64=card.imgcontent)) # ForwardMessageNode(event.sender,MessageChain(msgC)) - return await bot.send(event, Forward(node_list=msgC)) + return await messagechain_sender(event=event, msg=Forward(node_list=msgC)) else: return await messagechain_sender(event=event, msg=await messagechain_builder(text='每次只能抽1-9张塔罗牌哦', rndimg=True)) else: card = tarotcards.drawcards(userid=event.sender.id)[0] - return await bot.send(event, await messagechain_builder(imgbase64=card.imgcontent)) + return await messagechain_sender(event=event, msg=await messagechain_builder(imgbase64=card.imgcontent)) # 获取塔罗牌抽卡记录 @@ -265,4 +265,4 @@ async def getmytarots(event: GroupMessage): m = re.match(fr"^{commandpre}{commands_map['sys']['getmytarot']}", msg.strip()) if m: msg = tarotcards.getmydrawcardsinfo(event.sender.id) - return await bot.send(event, await messagechain_builder(text=msg)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=msg)) diff --git a/core/scheduler.py b/core/scheduler.py index 3c93f8a..3065d27 100644 --- a/core/scheduler.py +++ b/core/scheduler.py @@ -1,10 +1,28 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 1:22 +:Update: / +:Describe: 计时器模块,本来还想做一个检测更新的 +:Version: 0.0.1 +""" from apscheduler.schedulers.asyncio import AsyncIOScheduler from mirai.bot import Startup, Shutdown +# import logging +# import aiohttp +# import asyncio +# from bs4 import BeautifulSoup from core import bot + + +__all__ = ['scheduler', 'start_scheduler', 'stop_scheduler'] + scheduler = AsyncIOScheduler(timezone="Asia/Shanghai") +# scheduler.add_job(majsoul.set_link_node, 'cron', hour='0') + +_version = 'v0.7.0' @bot.on(Startup) def start_scheduler(_): @@ -14,3 +32,24 @@ def start_scheduler(_): @bot.on(Shutdown) def stop_scheduler(_): scheduler.shutdown(True) # 结束定时器 + + +# async def _auto_update() -> bool: +# """ +# 自动检查有无版本更新 +# Returns: +# +# """ +# try: +# async with aiohttp.ClientSession( +# connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=25),headers={'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"}) as session: +# async with session.get('https://github.com/NekoRabi/Majsoul-QQBot/releases') as response: +# if response.status == 503: +# return False +# html = response.text() +# +# except aiohttp.client.ClientConnectorError as _e: +# logging.warning('检测更新时发生了意外的错误,类别为aiohttp.client.ClientConnectorError,可能的原因是连接达到上限,可以尝试关闭代理:\n{_e}') +# return False +# bs = BeautifulSoup(html) +# return \ No newline at end of file diff --git a/plugin/AlarmClock/bot_clock.py b/plugin/AlarmClock/bot_clock.py index 3800f0d..d554431 100644 --- a/plugin/AlarmClock/bot_clock.py +++ b/plugin/AlarmClock/bot_clock.py @@ -1,7 +1,7 @@ import datetime import re -from mirai import GroupMessage, Plain, At #, Startup +from mirai import GroupMessage, Plain, At # , Startup from core import bot, scheduler, config, bot_cfg, commandpre from plugin.AlarmClock.file_init import * @@ -48,11 +48,14 @@ async def addclock(event: GroupMessage): description = m.group(4) info = date_check(date) if not info.get('effective'): - return await bot.send(event, await messagechain_builder(text=info.get('error'))) + # return await bot.send(event, await messagechain_builder(text=info.get('error'))) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=info.get('error'))) if m.group(3): info = time_check(time) if not info.get('effective'): - return await bot.send(event, await messagechain_builder(text=info.get('error'))) + # return await bot.send(event, await messagechain_builder(text=info.get('error'))) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text=info.get('error'))) else: time = '00:00:00' groupid = event.group.id @@ -72,14 +75,20 @@ async def group_fixed_clock(): hour_now = datetime.datetime.now().hour for groupid in _alarmclockgroup: if groupid != 0 and type(groupid) == int: - await bot.send_group_message(groupid, - await messagechain_builder( - text=f"准点报时: {datetime.datetime.now().hour}:00", - rndimg=True)) + # await bot.send_group_message(groupid, + # await messagechain_builder( + # text=f"准点报时: {datetime.datetime.now().hour}:00", + # rndimg=True)) + await messagechain_sender(grouptarget=groupid, + msg=await messagechain_builder(text=f"准点报时: {datetime.datetime.now().hour}:00", + rndimg=True)) if hour_now == 22: - await bot.send_group_message(groupid, - await messagechain_builder(text=f"晚上10点了,大家可以休息了,{_botname}也要休息了", - rndimg=True)) + # await bot.send_group_message(groupid, + # await messagechain_builder(text=f"晚上10点了,大家可以休息了,{_botname}也要休息了", + # rndimg=True)) + await messagechain_sender(grouptarget=groupid, + msg=await messagechain_builder(text=f"晚上10点了,大家可以休息了,{_botname}也要休息了", + rndimg=True)) if len(_alarmclockgroup) > 0: diff --git a/plugin/BilibiliPlugin/bilibili.py b/plugin/BilibiliPlugin/bilibili.py index d804151..24a99da 100644 --- a/plugin/BilibiliPlugin/bilibili.py +++ b/plugin/BilibiliPlugin/bilibili.py @@ -15,6 +15,7 @@ from core import bot, config from utils import write_file, read_file from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender last_bvid = {} @@ -81,7 +82,8 @@ async def bili_resolve(event: GroupMessage): img_url = f'http://{url}''' message_chain = await messagechain_builder(imgurl=img_url, text=msg) try: - await bot.send(event, message_chain) + # await bot.send(event, message_chain) + await messagechain_sender(event=event,msg =message_chain) except mirai.exceptions.ApiError as _e: print(f'视频封面发送失败 {_e.args}') return diff --git a/plugin/ImgGenerator/KissKiss/Kisskiss.py b/plugin/ImgGenerator/KissKiss/Kisskiss.py index afc3631..311a3e5 100644 --- a/plugin/ImgGenerator/KissKiss/Kisskiss.py +++ b/plugin/ImgGenerator/KissKiss/Kisskiss.py @@ -17,6 +17,7 @@ from io import BytesIO from core import bot, commands_map, commandpre, blacklist from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender if not os.path.exists("./images/ImgGenerator/KissKiss"): os.mkdir("./images/ImgGenerator/KissKiss") @@ -95,8 +96,10 @@ async def on_kiss(event: GroupMessage): operator_id = event.sender.id target_id = event.message_chain.get_first(At).target if operator_id == target_id: - return await bot.send(event, await messagechain_builder(text="请不要自交", rndimg=True)) + # return await bot.send(event, await messagechain_builder(text="请不要自交", rndimg=True)) + return await messagechain_sender(event=event, msg= await messagechain_builder(text="请不要自交", rndimg=True, at=event.sender.id)) else: await kiss(operator_id=operator_id, target_id=target_id) - await bot.send(event, await messagechain_builder( - imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif')) + # await bot.send(event, await messagechain_builder( + # imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif')) + return await messagechain_sender(event=event, msg= await messagechain_builder(imgpath=f'./images/ImgGenerator/KissKiss/tempKiss-{operator_id}-{target_id}.gif')) diff --git a/plugin/ImgGenerator/bwimg.py b/plugin/ImgGenerator/bwimg.py index 00deda0..c409eb9 100644 --- a/plugin/ImgGenerator/bwimg.py +++ b/plugin/ImgGenerator/bwimg.py @@ -1,3 +1,10 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 1:50 +:Update: / +:Describe: CS击杀制作 +:Version: 0.0.1 +""" import os import re @@ -9,6 +16,7 @@ __all__ = ['bwimg'] from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender if not os.path.exists("./images/ImgGenerator"): os.mkdir("./images/ImgGenerator") @@ -64,7 +72,8 @@ async def bwimg(event: GroupMessage): imgname = img.image_id await img.download(filename=f'./images/tempimg/{imgname}') makebwimg(imgname, m.group(1)) - await bot.send(event, await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}')) + # await bot.send(event, await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}')) + await messagechain_sender(event=event,msg=await messagechain_builder(imgpath=f'./images/ImgGenerator/{imgname}')) deletesource(imgname) # except Exception as e: # print(e) diff --git a/plugin/ImgGenerator/csgokill.py b/plugin/ImgGenerator/csgokill.py index b41f949..39adadf 100644 --- a/plugin/ImgGenerator/csgokill.py +++ b/plugin/ImgGenerator/csgokill.py @@ -17,6 +17,8 @@ __all__ = ['cskill'] +from utils.MessageChainSender import messagechain_sender + async def jisha(user: str, target: str, headshot=None, penetrate=None): """ @@ -93,7 +95,8 @@ async def cskill(event: GroupMessage): fr"^击杀(\S+)?$", msg.strip()) if m: if m.group(1): - await bot.send(event, await jisha(event.sender.member_name, m.group(1))) + # await bot.send(event, await jisha(event.sender.member_name, m.group(1))) + await messagechain_sender(event=event, msg=await jisha(event.sender.member_name, m.group(1))) 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) @@ -102,4 +105,5 @@ async def cskill(event: GroupMessage): membername = memberprofile.nickname else: membername = memberinfo.member_name - await bot.send(event, await jisha(event.sender.member_name, membername)) + # await bot.send(event, await jisha(event.sender.member_name, membername)) + await messagechain_sender(event=event, msg=await jisha(event.sender.member_name, membername)) diff --git a/plugin/ImgGenerator/groupmember_imgoperation.py b/plugin/ImgGenerator/groupmember_imgoperation.py index 0a16711..ffb699d 100644 --- a/plugin/ImgGenerator/groupmember_imgoperation.py +++ b/plugin/ImgGenerator/groupmember_imgoperation.py @@ -1,12 +1,13 @@ """ :Author: NekoRabi :Create: 2022/9/23 14:08 -:Update: / +:Update: 2023/6/16 :Describe: 群成员图片制作 :Version: 0.0.1 """ import random +from utils import root_logger from utils.MessageChainBuilder import messagechain_builder from mirai import GroupMessage, At, Plain from core import bot, blacklist @@ -18,6 +19,8 @@ import os import base64 +from utils.MessageChainSender import messagechain_sender + if not os.path.exists("./images/ImgGenerator"): os.mkdir("./images/ImgGenerator") @@ -142,6 +145,7 @@ async def holdup(userid): @bot.on(GroupMessage) async def daiburen(event: GroupMessage): + """生成逮捕图""" if event.sender.id in blacklist: return msg = "".join(map(str, event.message_chain[Plain])) @@ -157,7 +161,8 @@ async def daiburen(event: GroupMessage): if userid: # await makedaibu(userid) # return bot.send(event, await messagechain_builder(imgpath=f'./images/ImgGenerator/daibu_{userid}.png')) - return await bot.send(event, await messagechain_builder(imgbase64=await makedaibu(userid))) + return await messagechain_sender(event=event, + msg=await messagechain_builder(imgbase64=await makedaibu(userid))) @bot.on(GroupMessage) @@ -181,15 +186,20 @@ async def xka(event: GroupMessage): await makesmalllove(userid, memberinfo.member_name, member_profile.sex) else: await makesmalllove(userid, member_profile.nickname, member_profile.sex) - await bot.send(event, await messagechain_builder(imgpath=f'./images/ImgGenerator/xiaokeai_{userid}.png')) + # await bot.send(event, + # await messagechain_builder(imgpath=f'./images/ImgGenerator/xiaokeai_{userid}.png')) + await messagechain_sender(event=event, + msg=await messagechain_builder( + imgpath=f'./images/ImgGenerator/xiaokeai_{userid}.png')) except Exception as e: print(e) - pass + root_logger.error(f"制作并发生'小可爱'时发生了错误\n{e}") return @bot.on(GroupMessage) async def diuren(event: GroupMessage): + """丢人制作""" if event.sender.id in blacklist: return msg = "".join(map(str, event.message_chain[Plain])) @@ -203,7 +213,8 @@ async def diuren(event: GroupMessage): userid = event.message_chain.get_first(At).target if userid: img = await throwpeople(userid) - await bot.send(event, await messagechain_builder(imgbase64=img)) + # await bot.send(event, await messagechain_builder(imgbase64=img)) + await messagechain_sender(event=event, msg=await messagechain_builder(imgbase64=img)) # else: # await bot.send(event, await messagechain_builder(text='请At要丢的人哦~')) return @@ -211,6 +222,7 @@ async def diuren(event: GroupMessage): @bot.on(GroupMessage) async def chiren(event: GroupMessage): + """吃掉头像""" if event.sender.id in blacklist: return msg = "".join(map(str, event.message_chain[Plain])) @@ -219,12 +231,13 @@ async def chiren(event: GroupMessage): if At in event.message_chain: userid = event.message_chain.get_first(At).target img = await eatpeople(userid) - await bot.send(event, await messagechain_builder(imgbase64=img)) + await messagechain_sender(event=event, msg=await messagechain_builder(imgbase64=img)) return @bot.on(GroupMessage) async def juren(event: GroupMessage): + """举高高""" if event.sender.id in blacklist: return msg = "".join(map(str, event.message_chain[Plain])) @@ -238,5 +251,5 @@ async def juren(event: GroupMessage): userid = event.message_chain.get_first(At).target if userid: img = await holdup(userid) - await bot.send(event, await messagechain_builder(imgbase64=img)) + await bot.messagechain_sender(event=event, msg=await messagechain_builder(imgbase64=img)) return diff --git a/plugin/ImgGenerator/jupai/holdup.py b/plugin/ImgGenerator/jupai/holdup.py index 5d9f85e..abe803f 100644 --- a/plugin/ImgGenerator/jupai/holdup.py +++ b/plugin/ImgGenerator/jupai/holdup.py @@ -1,12 +1,20 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 1:57 +:Update: / +:Describe:举牌文本生成 +:Version: 0.0.1 +""" import os import random import re - import numpy as np + from utils.MessageChainBuilder import messagechain_builder from PIL import ImageFont, ImageDraw, Image from mirai import GroupMessage, Plain from core import bot, commandpre, blacklist +from utils.MessageChainSender import messagechain_sender if not os.path.exists("./images/ImgGenerator/jupai"): os.mkdir("./images/ImgGenerator/jupai") @@ -81,7 +89,9 @@ async def jupai(event: GroupMessage): if m: if len(m.group(1)) > 40: - await bot.send(event, "最多支持做40个字的举牌哦~") + # await bot.send(event, "最多支持做40个字的举牌哦~") + await messagechain_sender(event=event, msg="最多支持做40个字的举牌哦~") imgoutput(event.sender.id, (m.group(1))) message_chain = await messagechain_builder(imgpath=f'./images/ImgGenerator/jupai/{event.sender.id}.png') - await bot.send(event, message_chain) + # await bot.send(event, message_chain) + await messagechain_sender(event=event, msg=message_chain) diff --git a/plugin/ImgGenerator/prank_on_groupmember/persecute_groupmenber.py b/plugin/ImgGenerator/prank_on_groupmember/persecute_groupmenber.py index 518951a..83da388 100644 --- a/plugin/ImgGenerator/prank_on_groupmember/persecute_groupmenber.py +++ b/plugin/ImgGenerator/prank_on_groupmember/persecute_groupmenber.py @@ -1,7 +1,7 @@ """ :Author: NekoRabi :Create: 2022/8/13 20:13 -:Update: / +:Update: 2023/6/16 :Describe: 一个'迫害'群友的插件 """ import base64 @@ -13,6 +13,7 @@ from mirai.models import Plain, GroupMessage, Quote from core import bot, blacklist from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender default_fontsize = 48 default_maxwidth = default_fontsize * 15 @@ -193,7 +194,8 @@ async def groupmessage_screenshot(event: GroupMessage): origin_msg = origin_msg.replace('[图片]', '').replace('[动画表情]', '').replace('[符号表情]', '') origig_sender = quote.sender_id if origin_msg == '': - return await bot.send(event, await messagechain_builder(text='只能截图文本哦')) + # return await bot.send(event, await messagechain_builder(text='只能截图文本哦')) + return await messagechain_sender(event=event, msg=await messagechain_builder(text='只能截图文本哦')) headimg = await get_head_sculpture(origig_sender) headimg = headimg.resize((default_fontsize * 5, default_fontsize * 5), Image.ANTIALIAS) memberinfo = await bot.get_group_member(group=event.group.id, id_=origig_sender) # 获取群友群信息 @@ -231,7 +233,8 @@ async def groupmessage_screenshot(event: GroupMessage): msgchain = await messagechain_builder(text='消息似乎太久了,找不到完整的了', imgbase64=imgcontent) else: msgchain = await messagechain_builder(imgbase64=imgcontent) - res = await bot.send(event, msgchain) + res = await messagechain_sender(event=event, msg=msgchain) if res == -1: - await bot.send(event, await messagechain_builder(text='截图发送失败')) + # await bot.send(event, await messagechain_builder(text='截图发送失败')) + return await messagechain_sender(event=event, msg=await messagechain_builder(text='截图发送失败')) return diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire21.gif b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire21.gif new file mode 100644 index 0000000..fa07909 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire21.gif differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire34.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire34.jpg new file mode 100644 index 0000000..7d9e3fd Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire34.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire35.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire35.jpg new file mode 100644 index 0000000..e877cb2 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire35.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire36.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire36.jpg new file mode 100644 index 0000000..2ef43af Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire36.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire37.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire37.jpg new file mode 100644 index 0000000..2269cc6 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire37.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire38.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire38.jpg new file mode 100644 index 0000000..9b926c6 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire38.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire39.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire39.jpg new file mode 100644 index 0000000..851c208 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire39.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire40.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire40.jpg new file mode 100644 index 0000000..0543711 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire40.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire41.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire41.jpg new file mode 100644 index 0000000..7455531 Binary files /dev/null and b/plugin/LocalImageAutoSender/Image/Cheshire/Cheshire41.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire0.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire0.jpg index 0543711..aa622e3 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire0.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire0.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire1.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire1.jpg index 57e7e70..d103e58 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire1.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire1.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire10.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire10.jpg index 739bbd2..628c056 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire10.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire10.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire11.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire11.jpg index 1d5fd77..3b9db52 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire11.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire11.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire12.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire12.jpg index 8031fb1..f9e70cf 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire12.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire12.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire13.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire13.jpg index 40f9d42..85d9593 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire13.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire13.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire14.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire14.jpg index 4374e84..57e7e70 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire14.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire14.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire15.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire15.jpg index 40f9d42..706914c 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire15.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire15.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire16.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire16.jpg index 7d9e3fd..b9379f9 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire16.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire16.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire17.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire17.jpg index 828bd66..0dc22f2 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire17.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire17.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire18.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire18.jpg index 9d96ff6..739bbd2 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire18.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire18.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire19.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire19.jpg index cc324f3..1d5fd77 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire19.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire19.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire2.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire2.jpg index 686b6e5..2c7e5a2 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire2.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire2.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire20.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire20.jpg index 8fedc61..8031fb1 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire20.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire20.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire21.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire21.jpg deleted file mode 100644 index 93e0210..0000000 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire21.jpg and /dev/null differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire22.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire22.jpg index eac087a..40f9d42 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire22.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire22.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire23.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire23.jpg index b9379f9..4202b57 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire23.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire23.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire24.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire24.jpg index f392a20..4374e84 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire24.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire24.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire25.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire25.jpg index 4abc986..9d96ff6 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire25.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire25.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire26.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire26.jpg index 13c67f4..cc324f3 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire26.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire26.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire27.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire27.jpg index 2ef43af..686b6e5 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire27.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire27.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire28.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire28.jpg index f9e70cf..628ed46 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire28.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire28.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire29.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire29.jpg index 4202b57..8fedc61 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire29.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire29.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire3.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire3.jpg index 2269cc6..09094f1 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire3.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire3.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire30.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire30.jpg index 9b926c6..93e0210 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire30.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire30.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire31.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire31.jpg index 851c208..f392a20 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire31.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire31.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire32.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire32.jpg index eac087a..4abc986 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire32.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire32.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire33.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire33.jpg index f392a20..13c67f4 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire33.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire33.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire4.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire4.jpg index 7455531..eac087a 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire4.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire4.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire5.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire5.jpg index 2c7e5a2..d5cb87f 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire5.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire5.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire6.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire6.jpg index 09094f1..3bb8680 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire6.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire6.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire7.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire7.jpg index d5cb87f..225c9f7 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire7.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire7.jpg differ diff --git a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire8.jpg b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire8.jpg index 225c9f7..828bd66 100644 Binary files a/plugin/LocalImageAutoSender/Image/Cheshire/cheshire8.jpg and b/plugin/LocalImageAutoSender/Image/Cheshire/cheshire8.jpg differ diff --git a/plugin/LocalImageAutoSender/cheshire.py b/plugin/LocalImageAutoSender/cheshire.py index 4e13bb3..a948d7d 100644 --- a/plugin/LocalImageAutoSender/cheshire.py +++ b/plugin/LocalImageAutoSender/cheshire.py @@ -1,3 +1,10 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 1:59 +:Update: / +:Describe: 从本地发生柴郡图 +:Version: 0.0.1 +""" import os import random import re diff --git a/plugin/LocalImageAutoSender/imageRenameUtil.py b/plugin/LocalImageAutoSender/imageRenameUtil.py index a35c34f..50acfc1 100644 --- a/plugin/LocalImageAutoSender/imageRenameUtil.py +++ b/plugin/LocalImageAutoSender/imageRenameUtil.py @@ -1,13 +1,30 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 1:59 +:Update: / +:Describe: 一个不成熟的文件自动命名工具 +:Version: 0.0.1 +:HowToUse: 例:命令行中进入Cheshire文件夹,运行cmd,输入 'python xxxx/imageRenameUtil.py',再输入Cheshire,所有文件自动重命名 +""" import os # files = os.listdir("") i = 0 +foldername = input("请输入父文件夹名字") +# for file in os.listdir(): + +downline = False for parent, dirnames, filenames in os.walk("."): + if os.path.exists(f'{foldername}{0}.{filenames[0].split(".")[-1]}'): + downline = True for filename in filenames: # print("parent is: " + parent) # print("filename is: " + filename) - print(os.path.join(parent, filename)) # 输出rootdir路径下所有文件(包含子文件)信息 - newName = f'cheshire{i}.{filename.split(".")[1]}' + # print(os.path.join(parent, filename)) # 输出rootdir路径下所有文件(包含子文件)信息 + if downline: + newName = f'{foldername}-{i}.{filename.split(".")[-1]}' + else: + newName = f'{foldername}{i}.{filename.split(".")[-1]}' os.rename(os.path.join(parent, filename), os.path.join(parent, newName)) i = i + 1 diff --git a/plugin/LocalImageAutoSender/longtu.py b/plugin/LocalImageAutoSender/longtu.py index 0f6a99d..5d60a61 100644 --- a/plugin/LocalImageAutoSender/longtu.py +++ b/plugin/LocalImageAutoSender/longtu.py @@ -1,3 +1,10 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 2:01 +:Update: / +:Describe: 龙图发射器 +:Version: 0.0.1 +""" import os import random import re @@ -23,14 +30,13 @@ @bot.on(GroupMessage) async def dragon_img(event: GroupMessage): """ - 其他网站找来的龙图 + 发送找来的龙图 """ if not _enable: return if not _setting['silence']: if event.group.id in _silencegroup: return - if event.sender.id in _blacklist: return msg = "".join(map(str, event.message_chain[Plain])) diff --git a/plugin/MajSoulInfo/bot_majsoul.py b/plugin/MajSoulInfo/bot_majsoul.py index 459fd4d..7c37eef 100644 --- a/plugin/MajSoulInfo/bot_majsoul.py +++ b/plugin/MajSoulInfo/bot_majsoul.py @@ -24,8 +24,10 @@ __all__ = ['disableqhplugin', 'enableqhplugin', 'qhpt', 'getrecentqhpaipu', 'getplayerdetails', 'getqhmonthreport', 'getqhwatcher', 'addmajsoulwatch', 'delmajsoulwatch', 'qhdrawcards', 'getmyqhdrawcards', - 'clearmajsoulwatcher', 'clearmajsoulgroupwatcher', 'qhaddtag', 'qhdeltag', 'qhtagoperate', 'qhlisttag', 'asyqh_autopaipu', - 'freshqhpaipu', 'game_guan_wang', 'qhbind', 'qhbind_operation', 'get_player_detail_website', 'qhgroupauthentication'] + 'clearmajsoulwatcher', 'clearmajsoulgroupwatcher', 'qhaddtag', 'qhdeltag', 'qhtagoperate', 'qhlisttag', + 'asyqh_autopaipu', + 'freshqhpaipu', 'game_guan_wang', 'qhbind', 'qhbind_operation', 'get_player_detail_website', + 'qhgroupauthentication'] _admin = config.get('admin', []) _master = config.get('master', 1215791340) @@ -595,9 +597,10 @@ async def get_player_detail_website(event: GroupMessage): elif m.group(1) == '天凤': await messagechain_sender(event=event, msg='https://nodocchi.moe/tenhoulog/') if msg.strip().lower() == "mortal": - await messagechain_sender(event=event,msg='https://mjai.ekyu.moe') + await messagechain_sender(event=event, msg='https://mjai.ekyu.moe') return + async def asyqh_autopaipu(): """结合scheduler自定定时刷新数据库""" if not _qhsettings.get('silence_CLI', False): @@ -653,7 +656,6 @@ async def initialization(_): await majsoul.freshdb_when_start() await asyncio.sleep(240) - if _qhsettings.get('autoquery', False): _searchfrequency = int(_qhsettings.get("searchfrequency", 6)) if int(_searchfrequency) < 1 or int(_searchfrequency) > 29: diff --git a/plugin/MajSoulInfo/majsoulinfo.py b/plugin/MajSoulInfo/majsoulinfo.py index dd2d203..22fe417 100644 --- a/plugin/MajSoulInfo/majsoulinfo.py +++ b/plugin/MajSoulInfo/majsoulinfo.py @@ -1518,8 +1518,8 @@ def levelswitch(level, score, select_type='三麻', separator=':', space_length= else: for i in range(space_length): space += " " - stage_level = int(str(level)[2]) - 3 # 大段:士、杰、豪、圣、魂 - score_level = int(str(level)[3:]) - 1 #当前小段:一二三 (魂天1-20) + stage_level = int(str(level)[2]) - 3 # 大段:士、杰、豪、圣、魂 + score_level = int(str(level)[3:]) - 1 # 当前小段:一二三 (魂天1-20) maxscore = 2000 msg = "" if stage_level < 3: @@ -1790,7 +1790,7 @@ async def query_pt_byid(playerid: int, searchtype: Union[str, list] = None, qq: return await messagechain_builder(at=qq, text=msg) if _config.get('broadcast', 'image').lower() in ['text', 'txt', 'str']: return await messagechain_builder(text=msg) - return await messagechain_builder(imgbase64=text_to_image(text=msg,needtobase64=True)) + return await messagechain_builder(imgbase64=text_to_image(text=msg, needtobase64=True)) async def get_monthreport_byid(player_info: dict, selecttype: Union[str, int] = 4, month: str = None, diff --git a/plugin/Petpet/gif.py b/plugin/Petpet/gif.py index c924488..890051d 100644 --- a/plugin/Petpet/gif.py +++ b/plugin/Petpet/gif.py @@ -16,7 +16,9 @@ from mirai import MessageChain, Plain, Image, GroupMessage, At from mirai.models import NudgeEvent from core import bot, config, replydata, commandpre, commands_map +from utils import root_logger from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender blacklist = config.get('blacklist', []) __all__ = ['nudge_petpet'] @@ -168,11 +170,10 @@ async def petpet(member_id, flip=False, squish=0, fps=15) -> None: @bot.on(NudgeEvent) async def nudge_petpet(event: NudgeEvent): + """检测戳一戳事件""" sender = event.from_id - if sender == bot.qq: return - if sender in blacklist: return if (not _settings['silence']) or _settings['nudgereply']: @@ -181,40 +182,32 @@ async def nudge_petpet(event: NudgeEvent): target = event.target if target == bot.qq: if sender in _admin: - await bot.send_group_message(event.subject.id, await messagechain_builder( + await messagechain_sender(grouptarget=event.subject.id, msg=await messagechain_builder( reply_choices=replydata['nudgedata']['admin'])) await petpet(target) - await bot.send_group_message(event.subject.id, - await messagechain_builder(imgpath=f'./images/PetPet/temp/tempPetPet-{target}.gif')) + await messagechain_sender(grouptarget=event.subject.id, msg=await messagechain_builder( + imgpath=f'./images/PetPet/temp/tempPetPet-{target}.gif')) else: if random.random() < _nudgeconfig['sendnudgechance']: if random.random() < _nudgeconfig['supersendnudgechance']: - await bot.send_group_message(event.subject.id, - await messagechain_builder( - reply_choices=replydata['nudgedata'][ - 'supernudgereply'], - rndimg=True)) + await messagechain_sender(grouptarget=event.subject.id, msg=await messagechain_builder( + reply_choices=replydata['nudgedata']['supernudgereply'], + rndimg=True)) for i in range(_nudgeconfig['supernudgequantity']): await bot.send_nudge(subject=event.subject.id, target=sender, kind='Group') return else: await bot.send_nudge(subject=event.subject.id, target=sender, kind='Group') - return await bot.send_group_message(event.subject.id, - await messagechain_builder( - reply_choices=replydata['nudgedata'][ - 'nudgereply'], - rndimg=True)) + return await messagechain_sender(grouptarget=event.subject.id, + msg=await messagechain_builder( + reply_choices=replydata['nudgedata']['nudgereply'], + rndimg=True)) else: - return await bot.send_group_message(event.subject.id, - MessageChain( - [Plain( - random.choice( - replydata['nudgedata']['other']))])) + return await messagechain_sender(grouptarget=event.subject.id, + msg=random.choice(replydata['nudgedata']['other'])) else: await petpet(target) - await bot.send_group_message(event.subject.id, - MessageChain( - Image(path=f'./images/PetPet/temp/tempPetPet-{target}.gif'))) + await messagechain_sender(grouptarget=event.subject.id, msg=MessageChain(Image(path=f'./images/PetPet/temp/tempPetPet-{target}.gif'))) return @@ -226,9 +219,10 @@ async def touchhead(event: GroupMessage): if At in event.message_chain: target = event.message_chain.get_first(At).target await petpet(target) - if await bot.send(event, - MessageChain(Image(path=f'./images/PetPet/temp/tempPetPet-{target}.gif'))) == -1: + if await messagechain_sender(event=event, msg=MessageChain( + Image(path=f'./images/PetPet/temp/tempPetPet-{target}.gif'))) == -1: print('摸头发送失败') + root_logger.error('摸头发送失败') # else: # target = m.group(2) # await petpet(target) diff --git a/plugin/Remake/remake.py b/plugin/Remake/remake.py index 60a3566..411d89e 100644 --- a/plugin/Remake/remake.py +++ b/plugin/Remake/remake.py @@ -15,6 +15,7 @@ from core import bot, commandpre, add_help, config from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender from utils.bufferpool import * from utils.cfg_loader import read_file @@ -197,9 +198,9 @@ async def getremakeimg(event: GroupMessage): if m: senderid = event.sender.id if senderid in _blackuser: - return await bot.send(event, await messagechain_builder(text='你已被列入黑名单', at=senderid)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text='你已被列入黑名单', at=senderid)) if not cmdbuffer.updategroupcache(GroupCommand(event.group.id, senderid, 'remake')): - return await bot.send(event, await messagechain_builder(text="好快的重开", at=senderid)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text="好快的重开", at=senderid)) _today = time.strftime('%Y%m%d', time.localtime()) if _remake_member.get(senderid, None) is None: _remake_member[senderid] = dict(time=_today, remakecount=0) @@ -208,8 +209,9 @@ async def getremakeimg(event: GroupMessage): _remake_member[senderid] = dict(time=_today, remakecount=1) else: if member_info['remakecount'] >= _cfg['remake_perday']: - return await bot.send(event, - await messagechain_builder(text=f'每天只能重开{_cfg["remake_perday"]}次哦', at=senderid)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text=f'每天只能重开{_cfg["remake_perday"]}次哦', + at=senderid)) member_info['remakecount'] += 1 if m.group(2): basic_score = int(m.group(2)) @@ -221,8 +223,8 @@ async def getremakeimg(event: GroupMessage): worlddifficulty = None b64 = create_remakeimg(senderid, basic_score=basic_score, worlddifficulty=worlddifficulty) - # await bot.send(event, MessageChain(Image(path=f'./images/Remake/{senderid}.png'))) - await bot.send(event, MessageChain(Image(base64=b64))) + # await messagechain_sender(event=)(eventmsg=, MessageChain(Image(path=f'./images/Remake/{senderid}.png'))) + await messagechain_sender(event=event, msg=MessageChain(Image(base64=b64))) return diff --git a/plugin/RichiMahjongMatchControl/match_bot.py b/plugin/RichiMahjongMatchControl/match_bot.py index c71fd1a..4897343 100644 --- a/plugin/RichiMahjongMatchControl/match_bot.py +++ b/plugin/RichiMahjongMatchControl/match_bot.py @@ -2,7 +2,7 @@ :Author: NekoRabi :Create: 2022/10/15 21:19 :Update: / -:Describe: 比赛机器人 +:Describe: 模拟比赛机器人,但几乎没有用 :Version: 0.0.1 """ @@ -28,14 +28,14 @@ async def create_match(event: GroupMessage): m = re.match(fr"^{commandpre}创建比赛\s*(\w+)\s*(\d{{4}}-\d{{2}}-\d{{2}})\s*(\w+)?$", msg.strip()) if m: if not is_having_admin_permission(event): - return await bot.send(event, await messagechain_builder(text="仅管理员可以创建新比赛", at=event.sender.id)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text="仅管理员可以创建新比赛", at=event.sender.id)) if m.group(2): description = m.group(3) else: description = "" res = MatchOperator.register_match(sourcegroup=event.group.id, host=event.sender.id, matchname=m.group(1), ddl=m.group(2), description=description) - await bot.send(event, await messagechain_builder(text=res)) + await messagechain_sender(event=event, msg=await messagechain_builder(text=res)) @bot.on(GroupMessage) @@ -52,7 +52,7 @@ async def join_match(event: GroupMessage): teamname = matchname res = MatchOperator.join_match(matchname=m.group(1), qqid=event.sender.id, teamname=teamname, position=position, playername=playername) - await bot.send(event, await messagechain_builder(text=res)) + await messagechain_sender(event=event, msg=await messagechain_builder(text=res)) @bot.on(GroupMessage) @@ -87,7 +87,7 @@ async def get_teammembers(event: GroupMessage): msg += f"{position}({qqs})\n" else: msg += f"{position}{players}\n" - await bot.send(event, await messagechain_builder(text=msg[:-1])) + await messagechain_sender(event=event, msg=await messagechain_builder(text=msg[:-1])) @bot.on(GroupMessage) @@ -107,9 +107,9 @@ async def remove_teammate(event: GroupMessage): _id = int(_id) except ValueError: msg = "请输入正确的qq,如需输入玩家名,请在玩家名前加上' %playername%= '" - return await bot.send(event, await messagechain_builder(text=msg)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=msg)) res = MatchOperator.remove_teammate(matchname=matchname, teamname=teamname, _id=_id, position=position) - return await bot.send(event, await messagechain_builder(text=res)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=res)) @bot.on(GroupMessage) @@ -123,4 +123,4 @@ async def create_team(event: GroupMessage): description = m.group(3) res = MatchOperator.create_team(matchname=matchname, teamname=teamname, description=description, leader=event.sender.id) - return await bot.send(event, await messagechain_builder(text=res)) + return await messagechain_sender(event=event, msg=await messagechain_builder(text=res)) diff --git a/plugin/Setu/setu.py b/plugin/Setu/setu.py index 615d9d8..13bc678 100644 --- a/plugin/Setu/setu.py +++ b/plugin/Setu/setu.py @@ -1,3 +1,10 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 2:11 +:Update: / +:Describe: 从 liliconAPI 搜索色图 +:Version: 0.0.1 +""" import asyncio import base64 import os.path @@ -13,6 +20,7 @@ from mirai import GroupMessage, Plain from core import bot, commandpre, commands_map, config from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender from utils.bufferpool import * from utils.cfg_loader import write_file @@ -116,12 +124,12 @@ class SetuFinder: recalltime = 30 def __init__(self, botname, _config: dict): - self.r18enable = _config.get('r18enable',False) - self.r18groups = _config.get('r18groups',[]) - self.allowsearchself = _config.get('allowsearchself',False) - self.recalltime = _config.get('recalltime',30) + self.r18enable = _config.get('r18enable', False) + self.r18groups = _config.get('r18groups', []) + self.allowsearchself = _config.get('allowsearchself', False) + self.recalltime = _config.get('recalltime', 30) self.botname = botname - self.err_opt = _config.get('err_opt',True) + self.err_opt = _config.get('err_opt', True) async def getsetu(self, description, groupid, num=1) -> dict: if not num: @@ -164,14 +172,14 @@ async def enablesetu(event: GroupMessage): if event.sender.id in admin: groupid = event.group.id if groupid in setu_config.get('setugroups'): - await bot.send(event, await messagechain_builder(text="本群已开启色图")) + await messagechain_sender(event=event, msg=await messagechain_builder(text="本群已开启色图")) else: setu_config.get('setugroups').append(groupid) # with open(r'./config/config.yml', 'w', encoding='utf-8') as file: # yaml.dump(config, file, allow_unicode=True) # w_cfg_to_file(content=config, path=r'./config/config.yml') write_file(content=setu_config, path=r'./config/Setu/config.yml') - await bot.send(event, await messagechain_builder(text="色图开启成功")) + await messagechain_sender(event=event, msg=await messagechain_builder(text="色图开启成功")) @bot.on(GroupMessage) @@ -189,9 +197,9 @@ async def disablesetu(event: GroupMessage): # yaml.dump(config, file, allow_unicode=True) # w_cfg_to_file(content=config, path=r'./config/config.yml') write_file(content=setu_config, path=r'./config/Setu/config.yml') - await bot.send(event, await messagechain_builder(text="色图已关闭")) + await messagechain_sender(event=event, msg=await messagechain_builder(text="色图已关闭")) else: - await bot.send(event, await messagechain_builder(text="本群色图已关闭")) + await messagechain_sender(event=event, msg=await messagechain_builder(text="本群色图已关闭")) @bot.on(GroupMessage) @@ -201,7 +209,7 @@ async def randomsetu(event: GroupMessage): m = re.match( fr"^随机[涩色]图(网[址站]?)?", msg.strip()) if m: - await bot.send(event, await messagechain_builder(text='https://iw233.cn/API/Random.php')) + await messagechain_sender(event=event, msg=await messagechain_builder(text='https://iw233.cn/API/Random.php')) return @@ -221,40 +229,43 @@ async def getsomesetu(event: GroupMessage): # if random.random() * 100 < 10: if random.random() * 100 < 0: # print(f"发出对{senderid}的少冲提醒") - # await bot.send(event, [At(senderid), " 能不能少冲点啊,这次就不给你发了"]) + # await messagechain_sender(event=event,msg=await messagechain_builder([At(senderid), " 能不能少冲点啊,这次就不给你发了"]) pass else: if setu_config.get('enable', False) and event.group.id in setu_config.get('setugroups'): if not cmdbuffer.updategroupcache(GroupCommand(event.group.id, senderid, 'setu')): - return bot.send(event, await messagechain_builder(text="你冲的频率太频繁了,休息一下吧", at=senderid)) + return messagechain_sender(event=event, + msg=await messagechain_builder(text="你冲的频率太频繁了,休息一下吧", at=senderid)) try: imginfo = await stfinder.getsetu( m1.group(2), groupid=event.group.id) if imginfo['FoundError']: - return await bot.send(event, await messagechain_builder(at=senderid, text=imginfo['ErrorMsg'])) + return await messagechain_sender(event=event, msg=await messagechain_builder(at=senderid, + text=imginfo[ + 'ErrorMsg'])) # imgb64 = download_setu_base64_from_url(imginfo['url']) - res = await bot.send(event, await messagechain_builder(imgurl=imginfo['url'])) - # res = await bot.send(event,await messagechain_builder(imgbase64=imgb64)) + res = await messagechain_sender(event=event, msg=await messagechain_builder(imgurl=imginfo['url'])) + # res = await messagechain_sender(event=)(evenmsg=t,await messagechain_builder(imgbase64=imgb64)) if res == -1: - await bot.send(event, f"色图发送失败!这肯定不是{config['botconfig']['botname']}的问题!") + await messagechain_sender(event=event, msg=f"色图发送失败!这肯定不是{config['botconfig']['botname']}的问题!") elif stfinder.recalltime != -1: await asyncio.sleep(stfinder.recalltime) await bot.recall(res) except Exception as e: print(f"色图请求失败:{e}") if setu_config.get('err_opt', True): - await bot.send(event, - await messagechain_builder( - text=f"出错了!这肯定不是{config['botconfig']['botname']}的问题!")) + await messagechain_sender(event=event, msg=await messagechain_builder( + text=f"出错了!这肯定不是{config['botconfig']['botname']}的问题!")) elif m2: if random.random() * 100 < 0: # print(f"发出对{senderid}的少冲提醒") - # await bot.send(event, [At(senderid), " 能不能少冲点啊,这次就不给你发了"]) + # await messagechain_sender(event=event,msg=await messagechain_builder([At(senderid), " 能不能少冲点啊,这次就不给你发了"]) pass else: if setu_config.get('enable', False) and event.group.id in setu_config.get('setugroups'): if not cmdbuffer.updategroupcache(GroupCommand(event.group.id, senderid, 'setu')): - return bot.send(event, await messagechain_builder(at=senderid, text="你冲的频率太频繁了,休息一下吧")) + return messagechain_sender(event=event, + msg=await messagechain_builder(at=senderid, text="你冲的频率太频繁了,休息一下吧")) setu_num = m2.group(1) if not setu_num: setu_num = 1 @@ -264,18 +275,19 @@ async def getsomesetu(event: GroupMessage): imginfo = await stfinder.getsetu( m2.group(2), event.group.id, setu_num) if imginfo['FoundError']: - return await bot.send(event, await messagechain_builder(at=senderid, text=imginfo['ErrorMsg'])) - res = await bot.send(event, await messagechain_builder(imgurl=imginfo['url'])) - # await bot.send(event, MessageChain([Image(url=imginfo['url'])])) + return await messagechain_sender(event=event, msg=await messagechain_builder(at=senderid, + text=imginfo[ + 'ErrorMsg'])) + res = await messagechain_sender(event=event, msg=await messagechain_builder(imgurl=imginfo['url'])) + # await messagechain_sender(event=)(evenmsg=t, MessageChain([Image(url=imginfo['url'])])) if res == -1: - await bot.send(event, f"色图发送失败!这肯定不是{config['botconfig']['botname']}的问题!") + await messagechain_sender(event=event, msg=f"色图发送失败!这肯定不是{config['botconfig']['botname']}的问题!") elif stfinder.recalltime != -1: await asyncio.sleep(stfinder.recalltime) await bot.recall(res) except Exception as e: print(f"色图请求失败:{e}") if setu_config.get('err_opt', True): - await bot.send(event, - await messagechain_builder( - text=f"出错了!这肯定不是{config['botconfig']['botname']}的问题!")) + await messagechain_sender(event=event, msg=await messagechain_builder( + text=f"出错了!这肯定不是{config['botconfig']['botname']}的问题!")) return diff --git a/plugin/Tarot/__init__.py b/plugin/Tarot/__init__.py index 66edfba..5c330c1 100644 --- a/plugin/Tarot/__init__.py +++ b/plugin/Tarot/__init__.py @@ -1 +1 @@ -from plugin.Tarot.tarot import * +# from plugin.Tarot.tarot import * diff --git a/plugin/Tarot/tarot.py b/plugin/Tarot/tarot.py index 63e3e48..ea9b7e1 100644 --- a/plugin/Tarot/tarot.py +++ b/plugin/Tarot/tarot.py @@ -1,8 +1,8 @@ """ :Author: NekoRabi -:Update Time: 2022/8/16 20:02 -:Describe: 塔罗牌抽卡 -:Version: 0.0.1 +:Update Time: 2023/6/16 +:Describe: 塔罗牌抽卡,现已经集成进签到 +:Version: 0.0.2 """ import os diff --git a/plugin/Template/__init__.py b/plugin/Template/__init__.py index 7e70548..3f1e9c4 100644 --- a/plugin/Template/__init__.py +++ b/plugin/Template/__init__.py @@ -10,7 +10,7 @@ # 把你写的插件文件,按照 plugin.包名.文件名 的形式引入 # from plugin.Template.file_init import * -#from plugin.Template.helloworld import * +# from plugin.Template.helloworld import * # print("插件加载成功") diff --git a/plugin/Template/helloworld.py b/plugin/Template/helloworld.py index e7f8826..b7bd0ef 100644 --- a/plugin/Template/helloworld.py +++ b/plugin/Template/helloworld.py @@ -22,6 +22,7 @@ # 还可以import其他的模块,比如 工具类,sqlite3,asyncio,time,math 等等 +# 推荐使用 utils.MessageChainBuilder和 utils.MessageChainSender 中的方法来构造和发送消息链 async def asy_hello(): """ diff --git a/plugin/TenHouPlugin/th_bot.py b/plugin/TenHouPlugin/th_bot.py index 14bac0a..cdf9fc3 100644 --- a/plugin/TenHouPlugin/th_bot.py +++ b/plugin/TenHouPlugin/th_bot.py @@ -44,9 +44,9 @@ async def ranktenhouplayer(event: GroupMessage): m = re.match(fr"^{commandpre}{_cmd.get('thpt')}", msg.strip()) if m: if not cmdbuffer.updategroupcache(GroupCommand(event.group.id, event.sender.id, 'thpt')): - return messagechain_sender(event=event, - msg=await messagechain_builder(text="你查的太频繁了,休息一下好不好", rndimg=True, - at=event.sender.id)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text="你查的太频繁了,休息一下好不好", rndimg=True, + at=event.sender.id)) reset = True if m.group(3): reset = m.group(3) @@ -85,11 +85,16 @@ async def deltenhouwatcher(event: GroupMessage): m = re.match(fr"^{commandpre}{_cmd.get('delwatch')}", msg.strip()) if m: if is_having_admin_permission(event): - await bot.send(event, - tenhou.removethwatch(playername=m.group(2), groupid=event.group.id, - isadmin=is_having_admin_permission(event))) + # await bot.send(event, + # tenhou.removethwatch(playername=m.group(2), groupid=event.group.id, + # isadmin=is_having_admin_permission(event))) + await messagechain_sender(event=event, msg=await messagechain_builder( + text=tenhou.removethwatch(playername=m.group(2), groupid=event.group.id, + isadmin=is_having_admin_permission(event)))) else: - await bot.send(event, await messagechain_builder(at=event.sender.id, text=" 抱歉,只有管理员才能这么做哦")) + # await bot.send(event, await messagechain_builder(at=event.sender.id, text=" 抱歉,只有管理员才能这么做哦")) + await messagechain_sender(event=event, + msg=await messagechain_builder(text='抱歉,此权限需要管理员', at=event.sender.id)) @bot.on(GroupMessage) @@ -98,9 +103,13 @@ async def cleartenhouwatcher(event: GroupMessage): m = re.match(fr"^{commandpre}{_cmd.get('clearwatch')}", msg.strip()) if m: if is_having_admin_permission(event): - await bot.send(event, tenhou.clearthwatch(groupid=event.group.id)) + # await bot.send(event, tenhou.clearthwatch(groupid=event.group.id)) + await messagechain_sender(event=event, + msg=await messagechain_builder(text=tenhou.clearthwatch(groupid=event.group.id))) else: - await bot.send(event, await messagechain_builder(at=event.sender.id, text=" 抱歉,只有管理员才能这么做哦")) + # await bot.send(event, await messagechain_builder(at=event.sender.id, text=" 抱歉,只有管理员才能这么做哦")) + await messagechain_sender(event=event, + msg=await messagechain_builder(text='抱歉,此权限需要管理员', at=event.sender.id)) @bot.on(FriendMessage) @@ -110,9 +119,14 @@ async def friend_cleartenhouwatcher(event: GroupMessage): if m: if is_having_admin_permission(event): if m.group(1): - await bot.send(event, tenhou.clearthwatch(groupid=int(m.group(1)))) + # await bot.send(event, tenhou.clearthwatch(groupid=int(m.group(1)))) + await messagechain_sender(event=event, + msg=await messagechain_builder( + text=tenhou.clearthwatch(groupid=int(m.group(1))))) else: - await bot.send(event, "指令执行错误") + # await bot.send(event, "指令执行失败,请检查输入") + await messagechain_sender(event=event, + msg=await messagechain_builder(text="指令执行失败,请检查输入")) @bot.on(GroupMessage) @@ -121,7 +135,9 @@ async def gettenhouwatcher(event: GroupMessage): # 匹配指令 m = re.match(fr"^{commandpre}{_cmd.get('getwatch')}", msg.strip()) if m: - await bot.send(event, tenhou.getthwatch(event.group.id)) + # await bot.send(event, tenhou.getthwatch(event.group.id)) + await messagechain_sender(event=event, + msg=await messagechain_builder(text=tenhou.getthwatch(event.group.id))) @bot.on(GroupMessage) @@ -130,9 +146,9 @@ async def thmonthreport(event: GroupMessage): m = re.match(fr"^{commandpre}{_cmd.get('thyb')}", msg.strip()) if m: if not cmdbuffer.updategroupcache(GroupCommand(event.group.id, event.sender.id, 'thpt')): - return messagechain_sender(event=event, - msg=await messagechain_builder(text="你查的太频繁了,休息一下好不好", rndimg=True, - at=event.sender.id)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text="你查的太频繁了,休息一下好不好", rndimg=True, + at=event.sender.id)) searchtype = m.group(3) year = m.group(5) month = m.group(6) diff --git a/plugin/TencentCloudAPI/bot_TencentCloudAPI.py b/plugin/TencentCloudAPI/bot_TencentCloudAPI.py index 78ddaa3..3cf4a7a 100644 --- a/plugin/TencentCloudAPI/bot_TencentCloudAPI.py +++ b/plugin/TencentCloudAPI/bot_TencentCloudAPI.py @@ -1,9 +1,17 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 2:18 +:Update: / +:Describe: 腾讯云接口API +:Version: 0.0.1 +""" import re from mirai import GroupMessage, Plain, FriendMessage, Voice from core import config, bot, commandpre, commands_map from plugin.TencentCloudAPI.text_to_voice import VoiceCreater from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender from utils.cfg_loader import * __all__ = [] @@ -13,7 +21,7 @@ _secretId = _cfg.get('secretId', None) _secretKey = _cfg.get('secretKey', None) if _secretId: - if isinstance(_secretId,str): + if isinstance(_secretId, str): if _secretId.strip() == '': __plugin_enable = False else: @@ -22,7 +30,7 @@ __plugin_enable = False if _secretKey: - if isinstance(_secretKey,str): + if isinstance(_secretKey, str): if _secretKey.strip() == '': __plugin_enable = False else: @@ -58,12 +66,13 @@ async def send_group_voice(event: GroupMessage): return text = m.group(1).strip() if len(text) > 40: - return await bot.send(event, await messagechain_builder(text="文本太长啦", rndimg=True)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text="文本太长啦", rndimg=True)) voice = getbase64voice(text) if not voice['error']: - return await bot.send(event, Voice(base64=voice['file'])) - # return await bot.send(event, await Voice.from_local(content=voice['file'])) # 有问题 - # return await bot.send(event, await Voice.from_local(filename=f'./data/audio/{text}.{vc.codec}')) + return await messagechain_sender(event=event, msg=Voice(base64=voice['file'])) + # return await messagechain_sender(event=event,msg= await Voice.from_local(content=voice['file'])) # 有问题 + # return await messagechain_sender(event=event,msg= await Voice.from_local(filename=f'./data/audio/{text}.{vc.codec}')) @bot.on(FriendMessage) @@ -78,12 +87,13 @@ async def send_voice_to_group(event: FriendMessage): groupid = int(m.group(1)) text = m.group(2).strip() if len(text) > 40: - return await bot.send(event, await messagechain_builder(text="文本太长啦", rndimg=True)) + return await messagechain_sender(event=event, + msg=await messagechain_builder(text="文本太长啦", rndimg=True)) voice = getbase64voice(text) if not voice['error']: - return await bot.send_group_message(groupid, Voice(base64=voice['file'])) - # return await bot.send(event, await Voice.from_local(content=voice['file'])) # 有问题 - # return await bot.send(event, await Voice.from_local(filename=f'./data/audio/{text}.{vc.codec}')) + return await messagechain_sender(grouptarget=groupid, msg=Voice(base64=voice['file'])) + # return await messagechain_sender(event=event,msg= await Voice.from_local(content=voice['file'])) # 有问题 + # return await messagechain_sender(event=event,msg= await Voice.from_local(filename=f'./data/audio/{text}.{vc.codec}')) if len(__all__) > 0: print(f' |---已启用的腾讯云API服务{__all__}') diff --git a/plugin/TencentCloudAPI/text_to_voice.py b/plugin/TencentCloudAPI/text_to_voice.py index 084f2ba..24ebcc2 100644 --- a/plugin/TencentCloudAPI/text_to_voice.py +++ b/plugin/TencentCloudAPI/text_to_voice.py @@ -1,3 +1,10 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 2:18 +:Update: / +:Describe: 语音转文本功能 +:Version: 0.0.1 +""" import json import base64 import time diff --git a/plugin/__init__.py b/plugin/__init__.py index f5062f6..743387c 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -10,31 +10,31 @@ import logging import os -_plugins = os.listdir(r'./plugin') -# print(plugins) -for name in _plugins: - if os.path.isdir(f'./plugin/{name}'): - if os.path.exists(f'./plugin/{name}/__init__.py'): - print(f'加载插件 {name}') - logging.info(f'加载插件 {name}') - exec(f"from plugin.{name} import *") - -print('\n所有插件加载完毕') -logging.info('所有插件加载完毕') +# _plugins = os.listdir(r'./plugin') +# # print(plugins) +# for name in _plugins: +# if os.path.isdir(f'./plugin/{name}'): +# if os.path.exists(f'./plugin/{name}/__init__.py'): +# print(f'加载插件 {name}') +# logging.info(f'加载插件 {name}') +# exec(f"from plugin.{name} import *") +# +# print('\n所有插件加载完毕') +# logging.info('所有插件加载完毕') # 'Else' -# from plugin.AlarmClock import * -# from plugin.AutoReply import * -# from plugin.BilibiliPlugin import * -# from plugin.draw_wife import * -# from plugin.ImgGenerator import * -# from plugin.LocalImageAutoSender import * -# from plugin.MajSoulInfo import * -# from plugin.paili_analysis import * -# from plugin.Petpet import * -# from plugin.Remake import * -# from plugin.RichiMahjongMatchControl import * -# from plugin.Setu import * -# from plugin.TencentCloudAPI import * -# from plugin.TenHouPlugin import * +from plugin.AlarmClock import * +from plugin.AutoReply import * +from plugin.BilibiliPlugin import * +from plugin.draw_wife import * +from plugin.ImgGenerator import * +from plugin.LocalImageAutoSender import * +from plugin.MajSoulInfo import * +from plugin.paili_analysis import * +from plugin.Petpet import * +from plugin.Remake import * +from plugin.RichiMahjongMatchControl import * +from plugin.Setu import * +from plugin.TencentCloudAPI import * +from plugin.TenHouPlugin import * diff --git a/plugin/draw_wife/__init__.py b/plugin/draw_wife/__init__.py index 5f603ad..fa36af1 100644 --- a/plugin/draw_wife/__init__.py +++ b/plugin/draw_wife/__init__.py @@ -1 +1 @@ -from plugin.draw_wife.drawwife import * \ No newline at end of file +# from plugin.draw_wife.drawwife import * diff --git a/plugin/draw_wife/drawwife.py b/plugin/draw_wife/drawwife.py index 6f21746..a40f618 100644 --- a/plugin/draw_wife/drawwife.py +++ b/plugin/draw_wife/drawwife.py @@ -1,3 +1,9 @@ +""" +:Author: NekoRabi +:Update Time: 2023/6/16 2:09 +:Describe: 抽老婆插件,已经不用了,远不如AI绘画和色图 +:Version: 0.0.0 +""" import base64 import random import aiohttp @@ -9,6 +15,8 @@ from utils.MessageChainBuilder import messagechain_builder from PIL import Image, ImageDraw +from utils.MessageChainSender import messagechain_sender + user_agent_list = [ "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", @@ -22,7 +30,8 @@ asytimeout = aiohttp.ClientTimeout(total=60) -__all__ = ['drawwife'] +# __all__ = ['drawwife'] +__all__ = [] async def download_img(url): @@ -56,8 +65,7 @@ async def drawwife(event: GroupMessage): if m: index = random.randint(1, 9999) img = await download_img(f'https://www.thiswaifudoesnotexist.net/example-{index}.jpg') - return await bot.send(event, await messagechain_builder(at=event.sender.id, - imgbase64=img)) - + return await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, + imgbase64=img)) -add_help('group', "抽老婆 : 返回一张算法随机生成的老婆\n") +# add_help('group', "抽老婆 : 返回一张算法随机生成的老婆\n") diff --git a/plugin/paili_analysis/mah.py b/plugin/paili_analysis/mah.py index b9c4124..4f94247 100644 --- a/plugin/paili_analysis/mah.py +++ b/plugin/paili_analysis/mah.py @@ -1,9 +1,17 @@ +""" +:Author: NekoRabi +:Create: 2023/6/16 2:03 +:Update: / +:Describe: 牌理分析,有错误因为不是我写的,网上找的,我也不懂,注释就是这样的 +:Version: 0.0.1 +""" import pickle from plugin.paili_analysis.utils import * from plugin.paili_analysis.dfs import * from mirai import GroupMessage, Plain from core import bot from utils.MessageChainBuilder import messagechain_builder +from utils.MessageChainSender import messagechain_sender from utils.text_to_img import text_to_image __all__ = ['paili_calculator'] @@ -178,6 +186,12 @@ async def paili_calculator(event: GroupMessage): if m: shoupai = m.group(3) try: - await bot.send(event, await messagechain_builder(at=event.sender.id, imgbase64=calc_shanten_14(shoupai),text='牌理分析仅供参考, 有bug存在错误')) + # await bot.send(event, await messagechain_builder(at=event.sender.id, imgbase64=calc_shanten_14(shoupai),text='牌理分析仅供参考, 有bug存在错误')) + await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, + imgbase64=calc_shanten_14(shoupai), + text='牌理分析仅供参考, 有bug存在错误')) except ValueError: - await bot.send(event, await messagechain_builder(at=event.sender.id, text='请输入14位手牌')) + # await bot.send(event, await messagechain_builder(at=event.sender.id, text='请输入14位手牌')) + await messagechain_sender(event=event, msg=await messagechain_builder(at=event.sender.id, + imgbase64=calc_shanten_14(shoupai), + text='请输入14位手牌'))