mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
Merge branch 'nonebot2' into nonebot2
This commit is contained in:
commit
55828709c9
@ -8,10 +8,8 @@ from nonebot.internal.matcher import Matcher
|
|||||||
from nonebot.internal.params import ArgPlainText
|
from nonebot.internal.params import ArgPlainText
|
||||||
from nonebot.params import CommandArg
|
from nonebot.params import CommandArg
|
||||||
from .data_source import get_Info, get_Notification, check_token
|
from .data_source import get_Info, get_Notification, check_token
|
||||||
from LittlePaimon.utils.decorator import exception_handler
|
from utils.decorator import exception_handler
|
||||||
from LittlePaimon.utils.file_handler import load_json, save_json
|
from utils.file_handler import load_json, save_json
|
||||||
from LittlePaimon.utils.config import config
|
|
||||||
from LittlePaimon.utils.message_util import get_message_id
|
|
||||||
|
|
||||||
HELP_STR = '''
|
HELP_STR = '''
|
||||||
云原神相关功能
|
云原神相关功能
|
||||||
@ -98,7 +96,7 @@ async def _(event: Union[GroupMessageEvent, MessageEvent], msg: Message = Comman
|
|||||||
action = re.search(r'(?P<action>(信息|info)|(绑定|bind))', param)
|
action = re.search(r'(?P<action>(信息|info)|(绑定|bind))', param)
|
||||||
|
|
||||||
if event.message_type == 'guild':
|
if event.message_type == 'guild':
|
||||||
await cloud_ys.finish('该功能不支持频道推送哦~', at_sender=True)
|
await cloud_ys.finish('该功能暂不支持频道推送哦~', at_sender=True)
|
||||||
|
|
||||||
if not param:
|
if not param:
|
||||||
message = f'亲爱的旅行者: {user_id}\n\n' \
|
message = f'亲爱的旅行者: {user_id}\n\n' \
|
||||||
|
@ -541,7 +541,7 @@ async def _(event: MessageEvent, state: T_State, msg: Message = CommandArg()):
|
|||||||
uid = re.search(r'(?P<uid>(1|2|5)\d{8})', msg.extract_plain_text())
|
uid = re.search(r'(?P<uid>(1|2|5)\d{8})', msg.extract_plain_text())
|
||||||
if uid:
|
if uid:
|
||||||
state['uid'] = uid.group('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:
|
else:
|
||||||
user = ''
|
user = ''
|
||||||
for msg_seg in msg:
|
for msg_seg in msg:
|
||||||
|
@ -18,6 +18,10 @@ def get_font(size, font='msyhbd.ttc'):
|
|||||||
|
|
||||||
|
|
||||||
async def draw_ring(per):
|
async def draw_ring(per):
|
||||||
|
if per > 1:
|
||||||
|
per = 1
|
||||||
|
elif per < 0:
|
||||||
|
per = 0
|
||||||
per_list = [per, 1 - per]
|
per_list = [per, 1 - per]
|
||||||
colors = ['#507bd0', '#FFFFFF']
|
colors = ['#507bd0', '#FFFFFF']
|
||||||
plt.pie(per_list, startangle=90, colors=colors)
|
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'))
|
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_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_day = 16 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 = datetime.datetime.strptime('2022.' + str(abyss_new_month) + '.' + str(abyss_new_day) + '.00:00',
|
||||||
'%Y.%m.%d.%H:%M') - datetime.datetime.now()
|
'%Y.%m.%d.%H:%M') - datetime.datetime.now()
|
||||||
bg_draw.text((337, 1358), f"{abyss_new.days}/15", fill='white',
|
bg_draw.text((337, 1358), f"{abyss_new.days}/15", fill='white',
|
||||||
font=get_font(48, 'number.ttf'))
|
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'))
|
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']
|
exp = data['expeditions']
|
||||||
|
@ -1,38 +1,80 @@
|
|||||||
import random
|
import random
|
||||||
from asyncio import sleep
|
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 utils.config import config
|
||||||
from nonebot import get_driver
|
from utils.message_util import MessageBuild
|
||||||
from nonebot.message import event_preprocessor
|
|
||||||
from nonebot.adapters.onebot.v11 import Bot, FriendRequestEvent, GroupRequestEvent
|
|
||||||
|
|
||||||
superuser = int(list(get_driver().config.superusers)[0])
|
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):
|
async def addFriend(bot: Bot, event: FriendRequestEvent):
|
||||||
superuser_msg = f'{event.user_id}请求添加派蒙为好友, 验证信息为:{event.comment}'
|
superuser_msg = f'{event.user_id}请求添加派蒙为好友, 验证信息为:{event.comment}'
|
||||||
if config.paimon_add_friend:
|
if config.paimon_add_friend:
|
||||||
superuser_msg += ',已自动同意'
|
superuser_msg += ',已自动同意'
|
||||||
await sleep(random.randint(2, 4))
|
await sleep(random.randint(4, 8))
|
||||||
await event.approve(bot)
|
await event.approve(bot)
|
||||||
await sleep(random.randint(3, 6))
|
|
||||||
await bot.send_private_msg(user_id=event.user_id, message=f'旅行者你好呀,这里是小派蒙,发送/help查看帮助哦')
|
|
||||||
else:
|
else:
|
||||||
superuser_msg += ',请主人自行处理哦'
|
superuser_msg += ',请主人自行处理哦'
|
||||||
|
if config.paimon_request_remind:
|
||||||
await bot.send_private_msg(user_id=superuser, message=superuser_msg)
|
await bot.send_private_msg(user_id=superuser, message=superuser_msg)
|
||||||
|
|
||||||
|
|
||||||
@event_preprocessor
|
@requests_handle.handle()
|
||||||
async def addGroup(bot: Bot, event: GroupRequestEvent):
|
async def addGroup(bot: Bot, event: GroupRequestEvent):
|
||||||
if event.sub_type != 'invite':
|
if event.sub_type != 'invite':
|
||||||
return
|
return
|
||||||
superuser_msg = f'{event.user_id}邀请派蒙加入群{event.group_id}'
|
superuser_msg = f'{event.user_id}邀请派蒙加入群{event.group_id}'
|
||||||
if config.paimon_add_group or event.user_id == superuser:
|
if config.paimon_add_group or event.user_id == superuser:
|
||||||
superuser_msg += ',已自动同意'
|
superuser_msg += ',已自动同意'
|
||||||
await sleep(random.randint(2, 4))
|
await sleep(random.randint(4, 8))
|
||||||
await event.approve(bot)
|
await event.approve(bot)
|
||||||
await sleep(random.randint(3, 6))
|
|
||||||
await bot.send_group_msg(group_id=event.group_id, message=f'旅行者们大家好呀,这里是小派蒙,发送/help查看帮助哦')
|
|
||||||
else:
|
else:
|
||||||
superuser_msg += ',请主人自行处理哦'
|
superuser_msg += ',请主人自行处理哦'
|
||||||
|
if config.paimon_request_remind:
|
||||||
await bot.send_private_msg(user_id=superuser, message=superuser_msg)
|
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))
|
||||||
|
12
README.md
12
README.md
@ -82,7 +82,7 @@
|
|||||||
+ 5.27
|
+ 5.27
|
||||||
- 新增`原神日历`[@nicklly](https://github.com/nicklly)
|
- 新增`原神日历`[@nicklly](https://github.com/nicklly)
|
||||||
+ 5.28
|
+ 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
|
+ 6.3
|
||||||
- 新增游戏内展柜角色面板卡片,使用`更新角色面板`来获取角色,`ysd角色名`来查看角色卡片
|
- 新增游戏内展柜角色面板卡片,使用`更新角色面板`来获取角色,`ysd角色名`来查看角色卡片
|
||||||
- 修复部分不记录上次查询的uid的bug
|
- 修复部分不记录上次查询的uid的bug
|
||||||
@ -93,6 +93,9 @@
|
|||||||
- 修复`原神猜语音`和`模拟抽卡`因`nonebot2.0.0b3`版本Union校验产生的bug,但`原神猜语音`将暂时无法私聊使用
|
- 修复`原神猜语音`和`模拟抽卡`因`nonebot2.0.0b3`版本Union校验产生的bug,但`原神猜语音`将暂时无法私聊使用
|
||||||
+ 6.9
|
+ 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)})();
|
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) - 跨平台异步机器人框架
|
- [NoneBot2](https://github.com/nonebot/nonebot2) - 跨平台异步机器人框架
|
||||||
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) - Onebot标准的框架实现
|
- [go-cqhttp](https://github.com/Mrs4s/go-cqhttp) - Onebot标准的框架实现
|
||||||
- [西北一枝花](https://github.com/Nwflower) - 美工大大和武器攻略图提供
|
- [西北一枝花](https://github.com/Nwflower) - 美工大大和武器攻略图提供
|
||||||
|
- [nicklly](https://github.com/nicklly) - 原神日历、云原神等功能贡献者
|
||||||
- [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 抽卡和猜语音代码、资源参考
|
- [egenshin](https://github.com/pcrbot/erinilis-modules/tree/master/egenshin) - 抽卡和猜语音代码、资源参考
|
||||||
- [bluemushoom](https://bbs.nga.cn/nuke.php?func=ucp&uid=62861898) - 全角色收益曲线和参考面板攻略图来源
|
- [bluemushoom](https://bbs.nga.cn/nuke.php?func=ucp&uid=62861898) - 全角色收益曲线和参考面板攻略图来源
|
||||||
- [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出代码参考
|
- [genshin-gacha-export](https://github.com/sunfkny/genshin-gacha-export) - 抽卡记录导出代码参考
|
||||||
@ -157,7 +161,7 @@ javascript:(function(){prompt(document.domain,document.cookie)})();
|
|||||||
- 部分资源使用了云存储,如果想赞助流量费用,欢迎来[爱发电](https://afdian.net/@cherishmoon),十分感谢!
|
- 部分资源使用了云存储,如果想赞助流量费用,欢迎来[爱发电](https://afdian.net/@cherishmoon),十分感谢!
|
||||||
|
|
||||||
| 赞助者 | 金额 |
|
| 赞助者 | 金额 |
|
||||||
| --------------- | ---- |
|
|----------------|-----|
|
||||||
| 深海 | 10 |
|
| 深海 | 10 |
|
||||||
| 夜空koi | 30 |
|
| 夜空koi | 30 |
|
||||||
| 情话 | 20 |
|
| 情话 | 20 |
|
||||||
@ -165,6 +169,8 @@ javascript:(function(){prompt(document.domain,document.cookie)})();
|
|||||||
| 米特建木 | 10 |
|
| 米特建木 | 10 |
|
||||||
| 永远的皇珈骑士 | 30 |
|
| 永远的皇珈骑士 | 30 |
|
||||||
| 小兔和鹿 | 30 |
|
| 小兔和鹿 | 30 |
|
||||||
|
| el psy congroo | 20 |
|
||||||
|
| jimjqn | 30 |
|
||||||
|
|
||||||
## 丨其他
|
## 丨其他
|
||||||
|
|
||||||
|
@ -27,10 +27,6 @@ class PluginConfig(BaseModel):
|
|||||||
paimon_ecy_cd: int = 6
|
paimon_ecy_cd: int = 6
|
||||||
# 原神壁纸图冷却(秒)
|
# 原神壁纸图冷却(秒)
|
||||||
paimon_ysp_cd: int = 10
|
paimon_ysp_cd: int = 10
|
||||||
# 是否自动通过好友请求
|
|
||||||
paimon_add_friend: bool = False
|
|
||||||
# 是否自动通过群组请求
|
|
||||||
paimon_add_group: bool = False
|
|
||||||
# 派蒙聊天开启群组
|
# 派蒙聊天开启群组
|
||||||
paimon_chat_group: List[int] = []
|
paimon_chat_group: List[int] = []
|
||||||
|
|
||||||
@ -65,6 +61,15 @@ class PluginConfig(BaseModel):
|
|||||||
# 连续主动说话最多几句话
|
# 连续主动说话最多几句话
|
||||||
paimon_speak_continuously_max_len: int = 3
|
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()
|
driver = get_driver()
|
||||||
global_config = driver.config
|
global_config = driver.config
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
"凝光": ["暴击率", "暴击伤害", "攻击力"],
|
"凝光": ["暴击率", "暴击伤害", "攻击力"],
|
||||||
"岩主": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"],
|
"岩主": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"],
|
||||||
"云堇": ["防御力", "元素充能效率"],
|
"云堇": ["防御力", "元素充能效率"],
|
||||||
"神里绫人": ["暴击率", "暴击伤害", "攻击力", "防御力"],
|
"神里绫人": ["暴击率", "暴击伤害", "攻击力", "生命值"],
|
||||||
"夜兰": ["暴击率", "暴击伤害", "生命值", "元素充能效率"],
|
"夜兰": ["暴击率", "暴击伤害", "生命值", "元素充能效率"],
|
||||||
"久岐忍": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"]
|
"久岐忍": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"]
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user