update nonebot, fix autoagree

This commit is contained in:
felinae98 2021-02-09 12:35:49 +08:00
parent b970860c9a
commit 771d44860b
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
2 changed files with 13 additions and 7 deletions

12
poetry.lock generated
View File

@ -596,7 +596,7 @@ reference = "aliyun"
[[package]]
name = "nonebot2"
version = "2.0.0a9"
version = "2.0.0a10"
description = "An asynchronous python bot framework."
category = "main"
optional = false
@ -611,6 +611,10 @@ pygtrie = ">=2.4.1,<3.0.0"
uvicorn = ">=0.11.5,<0.12.0"
websockets = ">=8.1,<9.0"
[package.extras]
quart = ["Quart (>=0.14.1,<0.15.0)"]
all = ["Quart (>=0.14.1,<0.15.0)"]
[package.source]
type = "legacy"
url = "https://mirrors.aliyun.com/pypi/simple"
@ -1253,7 +1257,7 @@ reference = "aliyun"
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "02d96d899638d0a8f2ecb5fa430b8fa03c5303ef503d3f906fe9cebfafba64f2"
content-hash = "cc910d2170cfbfb59c5a8de03ebb0882bd5aa522a8b90eff0e56af5811d60cde"
[metadata.files]
appdirs = [
@ -1452,8 +1456,8 @@ nonebot-plugin-apscheduler = [
{file = "nonebot_plugin_apscheduler-0.1.2-py3-none-any.whl", hash = "sha256:eed7b9e60d08826ae4919f82dc240fc7ec469185271c2271e14438a3e0ca7692"},
]
nonebot2 = [
{file = "nonebot2-2.0.0a9-py3-none-any.whl", hash = "sha256:71d71fbfe364b08509e66519504a5723cc7148cff489c9a620541f3bea9f6296"},
{file = "nonebot2-2.0.0a9.tar.gz", hash = "sha256:62f2a24b9539aa72bfee2bed3ab1efe9831653ffd660f03cb1d173796df7224d"},
{file = "nonebot2-2.0.0a10-py3-none-any.whl", hash = "sha256:e4d75367b89a978b6f620a7de1c7fe598059868c8a9034936b9b471dd8c7c1a7"},
{file = "nonebot2-2.0.0a10.tar.gz", hash = "sha256:db3b7edd9119b77b0201fa9ca71c71c2cc95ae0df06506748ef5f13b172fdab6"},
]
parso = [
{file = "parso-0.8.1-py2.py3-none-any.whl", hash = "sha256:15b00182f472319383252c18d5913b69269590616c947747bc50bf4ac768f410"},

View File

@ -1,4 +1,4 @@
from nonebot import on_request
from nonebot import on_request, logger
from nonebot.adapters.cqhttp import Bot, Event
from nonebot.permission import SUPERUSER
from nonebot.typing import T_State
@ -10,9 +10,11 @@ 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:
await bot.set_friend_add_request(flag=event.id, approve=True)
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:
await bot.set_group_add_request(flag=event.id, sub_type='invite', approve=True)
await event.approve(bot)
logger.info('add group {}'.format(event.group_id))