summaryrefslogtreecommitdiff
path: root/ATRI/plugins/welcome.py
diff options
context:
space:
mode:
[Update]
Diffstat (limited to 'ATRI/plugins/welcome.py')
1 files changed, 17 insertions, 10 deletions
diff --git a/ATRI/plugins/welcome.py b/ATRI/plugins/welcome.py
index 8f44300..6e2a9d0 100644
--- a/ATRI/plugins/welcome.py
+++ b/ATRI/plugins/welcome.py
@@ -9,6 +9,7 @@ from aiocqhttp.exceptions import ActionFailed
import config # type: ignore
+
bot = nonebot.get_bot()
master = config.MASTER()
@@ -23,8 +24,19 @@ async def _(session: NoticeSession):
else:
await session.send(f'[CQ:at,qq={user}]\nねえ❤...是新人欸!\nここでは遠慮はいらないのだからね❤')
-@on_notice('firend_add')
+@on_notice('group_decrease')
async def _(session: NoticeSession):
+ user = str(session.event.user_id)
+ now = str(session.event.operator_id)
+
+ if now == user:
+ inf = await bot.get_stranger_info(user_id = user) # type: ignore
+ name = inf['nickname']
+ await session.send(f'{name}({user}) 跑了')
+
+
+@on_request('friend_add')
+async def _(session: RequestSession):
user = session.event.user_id
await bot.send_private_msg(
user_id = master, # type: ignore
@@ -35,6 +47,10 @@ async def _(session: NoticeSession):
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接近陌生人,故请求已同意!'
@@ -54,15 +70,6 @@ async def _(session: NoticeSession):
message = f'主人似乎不想让ATRI接触陌生人呢...'
)
-@on_request('friend_add')
-async def _(session: RequestSession):
- with open(Path('.') / 'ATRI' / 'plugins' / 'switch' / 'switch.json', 'r') as f:
- data = json.load(f)
-
- if data["approve_friend_add"] == 0:
- await session.approve()
-
-
@on_request('group')
async def _(session: RequestSession):
group = session.event.group_id