mirror of
https://github.com/nonebot/nonebot2.git
synced 2025-02-22 02:25:56 +08:00
🚸 add .approve and .reject method for request event in mirai adapter
This commit is contained in:
parent
3f56da9245
commit
20b299c758
@ -1,7 +1,13 @@
|
|||||||
|
from typing import TYPE_CHECKING
|
||||||
|
from typing_extensions import Literal
|
||||||
|
|
||||||
from pydantic import Field
|
from pydantic import Field
|
||||||
|
|
||||||
from .base import Event
|
from .base import Event
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..bot import MiraiBot as Bot
|
||||||
|
|
||||||
|
|
||||||
class RequestEvent(Event):
|
class RequestEvent(Event):
|
||||||
event_id: int = Field(alias='eventId')
|
event_id: int = Field(alias='eventId')
|
||||||
@ -13,14 +19,79 @@ class NewFriendRequestEvent(RequestEvent):
|
|||||||
from_id: int = Field(alias='fromId')
|
from_id: int = Field(alias='fromId')
|
||||||
group_id: int = Field(0, alias='groupId')
|
group_id: int = Field(0, alias='groupId')
|
||||||
|
|
||||||
|
async def approve(self, bot: "Bot"):
|
||||||
|
return await bot.api.post('/resp/newFriendRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': 0
|
||||||
|
})
|
||||||
|
|
||||||
|
async def reject(self,
|
||||||
|
bot: "Bot",
|
||||||
|
operate: Literal[1, 2] = 1,
|
||||||
|
message: str = ''):
|
||||||
|
assert operate > 0
|
||||||
|
return await bot.api.post('/resp/newFriendRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': operate,
|
||||||
|
'message': message
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class MemberJoinRequestEvent(RequestEvent):
|
class MemberJoinRequestEvent(RequestEvent):
|
||||||
from_id: int = Field(alias='fromId')
|
from_id: int = Field(alias='fromId')
|
||||||
group_id: int = Field(alias='groupId')
|
group_id: int = Field(alias='groupId')
|
||||||
group_name: str = Field(alias='groupName')
|
group_name: str = Field(alias='groupName')
|
||||||
|
|
||||||
|
async def approve(self, bot: "Bot"):
|
||||||
|
return await bot.api.post('/resp/memberJoinRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': 0
|
||||||
|
})
|
||||||
|
|
||||||
|
async def reject(self,
|
||||||
|
bot: "Bot",
|
||||||
|
operate: Literal[1, 2, 3, 4] = 1,
|
||||||
|
message: str = ''):
|
||||||
|
assert operate > 0
|
||||||
|
return await bot.api.post('/resp/memberJoinRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': operate,
|
||||||
|
'message': message
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
class BotInvitedJoinGroupRequestEvent(RequestEvent):
|
class BotInvitedJoinGroupRequestEvent(RequestEvent):
|
||||||
from_id: int = Field(alias='fromId')
|
from_id: int = Field(alias='fromId')
|
||||||
group_id: int = Field(alias='groupId')
|
group_id: int = Field(alias='groupId')
|
||||||
group_name: str = Field(alias='groupName')
|
group_name: str = Field(alias='groupName')
|
||||||
|
|
||||||
|
async def approve(self, bot: "Bot"):
|
||||||
|
return await bot.api.post('/resp/botInvitedJoinGroupRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': 0
|
||||||
|
})
|
||||||
|
|
||||||
|
async def reject(self, bot: "Bot", message: str = ""):
|
||||||
|
return await bot.api.post('/resp/botInvitedJoinGroupRequestEvent',
|
||||||
|
params={
|
||||||
|
'eventId': self.event_id,
|
||||||
|
'groupId': self.group_id,
|
||||||
|
'fromId': self.from_id,
|
||||||
|
'operate': 1,
|
||||||
|
'message': message
|
||||||
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user