fix auto_agree

This commit is contained in:
felinae98 2021-02-09 12:49:12 +08:00
parent 771d44860b
commit 751331262c
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610

View File

@ -3,18 +3,16 @@ from nonebot.adapters.cqhttp import Bot, Event
from nonebot.permission import SUPERUSER
from nonebot.typing import T_State
from nonebot.adapters.cqhttp.permission import PRIVATE_FRIEND
from nonebot.adapters.cqhttp.event import FriendRequestEvent, GroupRequestEvent
from nonebot.adapters.cqhttp.event import FriendRequestEvent, GroupRequestEvent, RequestEvent
friend_req = on_request(priority=5)
@friend_req.handle()
async def add_superuser(bot: Bot, event: FriendRequestEvent, state: T_State):
if event.user_id in bot.config.superusers:
async def add_superuser(bot: Bot, event: RequestEvent, state: T_State):
if event.user_id in bot.config.superusers and event.request_type == 'private':
await event.approve(bot)
logger.info('add user {}'.format(event.user_id))
@friend_req.handle()
async def agree_to_group(bot: Bot, event: GroupRequestEvent, state: T_State):
if event.sub_type == 'invite' and event.user_id in bot.config.superusers:
elif event.sub_type == 'invite' and event.user_id in bot.config.superusers and event.request_type == 'group':
await event.approve(bot)
logger.info('add group {}'.format(event.group_id))