blob: bee6b75519f7e0c8b70235a6db1a6a73da0ac2d2 (
plain) (
blame)
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
|
package gumble
import (
"layeh.com/gumble/gumble/MumbleProto"
)
// ContextActionType is a bitmask of contexts where a ContextAction can be
// triggered.
type ContextActionType int
// Supported ContextAction contexts.
const (
ContextActionServer ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Server)
ContextActionChannel ContextActionType = ContextActionType(MumbleProto.ContextActionModify_Channel)
ContextActionUser ContextActionType = ContextActionType(MumbleProto.ContextActionModify_User)
)
// ContextAction is an triggerable item that has been added by a server-side
// plugin.
type ContextAction struct {
// The context action type.
Type ContextActionType
// The name of the context action.
Name string
// The user-friendly description of the context action.
Label string
client *Client
}
// Trigger will trigger the context action in the context of the server.
func (c *ContextAction) Trigger() {
packet := MumbleProto.ContextAction{
Action: &c.Name,
}
c.client.Conn.WriteProto(&packet)
}
// TriggerUser will trigger the context action in the context of the given
// user.
func (c *ContextAction) TriggerUser(user *User) {
packet := MumbleProto.ContextAction{
Session: &user.Session,
Action: &c.Name,
}
c.client.Conn.WriteProto(&packet)
}
// TriggerChannel will trigger the context action in the context of the given
// channel.
func (c *ContextAction) TriggerChannel(channel *Channel) {
packet := MumbleProto.ContextAction{
ChannelId: &channel.ID,
Action: &c.Name,
}
c.client.Conn.WriteProto(&packet)
}
|