add auto agree

This commit is contained in:
felinae98 2021-02-06 19:02:49 +08:00
parent 180c606950
commit c80565c474
No known key found for this signature in database
GPG Key ID: 00C8B010587FF610
3 changed files with 23 additions and 1 deletions

1
bot.py
View File

@ -10,7 +10,6 @@ driver.register_adapter('cqhttp', CQHTTPBot)
nonebot.load_builtin_plugins()
nonebot.load_plugins('src/plugins')
nonebot.load_plugin("nonebot_plugin_apscheduler")
nonebot.load_plugin('nonebot_plugin_test')
if __name__ == "__main__":
nonebot.run(app="bot:app")

View File

@ -4,6 +4,11 @@ version = "0.1.0"
description = "Subscribe message from social medias"
authors = ["felinae98 <felinae225@qq.com>"]
license = "MIT"
homepage = "https://github.com/felinae98/nonebot-hk-reporter"
keywords = ["nonebot", "nonebot2", "qqbot"]
packages = [
{ include = "hk_reporter/*.py", from = "./src/plugins/" }
]
[tool.poetry.dependencies]
python = "^3.9"

18
src/plugins/auto_agree.py Normal file
View File

@ -0,0 +1,18 @@
from nonebot import on_request
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
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)
@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)