diff options
Diffstat (limited to 'ATRI/plugins/welcome.py')
-rw-r--r-- | ATRI/plugins/welcome.py | 72 |
1 files changed, 6 insertions, 66 deletions
diff --git a/ATRI/plugins/welcome.py b/ATRI/plugins/welcome.py index b61c5bf..d727e5e 100644 --- a/ATRI/plugins/welcome.py +++ b/ATRI/plugins/welcome.py @@ -1,10 +1,8 @@ -import json import nonebot -from pathlib import Path from nonebot import on_notice from nonebot.notice_request import NoticeSession, RequestSession from nonebot.plugin import on_request -from aiocqhttp.exceptions import ActionFailed +from nonebot.helpers import send_to_superusers import config # type: ignore @@ -37,69 +35,11 @@ async def _(session: NoticeSession): @on_request('friend_add') async def _(session: RequestSession): user = session.event.user_id - await bot.send_private_msg( - user_id = master, # type: ignore - message = f'{user}\n想认识ATRI欸欸欸!!' - ) - - with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: - data = json.load(f) - - if data["approve_friend_add"] == 0: - try: - await session.approve() - except ActionFailed as e: - print(e.retcode) - await bot.send_private_msg( - user_id = master, # type: ignore - message = '由于主人已同意ATRI接近陌生人,故请求已同意!' - ) - await bot.send_private_msg( - user_id = user, # type: ignore - message = f'初次见面,我是アトリ!咱可是高性能ですから~!\nATRI的使用方法(恁可少想有的没的8,老涩批):https://lolihub.icu/#/robot/user' - ) - - else: - await bot.send_private_msg( - user_id = master, # type: ignore - message = '由于主人不同意ATRI接近陌生人,故请求已回拒...' - ) - await bot.send_private_msg( - user_id = user, # type: ignore - message = f'主人似乎不想让ATRI接触陌生人呢...' - ) + await send_to_superusers(bot, f'{user}\n想认识ATRI欸欸欸!!') @on_request('group') async def _(session: RequestSession): - group = session.event.group_id - user = session.event.user_id - - with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f: - data = json.load(f) - - if session.event.sub_type == 'invite': - - if data["approve_invite_join_group"] == 0: - await session.bot.send_private_msg( - user_id = user, # type: ignore - message = '嗯哼?想邀请ATRI入群嘛,正好!咱主人想让咱出去看看大世界!' - ) - await session.bot.send_private_msg( - user_id = master, # type: ignore - message = f'ATRI收到一个新邀请:\n裙: {group}\n邀请人: {user}\n已同意' - ) - - try: - await session.approve() - except ActionFailed as e: - print(e.retcode) - - else: - await session.bot.send_private_msg( - user_id = user, # type: ignore - message = '主人告诉咱不能随便乱跑...\n作者联系方式:https://lolihub.icu/#/about' - ) - await session.bot.send_private_msg( - user_id = master, # type: ignore - message = f'ATRI收到一个新邀请:裙: {group}\n邀请人: {user}\n已拒绝' - )
\ No newline at end of file + if session.event.user_id == master: + await session.approve() + else: + await session.send(f'邀请入群请联系ATRI的主人[{master}]')
\ No newline at end of file |