mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-02 09:26:12 +08:00
add auto agree
This commit is contained in:
parent
180c606950
commit
c80565c474
1
bot.py
1
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")
|
||||
|
@ -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
18
src/plugins/auto_agree.py
Normal 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)
|
Loading…
x
Reference in New Issue
Block a user