2021-01-31 17:01:04 +08:00
|
|
|
|
from typing import TYPE_CHECKING
|
2021-11-22 23:21:26 +08:00
|
|
|
|
from typing_extensions import Literal
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
2021-01-29 21:19:13 +08:00
|
|
|
|
from pydantic import Field
|
|
|
|
|
|
2021-01-29 17:38:39 +08:00
|
|
|
|
from .base import Event
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
2021-01-31 17:01:04 +08:00
|
|
|
|
if TYPE_CHECKING:
|
2021-02-01 14:24:45 +08:00
|
|
|
|
from ..bot import Bot
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
|
|
|
|
class RequestEvent(Event):
|
2021-02-01 00:01:31 +08:00
|
|
|
|
"""请求事件基类"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
|
|
|
|
|
event_id: int = Field(alias="eventId")
|
2021-01-29 21:19:13 +08:00
|
|
|
|
message: str
|
|
|
|
|
nick: str
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NewFriendRequestEvent(RequestEvent):
|
2021-02-01 00:01:31 +08:00
|
|
|
|
"""添加好友申请"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
|
|
|
|
|
from_id: int = Field(alias="fromId")
|
|
|
|
|
group_id: int = Field(0, alias="groupId")
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
2021-01-31 17:01:04 +08:00
|
|
|
|
async def approve(self, bot: "Bot"):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
|
|
|
|
通过此人的好友申请
|
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/newFriendRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": 0,
|
|
|
|
|
"message": "",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async def reject(self, bot: "Bot", operate: Literal[1, 2] = 1, message: str = ""):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
2021-03-07 22:36:38 +08:00
|
|
|
|
拒绝此人的好友申请
|
2021-01-31 22:43:43 +08:00
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
* ``operate: Literal[1, 2]``: 响应的操作类型
|
2021-02-01 13:50:14 +08:00
|
|
|
|
|
|
|
|
|
* ``1``: 拒绝添加好友
|
|
|
|
|
* ``2``: 拒绝添加好友并添加黑名单,不再接收该用户的好友申请
|
|
|
|
|
|
2021-01-31 22:43:43 +08:00
|
|
|
|
* ``message: str``: 回复的信息
|
|
|
|
|
"""
|
2021-01-31 17:01:04 +08:00
|
|
|
|
assert operate > 0
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/newFriendRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": operate,
|
|
|
|
|
"message": message,
|
|
|
|
|
},
|
|
|
|
|
)
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
|
|
|
|
class MemberJoinRequestEvent(RequestEvent):
|
2021-02-01 00:01:31 +08:00
|
|
|
|
"""用户入群申请(Bot需要有管理员权限)"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
|
|
|
|
|
from_id: int = Field(alias="fromId")
|
|
|
|
|
group_id: int = Field(alias="groupId")
|
|
|
|
|
group_name: str = Field(alias="groupName")
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
2021-01-31 17:01:04 +08:00
|
|
|
|
async def approve(self, bot: "Bot"):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
|
|
|
|
通过此人的加群申请
|
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/memberJoinRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": 0,
|
|
|
|
|
"message": "",
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
async def reject(
|
|
|
|
|
self, bot: "Bot", operate: Literal[1, 2, 3, 4] = 1, message: str = ""
|
|
|
|
|
):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
|
|
|
|
拒绝(忽略)此人的加群申请
|
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
* ``operate: Literal[1, 2, 3, 4]``: 响应的操作类型
|
2021-02-01 13:50:14 +08:00
|
|
|
|
|
|
|
|
|
* ``1``: 拒绝入群
|
|
|
|
|
* ``2``: 忽略请求
|
|
|
|
|
* ``3``: 拒绝入群并添加黑名单,不再接收该用户的入群申请
|
|
|
|
|
* ``4``: 忽略入群并添加黑名单,不再接收该用户的入群申请
|
|
|
|
|
|
2021-01-31 22:43:43 +08:00
|
|
|
|
* ``message: str``: 回复的信息
|
|
|
|
|
"""
|
2021-01-31 17:01:04 +08:00
|
|
|
|
assert operate > 0
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/memberJoinRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": operate,
|
|
|
|
|
"message": message,
|
|
|
|
|
},
|
|
|
|
|
)
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
2021-01-29 21:19:13 +08:00
|
|
|
|
|
|
|
|
|
class BotInvitedJoinGroupRequestEvent(RequestEvent):
|
2021-02-01 00:01:31 +08:00
|
|
|
|
"""Bot被邀请入群申请"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
|
|
|
|
|
from_id: int = Field(alias="fromId")
|
|
|
|
|
group_id: int = Field(alias="groupId")
|
|
|
|
|
group_name: str = Field(alias="groupName")
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
|
|
|
|
async def approve(self, bot: "Bot"):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
2021-03-07 22:36:38 +08:00
|
|
|
|
通过这份被邀请入群申请
|
2021-01-31 22:43:43 +08:00
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/botInvitedJoinGroupRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": 0,
|
|
|
|
|
"message": "",
|
|
|
|
|
},
|
|
|
|
|
)
|
2021-01-31 17:01:04 +08:00
|
|
|
|
|
|
|
|
|
async def reject(self, bot: "Bot", message: str = ""):
|
2021-01-31 22:43:43 +08:00
|
|
|
|
"""
|
|
|
|
|
:说明:
|
|
|
|
|
|
2021-03-07 22:36:38 +08:00
|
|
|
|
拒绝这份被邀请入群申请
|
2021-01-31 22:43:43 +08:00
|
|
|
|
|
|
|
|
|
:参数:
|
|
|
|
|
|
|
|
|
|
* ``bot: Bot``: 当前的 ``Bot`` 对象
|
|
|
|
|
* ``message: str``: 邀请消息
|
|
|
|
|
"""
|
2021-11-22 23:21:26 +08:00
|
|
|
|
return await bot.api.post(
|
|
|
|
|
"/resp/botInvitedJoinGroupRequestEvent",
|
|
|
|
|
params={
|
|
|
|
|
"eventId": self.event_id,
|
|
|
|
|
"groupId": self.group_id,
|
|
|
|
|
"fromId": self.from_id,
|
|
|
|
|
"operate": 1,
|
|
|
|
|
"message": message,
|
|
|
|
|
},
|
|
|
|
|
)
|