-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchat_type.go
51 lines (41 loc) · 1.05 KB
/
chat_type.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
package tdproto
import (
"log"
)
// Chat type
type ChatType string
const (
// Direct chat
DirectChatType ChatType = "direct"
// Group chat
GroupChatType ChatType = "group"
// Task
TaskChatType ChatType = "task"
//Meeting
MeetingChatType ChatType = "meeting"
// Thread chat
ThreadChatType ChatType = "thread"
)
func (ct ChatType) JidPrefix() string {
switch ct {
case DirectChatType:
return ContactPrefix
case GroupChatType:
return GroupPrefix
case TaskChatType:
return TaskPrefix
case MeetingChatType:
return MeetingPrefix
case ThreadChatType:
return ThreadPrefix
default:
log.Panicf("JidPrefix(): incorrect chat type: %s", ct)
return ""
}
}
func (ct ChatType) String() string { return string(ct) }
func (ct ChatType) IsDirect() bool { return ct == DirectChatType }
func (ct ChatType) IsGroup() bool { return ct == GroupChatType }
func (ct ChatType) IsTask() bool { return ct == TaskChatType }
func (ct ChatType) IsMeeting() bool { return ct == MeetingChatType }
func (ct ChatType) IsThread() bool { return ct == ThreadChatType }