From c80565c4746e3c863225657d42b2183fddb80aa6 Mon Sep 17 00:00:00 2001 From: felinae98 <731499577@qq.com> Date: Sat, 6 Feb 2021 19:02:49 +0800 Subject: [PATCH] add auto agree --- bot.py | 1 - pyproject.toml | 5 +++++ src/plugins/auto_agree.py | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/plugins/auto_agree.py diff --git a/bot.py b/bot.py index ec63e15..982ec67 100644 --- a/bot.py +++ b/bot.py @@ -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") diff --git a/pyproject.toml b/pyproject.toml index d49a7df..6b9d7a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,11 @@ version = "0.1.0" description = "Subscribe message from social medias" authors = ["felinae98 "] 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" diff --git a/src/plugins/auto_agree.py b/src/plugins/auto_agree.py new file mode 100644 index 0000000..fe260a9 --- /dev/null +++ b/src/plugins/auto_agree.py @@ -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)