mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-22 02:25:56 +08:00
♿ add request event approve reject
This commit is contained in:
parent
fcac6f8a0f
commit
7c3b2b514a
@ -1,6 +1,6 @@
|
|||||||
import inspect
|
import inspect
|
||||||
from typing_extensions import Literal
|
from typing_extensions import Literal
|
||||||
from typing import Type, List, Optional
|
from typing import Type, List, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from pygtrie import StringTrie
|
from pygtrie import StringTrie
|
||||||
@ -11,6 +11,9 @@ from nonebot.adapters import Event as BaseEvent
|
|||||||
|
|
||||||
from .message import Message
|
from .message import Message
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from .bot import Bot
|
||||||
|
|
||||||
|
|
||||||
class Event(BaseEvent):
|
class Event(BaseEvent):
|
||||||
"""
|
"""
|
||||||
@ -458,6 +461,14 @@ class FriendRequestEvent(RequestEvent):
|
|||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return str(self.user_id)
|
||||||
|
|
||||||
|
async def approve(self, bot: "Bot", remark: str = ""):
|
||||||
|
return await bot.set_friend_add_request(flag=self.flag,
|
||||||
|
approve=True,
|
||||||
|
remark=remark)
|
||||||
|
|
||||||
|
async def reject(self, bot: "Bot"):
|
||||||
|
return await bot.set_friend_add_request(flag=self.flag, approve=False)
|
||||||
|
|
||||||
|
|
||||||
class GroupRequestEvent(RequestEvent):
|
class GroupRequestEvent(RequestEvent):
|
||||||
"""加群请求/邀请事件"""
|
"""加群请求/邀请事件"""
|
||||||
@ -477,6 +488,17 @@ class GroupRequestEvent(RequestEvent):
|
|||||||
def get_session_id(self) -> str:
|
def get_session_id(self) -> str:
|
||||||
return str(self.user_id)
|
return str(self.user_id)
|
||||||
|
|
||||||
|
async def approve(self, bot: "Bot"):
|
||||||
|
return await bot.set_group_add_request(flag=self.flag,
|
||||||
|
sub_type=self.sub_type,
|
||||||
|
approve=True)
|
||||||
|
|
||||||
|
async def reject(self, bot: "Bot", reason: str = ""):
|
||||||
|
return await bot.set_group_add_request(flag=self.flag,
|
||||||
|
sub_type=self.sub_type,
|
||||||
|
approve=False,
|
||||||
|
reason=reason)
|
||||||
|
|
||||||
|
|
||||||
# Meta Events
|
# Meta Events
|
||||||
class MetaEvent(Event):
|
class MetaEvent(Event):
|
||||||
|
@ -9,6 +9,7 @@ sidebar: auto
|
|||||||
- 修复 `Message` 消息为 `None` 时的处理错误
|
- 修复 `Message` 消息为 `None` 时的处理错误
|
||||||
- 修复 `Message.extract_plain_text` 返回为转义字符串的问题
|
- 修复 `Message.extract_plain_text` 返回为转义字符串的问题
|
||||||
- 修复命令处理错误地删除了后续空格
|
- 修复命令处理错误地删除了后续空格
|
||||||
|
- 增加好友添加和加群请求事件 `approve`, `reject` 方法
|
||||||
|
|
||||||
## v2.0.0a8
|
## v2.0.0a8
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user