From 25bb845edd7e0cfd48108def8685c695c09cc260 Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Sun, 12 Jun 2022 15:32:52 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86bug?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E`=E5=A5=BD=E5=8F=8B=E3=80=81?= =?UTF-8?q?=E5=85=A5=E7=BE=A4=E5=92=8C=E9=BE=99=E7=8E=8B=E6=8F=90=E9=86=92?= =?UTF-8?q?`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Paimon_Info/__init__.py | 2 +- Paimon_Plugins/auto_handle.py | 68 ++++++++++++++++++++++++++++------- README.md | 28 +++++++++------ utils/config.py | 13 ++++--- utils/json/score.json | 2 +- 5 files changed, 83 insertions(+), 30 deletions(-) diff --git a/Paimon_Info/__init__.py b/Paimon_Info/__init__.py index 71ea77e..622ae87 100644 --- a/Paimon_Info/__init__.py +++ b/Paimon_Info/__init__.py @@ -541,7 +541,7 @@ async def _(event: MessageEvent, state: T_State, msg: Message = CommandArg()): uid = re.search(r'(?P(1|2|5)\d{8})', msg.extract_plain_text()) if uid: state['uid'] = uid.group('uid') - await update_last_query(str(event.user_id), uid) + await update_last_query(str(event.user_id), uid.group('uid')) else: user = '' for msg_seg in msg: diff --git a/Paimon_Plugins/auto_handle.py b/Paimon_Plugins/auto_handle.py index 482abd9..5143c7a 100644 --- a/Paimon_Plugins/auto_handle.py +++ b/Paimon_Plugins/auto_handle.py @@ -1,38 +1,80 @@ import random from asyncio import sleep +from pathlib import Path + +from nonebot import get_driver, on_request, on_notice +from nonebot.adapters.onebot.v11 import Bot, FriendRequestEvent, GroupRequestEvent, GroupIncreaseNoticeEvent, \ + MessageSegment, Message, FriendAddNoticeEvent, HonorNotifyEvent + from utils.config import config -from nonebot import get_driver -from nonebot.message import event_preprocessor -from nonebot.adapters.onebot.v11 import Bot, FriendRequestEvent, GroupRequestEvent +from utils.message_util import MessageBuild superuser = int(list(get_driver().config.superusers)[0]) +requests_handle = on_request(priority=5, block=True) +notice_handle = on_notice(priority=5, block=True) -@event_preprocessor + +@requests_handle.handle() async def addFriend(bot: Bot, event: FriendRequestEvent): superuser_msg = f'{event.user_id}请求添加派蒙为好友, 验证信息为:{event.comment}' if config.paimon_add_friend: superuser_msg += ',已自动同意' - await sleep(random.randint(2, 4)) + await sleep(random.randint(4, 8)) await event.approve(bot) - await sleep(random.randint(3, 6)) - await bot.send_private_msg(user_id=event.user_id, message=f'旅行者你好呀,这里是小派蒙,发送/help查看帮助哦') else: superuser_msg += ',请主人自行处理哦' - await bot.send_private_msg(user_id=superuser, message=superuser_msg) + if config.paimon_request_remind: + await bot.send_private_msg(user_id=superuser, message=superuser_msg) -@event_preprocessor +@requests_handle.handle() async def addGroup(bot: Bot, event: GroupRequestEvent): if event.sub_type != 'invite': return superuser_msg = f'{event.user_id}邀请派蒙加入群{event.group_id}' if config.paimon_add_group or event.user_id == superuser: superuser_msg += ',已自动同意' - await sleep(random.randint(2, 4)) + await sleep(random.randint(4, 8)) await event.approve(bot) - await sleep(random.randint(3, 6)) - await bot.send_group_msg(group_id=event.group_id, message=f'旅行者们大家好呀,这里是小派蒙,发送/help查看帮助哦') else: superuser_msg += ',请主人自行处理哦' - await bot.send_private_msg(user_id=superuser, message=superuser_msg) \ No newline at end of file + if config.paimon_request_remind: + await bot.send_private_msg(user_id=superuser, message=superuser_msg) + + +greet_emoticon = MessageBuild.Image(Path(__file__).parent.parent / 'res' / 'emoticons' / '派蒙-干杯.png', mode='RGBA') +honor_emoticon = MessageBuild.Image(Path(__file__).parent.parent / 'res' / 'emoticons' / '派蒙-哼哼.png', mode='RGBA') +honor2_emoticon = MessageBuild.Image(Path(__file__).parent.parent / 'res' / 'emoticons' / '派蒙-黑线.png', mode='RGBA') + + +@notice_handle.handle() +async def FriendNew(bot: Bot, event: FriendAddNoticeEvent): + await sleep(random.randint(4, 8)) + await bot.send_private_msg(user_id=event.user_id, message=Message(MessageSegment.text('旅行者你好呀~,这里是小派蒙,对我说help查看帮助吧~\n') + greet_emoticon)) + + +@notice_handle.handle() +async def GroupNewMember(bot: Bot, event: GroupIncreaseNoticeEvent): + if event.user_id == event.self_id: + await sleep(random.randint(4, 8)) + await bot.send_group_msg(group_id=event.group_id, message=Message( + MessageSegment.text('旅行者们大家好呀~,这里是小派蒙,对我说help查看帮助吧~\n') + greet_emoticon)) + elif event.group_id not in config.paimon_greet_ban: + await sleep(random.randint(4, 8)) + await bot.send_group_msg(group_id=event.group_id, message=Message( + MessageSegment.at(event.user_id) + MessageSegment.text("欢迎新旅行者哦~\n") + greet_emoticon)) + + +@notice_handle.handle() +async def GroupTalkative(bot: Bot, event: HonorNotifyEvent): + if event.group_id not in config.paimon_greet_ban and event.honor_type == 'talkative': + await sleep(random.randint(4, 8)) + if event.user_id == event.self_id: + text = random.choice(['诶嘿~本应急食品是龙王~~', '哦豁,派蒙又是龙王,你们好逊哦(', '怎么回事,你们这么多人居然说不过我一个应急食品?~', '请叫我龙王派蒙~诶嘿']) + await bot.send_group_msg(group_id=event.group_id, + message=Message(MessageSegment.text(text) + honor_emoticon)) + elif random.random() <= 0.5: + text = random.choice(['怎么这人比我派蒙话还多!!', '咦~是个话唠龙王(', '好气哦,怎么能抢我派蒙的龙王啊!!']) + await bot.send_group_msg(group_id=event.group_id, + message=Message(MessageSegment.at(event.user_id) + MessageSegment.text(text) + honor2_emoticon)) diff --git a/README.md b/README.md index fc70ed7..8ff1ade 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ + 5.27 - 新增`原神日历`[@nicklly](https://github.com/nicklly) + 5.28 - - `Paimon_Chat`聊天新增`学习群友发言`(魔改自[Pallas-Bot](https://github.com/InvoluteHell/Pallas-Bot/tree/master/src/plugins/repeater)),需安装`jieba_fast、pymongo、pypinyin依赖库`、`mongodb数据库`且在`.env.*`配置文件中添加mongodb连接参数`paimon_mongodb_url`,例如`paimon_mongodb_url=mongodb://localhost:27017/ + - `Paimon_Chat`聊天新增`学习群友发言`(魔改自[Pallas-Bot](https://github.com/InvoluteHell/Pallas-Bot/tree/master/src/plugins/repeater)),需安装`jieba_fast、pymongo、pypinyin依赖库`、`mongodb数据库`且在`.env.*`配置文件中添加mongodb连接参数`paimon_mongodb_url`,例如`paimon_mongodb_url=mongodb://localhost:27017/` + 6.3 - 新增游戏内展柜角色面板卡片,使用`更新角色面板`来获取角色,`ysd角色名`来查看角色卡片 - 修复部分不记录上次查询的uid的bug @@ -93,6 +93,9 @@ - 修复`原神猜语音`和`模拟抽卡`因`nonebot2.0.0b3`版本Union校验产生的bug,但`原神猜语音`将暂时无法私聊使用 + 6.9 - 新增`帮助菜单`指令~~(不太好看,继续美化)~~ ++ 6.12 + - 新增`云原神签到`等功能[@nicklly](https://github.com/nicklly) + - 修复部分bug,新增`好友、群新成员和龙王提醒`[#45](https://github.com/CMHopeSunshine/LittlePaimon/issues/45) ## 丨功能列表 @@ -136,7 +139,7 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); ``` -复制得到的cookie,向小派蒙发送**`添加公共ck`**和粘贴的内容,即可开始使用 +复制得到的cookie,向小派蒙发送`添加公共ck`和粘贴的内容,即可开始使用 ## 丨感谢 @@ -145,6 +148,7 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - [NoneBot2](https://github.com/nonebot/nonebot2) - 跨平台异步机器人框架 - [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) - Onebot标准的框架实现 - [西北一枝花](https://github.com/Nwflower) - 美工大大和武器攻略图提供 +- [nicklly](https://github.com/nicklly) - 原神日历、云原神等功能贡献者 - [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 抽卡和猜语音代码、资源参考 - [bluemushoom](https://bbs.nga.cn/nuke.php?func=ucp&uid=62861898) - 全角色收益曲线和参考面板攻略图来源 - [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出代码参考 @@ -156,15 +160,17 @@ javascript:(function(){prompt(document.domain,document.cookie)})(); - 如果本项目对你有帮助,给个star~~求求啦 - 部分资源使用了云存储,如果想赞助流量费用,欢迎来[爱发电](https://afdian.net/@cherishmoon),十分感谢! -| 赞助者 | 金额 | -| --------------- | ---- | -| 深海 | 10 | -| 夜空koi | 30 | -| 情话 | 20 | -| 爱发电用户_Mfms | 15 | -| 米特建木 | 10 | -| 永远的皇珈骑士 | 30 | -| 小兔和鹿 | 30 | +| 赞助者 | 金额 | +|----------------|-----| +| 深海 | 10 | +| 夜空koi | 30 | +| 情话 | 20 | +| 爱发电用户_Mfms | 15 | +| 米特建木 | 10 | +| 永远的皇珈骑士 | 30 | +| 小兔和鹿 | 30 | +| el psy congroo | 20 | +| jimjqn | 30 | ## 丨其他 diff --git a/utils/config.py b/utils/config.py index a5930ec..1833141 100644 --- a/utils/config.py +++ b/utils/config.py @@ -27,10 +27,6 @@ class PluginConfig(BaseModel): paimon_ecy_cd: int = 6 # 原神壁纸图冷却(秒) paimon_ysp_cd: int = 10 - # 是否自动通过好友请求 - paimon_add_friend: bool = False - # 是否自动通过群组请求 - paimon_add_group: bool = False # 派蒙聊天开启群组 paimon_chat_group: List[int] = [] @@ -65,6 +61,15 @@ class PluginConfig(BaseModel): # 连续主动说话最多几句话 paimon_speak_continuously_max_len: int = 3 + # 派蒙收到好友申请或群邀请时是否向超级管理员发通知 + paimon_request_remind: bool = True + # 是否自动通过好友请求 + paimon_add_friend: bool = False + # 是否自动通过群组请求 + paimon_add_group: bool = False + # 禁用群新成员欢迎语和龙王提醒的群号列表 + paimon_greet_ban: List[int] = [] + driver = get_driver() global_config = driver.config diff --git a/utils/json/score.json b/utils/json/score.json index bd55eb3..0fce1dc 100644 --- a/utils/json/score.json +++ b/utils/json/score.json @@ -49,7 +49,7 @@ "凝光": ["暴击率", "暴击伤害", "攻击力"], "岩主": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"], "云堇": ["防御力", "元素充能效率"], - "神里绫人": ["暴击率", "暴击伤害", "攻击力", "防御力"], + "神里绫人": ["暴击率", "暴击伤害", "攻击力", "生命值"], "夜兰": ["暴击率", "暴击伤害", "生命值", "元素充能效率"], "久岐忍": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"] }, From 616da0d40160a25b3c1c22e241435b135c6d335e Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Sun, 12 Jun 2022 16:55:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BA=91=E5=8E=9F=E7=A5=9Efix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Paimon_CloudGenshin/__init__.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/Paimon_CloudGenshin/__init__.py b/Paimon_CloudGenshin/__init__.py index 58033fa..1a87a0e 100644 --- a/Paimon_CloudGenshin/__init__.py +++ b/Paimon_CloudGenshin/__init__.py @@ -6,10 +6,8 @@ from nonebot import on_command, require, get_bot from nonebot.adapters.onebot.v11 import MessageEvent, Message, GroupMessageEvent from nonebot.params import CommandArg from .data_source import get_Info, get_Notification, check_token -from LittlePaimon.utils.decorator import exception_handler -from LittlePaimon.utils.file_handler import load_json, save_json -from LittlePaimon.utils.config import config -from LittlePaimon.utils.message_util import get_message_id +from utils.decorator import exception_handler +from utils.file_handler import load_json, save_json HELP_STR = ''' 云原神相关功能 @@ -56,10 +54,7 @@ async def _(event: Union[GroupMessageEvent, MessageEvent], msg: Message = Comman action = re.search(r'(?P(信息|info)|(绑定|bind))', param) if event.message_type == 'guild': - await cloud_ys.finish('该功能不支持群组或频道推送哦~', at_sender=True) - - if str(get_message_id(event)) not in config.paimon_cloudys_group: - await cloud_ys.finish(f'尚未在群 {str(get_message_id(event))} 开启本功能') + await cloud_ys.finish('该功能暂不支持频道推送哦~', at_sender=True) if not param: await cloud_ys.finish('请输入具体指令或参数!', at_sender=True) From acef2feba8e3c734944f16047e3b13904a85099b Mon Sep 17 00:00:00 2001 From: CMHopeSunshine <277073121@qq.com> Date: Mon, 13 Jun 2022 21:08:01 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D`ssbq`=E6=A0=91=E8=84=82?= =?UTF-8?q?=E8=B6=85=E8=BF=87160=E6=97=B6=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Paimon_Info/draw_daily_note.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Paimon_Info/draw_daily_note.py b/Paimon_Info/draw_daily_note.py index 20664d2..e2de6df 100644 --- a/Paimon_Info/draw_daily_note.py +++ b/Paimon_Info/draw_daily_note.py @@ -18,6 +18,10 @@ def get_font(size, font='msyhbd.ttc'): async def draw_ring(per): + if per > 1: + per = 1 + elif per < 0: + per = 0 per_list = [per, 1 - per] colors = ['#507bd0', '#FFFFFF'] plt.pie(per_list, startangle=90, colors=colors) @@ -109,14 +113,14 @@ async def draw_daily_note_card(data, uid): bg_draw.text((965, 1167), "周本减半", fill='white', font=get_font(40, '优设标题黑.ttf')) # 深渊文字 abyss_new_month = datetime.datetime.now().month if datetime.datetime.now().day < 16 else datetime.datetime.now().month + 1 - abyss_new_day = 15 if datetime.datetime.now().day < 16 else 1 - abyss_new = datetime.datetime.strptime('2022.' + str(abyss_new_month) + '.' + str(abyss_new_day) + '.04:00', + abyss_new_day = 16 if datetime.datetime.now().day < 16 else 1 + abyss_new = datetime.datetime.strptime('2022.' + str(abyss_new_month) + '.' + str(abyss_new_day) + '.00:00', '%Y.%m.%d.%H:%M') - datetime.datetime.now() bg_draw.text((337, 1358), f"{abyss_new.days}/15", fill='white', font=get_font(48, 'number.ttf')) - bg_draw.text((745, 1358), f"本期深渊还有{abyss_new.days}天结束", fill='white', + bg_draw.text((745, 1358), f"本期深渊还有{abyss_new.days if abyss_new.days <= 15 else 15}天结束", fill='white', font=get_font(40, '优设标题黑.ttf')) - bg_img.alpha_composite(await draw_ring(abyss_new.days / 15), (100, 1249)) + bg_img.alpha_composite(await draw_ring(abyss_new.days if abyss_new.days <= 15 else 15 / 15), (100, 1249)) # 派遣情况 exp = data['expeditions']