-
Notifications
You must be signed in to change notification settings - Fork 9
/
intf_group.go
110 lines (93 loc) · 3.88 KB
/
intf_group.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// 接口定义 - 单级群组接口
package libonebot
import "time"
// 群消息事件
// https://12.onebot.dev/interface/group/message-events/
// GroupMessageEvent 表示一个群消息事件.
type GroupMessageEvent struct {
MessageEvent
GroupID string `json:"group_id"` // 群 ID
UserID string `json:"user_id"` // 用户 ID
}
// MakeGroupMessageEvent 构造一个群消息事件.
func MakeGroupMessageEvent(time time.Time, messageID string, message Message, alt_message string, groupID string, userID string) GroupMessageEvent {
return GroupMessageEvent{
MessageEvent: MakeMessageEvent(time, "group", messageID, message, alt_message),
GroupID: groupID,
UserID: userID,
}
}
// 群通知事件
// https://12.onebot.dev/interface/group/notice-events/
// GroupMemberIncreaseNoticeEvent 表示一个群成员增加通知事件.
type GroupMemberIncreaseNoticeEvent struct {
NoticeEvent
GroupID string `json:"group_id"` // 群 ID
UserID string `json:"user_id"` // 用户 ID
OperatorID string `json:"operator_id"` // 操作者 ID
}
const (
GroupMemberIncreaseNoticeEventSubTypeJoin = "join" // 成员主动加入
GroupMemberIncreaseNoticeEventSubTypeInvite = "invite" // 成员被邀请加入
)
// MakeGroupMemberIncreaseNoticeEvent 构造一个群成员增加通知事件.
func MakeGroupMemberIncreaseNoticeEvent(time time.Time, groupID string, userID string, operatorID string) GroupMemberIncreaseNoticeEvent {
return GroupMemberIncreaseNoticeEvent{
NoticeEvent: MakeNoticeEvent(time, "group_member_increase"),
GroupID: groupID,
UserID: userID,
OperatorID: operatorID,
}
}
// GroupMemberDecreaseNoticeEvent 表示一个群成员减少通知事件.
type GroupMemberDecreaseNoticeEvent struct {
NoticeEvent
GroupID string `json:"group_id"` // 群 ID
UserID string `json:"user_id"` // 用户 ID
OperatorID string `json:"operator_id"` // 操作者 ID
}
const (
GroupMemberDecreaseNoticeEventSubTypeLeave = "leave" // 成员主动退出
GroupMemberDecreaseNoticeEventSubTypeKick = "kick" // 成员被踢出
)
// MakeGroupMemberDecreaseNoticeEvent 构造一个群成员减少通知事件.
func MakeGroupMemberDecreaseNoticeEvent(time time.Time, groupID string, userID string, operatorID string) GroupMemberDecreaseNoticeEvent {
return GroupMemberDecreaseNoticeEvent{
NoticeEvent: MakeNoticeEvent(time, "group_member_decrease"),
GroupID: groupID,
UserID: userID,
OperatorID: operatorID,
}
}
// GroupMessageDeleteNoticeEvent 表示一个群消息删除通知事件.
type GroupMessageDeleteNoticeEvent struct {
NoticeEvent
GroupID string `json:"group_id"` // 群 ID
MessageID string `json:"message_id"` // 消息 ID
UserID string `json:"user_id"` // 消息发送者 ID
OperatorID string `json:"operator_id"` // 操作者 ID
}
const (
GroupMessageDeleteNoticeEventSubTypeRecall = "recall" // 发送者主动删除
GroupMessageDeleteNoticeEventSubTypeDelete = "delete" // 管理员删除
)
// MakeGroupMessageDeleteNoticeEvent 构造一个群消息删除通知事件.
func MakeGroupMessageDeleteNoticeEvent(time time.Time, groupID string, messageID string, userID string, operatorID string) GroupMessageDeleteNoticeEvent {
return GroupMessageDeleteNoticeEvent{
NoticeEvent: MakeNoticeEvent(time, "group_message_delete"),
GroupID: groupID,
MessageID: messageID,
UserID: userID,
OperatorID: operatorID,
}
}
// 群动作
// https://12.onebot.dev/interface/group/actions/
const (
ActionGetGroupInfo = "get_group_info" // 获取群信息
ActionGetGroupList = "get_group_list" // 获取群列表
ActionGetGroupMemberInfo = "get_group_member_info" // 获取群成员信息
ActionGetGroupMemberList = "get_group_member_list" // 获取群成员列表
ActionSetGroupName = "set_group_name" // 设置群名称
ActionLeaveGroup = "leave_group" // 退出群
)