2022-05-15 20:15:10 +08:00
|
|
|
|
import random
|
|
|
|
|
from asyncio import sleep
|
2022-06-12 15:32:52 +08:00
|
|
|
|
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
|
|
|
|
|
|
2022-08-07 00:17:07 +08:00
|
|
|
|
from ..utils.config import config
|
|
|
|
|
from ..utils.message_util import MessageBuild
|
2022-05-15 20:15:10 +08:00
|
|
|
|
|
|
|
|
|
superuser = int(list(get_driver().config.superusers)[0])
|
|
|
|
|
|
2022-06-12 15:32:52 +08:00
|
|
|
|
requests_handle = on_request(priority=5, block=True)
|
|
|
|
|
notice_handle = on_notice(priority=5, block=True)
|
|
|
|
|
|
2022-05-15 20:15:10 +08:00
|
|
|
|
|
2022-06-12 15:32:52 +08:00
|
|
|
|
@requests_handle.handle()
|
2022-05-15 20:15:10 +08:00
|
|
|
|
async def addFriend(bot: Bot, event: FriendRequestEvent):
|
|
|
|
|
superuser_msg = f'{event.user_id}请求添加派蒙为好友, 验证信息为:{event.comment}'
|
|
|
|
|
if config.paimon_add_friend:
|
|
|
|
|
superuser_msg += ',已自动同意'
|
2022-06-12 15:32:52 +08:00
|
|
|
|
await sleep(random.randint(4, 8))
|
2022-05-15 20:15:10 +08:00
|
|
|
|
await event.approve(bot)
|
|
|
|
|
else:
|
|
|
|
|
superuser_msg += ',请主人自行处理哦'
|
2022-06-12 15:32:52 +08:00
|
|
|
|
if config.paimon_request_remind:
|
|
|
|
|
await bot.send_private_msg(user_id=superuser, message=superuser_msg)
|
2022-05-15 20:15:10 +08:00
|
|
|
|
|
|
|
|
|
|
2022-06-12 15:32:52 +08:00
|
|
|
|
@requests_handle.handle()
|
2022-05-15 20:15:10 +08:00
|
|
|
|
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 += ',已自动同意'
|
2022-06-12 15:32:52 +08:00
|
|
|
|
await sleep(random.randint(4, 8))
|
2022-05-15 20:15:10 +08:00
|
|
|
|
await event.approve(bot)
|
|
|
|
|
else:
|
|
|
|
|
superuser_msg += ',请主人自行处理哦'
|
2022-06-12 15:32:52 +08:00
|
|
|
|
if config.paimon_request_remind:
|
|
|
|
|
await bot.send_private_msg(user_id=superuser, message=superuser_msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@notice_handle.handle()
|
|
|
|
|
async def FriendNew(bot: Bot, event: FriendAddNoticeEvent):
|
2022-08-07 00:17:07 +08:00
|
|
|
|
greet_emoticon = MessageBuild.Image(Path() / 'resources' / 'LittlePaimon' / 'emoticons' / '派蒙-干杯.png', mode='RGBA')
|
2022-06-12 15:32:52 +08:00
|
|
|
|
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):
|
2022-08-07 00:17:07 +08:00
|
|
|
|
greet_emoticon = MessageBuild.Image(Path() / 'resources' / 'LittlePaimon' / 'emoticons' / '派蒙-干杯.png', mode='RGBA')
|
2022-06-12 15:32:52 +08:00
|
|
|
|
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:
|
2022-08-07 00:17:07 +08:00
|
|
|
|
honor_emoticon = MessageBuild.Image(Path() / 'resources' / 'LittlePaimon' / 'emoticons' / '派蒙-哼哼.png',
|
|
|
|
|
mode='RGBA')
|
2022-06-12 15:32:52 +08:00
|
|
|
|
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:
|
2022-08-07 00:17:07 +08:00
|
|
|
|
honor2_emoticon = MessageBuild.Image(Path() / 'resources' / 'LittlePaimon' / 'emoticons' / '派蒙-黑线.png',
|
|
|
|
|
mode='RGBA')
|
2022-06-12 15:32:52 +08:00
|
|
|
|
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))
|