修复部分bug,新增好友、入群和龙王提醒

This commit is contained in:
CMHopeSunshine 2022-06-12 15:32:52 +08:00
parent 933264b410
commit 25bb845edd
5 changed files with 83 additions and 30 deletions

View File

@ -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())
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:

View File

@ -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)
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))

View File

@ -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 |
## 丨其他

View File

@ -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

View File

@ -49,7 +49,7 @@
"凝光": ["暴击率", "暴击伤害", "攻击力"],
"岩主": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"],
"云堇": ["防御力", "元素充能效率"],
"神里绫人": ["暴击率", "暴击伤害", "攻击力", "防御力"],
"神里绫人": ["暴击率", "暴击伤害", "攻击力", "生命值"],
"夜兰": ["暴击率", "暴击伤害", "生命值", "元素充能效率"],
"久岐忍": ["暴击率", "暴击伤害", "攻击力", "元素充能效率"]
},