群/C2C 管理事件
需要 Intents(public_messages=True)。
群管理事件
on_group_at_message_create
当收到群 @机器人的消息时触发。
python
async def on_group_at_message_create(self, message: GroupMessage)事件触发详情
- 触发解析:
parse_group_at_message_create→on_group_at_message_create - 参数模型:
GroupMessage—__slots__(继承自BaseMessage+ 自有):content,id,message_reference(嵌套_MessageRef:message_id),mentions(列表_User),attachments(列表_Attachments),msg_seq,timestamp,event_id,author(嵌套_User:member_openid),group_openid - 源码位置:
connection.py第 205-207 行 |message.py第 190-261 行
on_group_add_robot
机器人加入群聊时触发。
python
async def on_group_add_robot(self, event: GroupManageEvent)事件触发详情
- 触发解析:
parse_group_add_robot→on_group_add_robot - 参数模型:
GroupManageEvent—__slots__包含:event_id,timestamp,group_openid,op_member_openid - 源码位置:
connection.py第 213-215 行 |manage.py第 5-22 行
on_group_del_robot
机器人退出群聊时触发。
python
async def on_group_del_robot(self, event: GroupManageEvent)事件触发详情
- 触发解析:
parse_group_del_robot→on_group_del_robot - 参数模型:
GroupManageEvent—__slots__同on_group_add_robot - 源码位置:
connection.py第 217-219 行 |manage.py第 5-22 行
on_group_msg_reject
群聊拒绝机器人主动消息。
python
async def on_group_msg_reject(self, event: GroupManageEvent)事件触发详情
- 触发解析:
parse_group_msg_reject→on_group_msg_reject - 参数模型:
GroupManageEvent—__slots__同on_group_add_robot - 源码位置:
connection.py第 221-223 行 |manage.py第 5-22 行
on_group_msg_receive
群聊接受机器人主动消息。
python
async def on_group_msg_receive(self, event: GroupManageEvent)事件触发详情
- 触发解析:
parse_group_msg_receive→on_group_msg_receive - 参数模型:
GroupManageEvent—__slots__同on_group_add_robot - 源码位置:
connection.py第 225-227 行 |manage.py第 5-22 行
C2C 管理事件
on_c2c_message_create
当收到 C2C 的消息时触发。
python
async def on_c2c_message_create(self, message: C2CMessage)事件触发详情
- 触发解析:
parse_c2c_message_create→on_c2c_message_create - 参数模型:
C2CMessage—__slots__(继承自BaseMessage+ 自有):content,id,message_reference(嵌套_MessageRef:message_id),mentions(列表_User),attachments(列表_Attachments),msg_seq,timestamp,event_id,author(嵌套_User:user_openid) - 源码位置:
connection.py第 209-211 行 |message.py第 263-283 行
on_friend_add
用户添加机器人为好友时触发。
python
async def on_friend_add(self, event: C2CManageEvent)事件触发详情
- 触发解析:
parse_friend_add→on_friend_add - 参数模型:
C2CManageEvent—__slots__包含:event_id,timestamp,openid - 源码位置:
connection.py第 229-231 行 |manage.py第 25-40 行
on_friend_del
用户删除机器人好友时触发。
python
async def on_friend_del(self, event: C2CManageEvent)事件触发详情
- 触发解析:
parse_friend_del→on_friend_del - 参数模型:
C2CManageEvent—__slots__同on_friend_add - 源码位置:
connection.py第 233-235 行 |manage.py第 25-40 行
on_c2c_msg_reject
用户拒绝机器人主动消息。
python
async def on_c2c_msg_reject(self, event: C2CManageEvent)事件触发详情
- 触发解析:
parse_c2c_msg_reject→on_c2c_msg_reject - 参数模型:
C2CManageEvent—__slots__同on_friend_add - 源码位置:
connection.py第 237-239 行 |manage.py第 25-40 行
on_c2c_msg_receive
用户接受机器人主动消息。
python
async def on_c2c_msg_receive(self, event: C2CManageEvent)事件触发详情
- 触发解析:
parse_c2c_msg_receive→on_c2c_msg_receive - 参数模型:
C2CManageEvent—__slots__同on_friend_add - 源码位置:
connection.py第 241-243 行 |manage.py第 25-40 行
音视频子频道事件
需要 Intents(audio_or_live_channel_member=True)。
on_audio_or_live_channel_member_enter
用户进入音视频/直播子频道时触发。
python
async def on_audio_or_live_channel_member_enter(self, audio: PublicAudio)事件触发详情
- 触发解析:
parse_audio_or_live_channel_member_enter→on_audio_or_live_channel_member_enter - 参数模型:
PublicAudio—__slots__包含:guild_id,channel_id,channel_type,user_id - 源码位置:
connection.py第 273-275 行 |audio.py第 28-45 行
on_audio_or_live_channel_member_exit
用户退出音视频/直播子频道时触发。
python
async def on_audio_or_live_channel_member_exit(self, audio: PublicAudio)事件触发详情
- 触发解析:
parse_audio_or_live_channel_member_exit→on_audio_or_live_channel_member_exit - 参数模型:
PublicAudio—__slots__同on_audio_or_live_channel_member_enter - 源码位置:
connection.py第 277-279 行 |audio.py第 28-45 行