-
Notifications
You must be signed in to change notification settings - Fork 101
/
botCommandScope.go
executable file
·266 lines (216 loc) · 9.34 KB
/
botCommandScope.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
// AUTOGENERATED - DO NOT EDIT
package tdlib
import (
"encoding/json"
"fmt"
)
// BotCommandScope Represents the scope to which bot commands are relevant
type BotCommandScope interface {
GetBotCommandScopeEnum() BotCommandScopeEnum
}
// BotCommandScopeEnum Alias for abstract BotCommandScope 'Sub-Classes', used as constant-enum here
type BotCommandScopeEnum string
// BotCommandScope enums
const (
BotCommandScopeDefaultType BotCommandScopeEnum = "botCommandScopeDefault"
BotCommandScopeAllPrivateChatsType BotCommandScopeEnum = "botCommandScopeAllPrivateChats"
BotCommandScopeAllGroupChatsType BotCommandScopeEnum = "botCommandScopeAllGroupChats"
BotCommandScopeAllChatAdministratorsType BotCommandScopeEnum = "botCommandScopeAllChatAdministrators"
BotCommandScopeChatType BotCommandScopeEnum = "botCommandScopeChat"
BotCommandScopeChatAdministratorsType BotCommandScopeEnum = "botCommandScopeChatAdministrators"
BotCommandScopeChatMemberType BotCommandScopeEnum = "botCommandScopeChatMember"
)
func unmarshalBotCommandScope(rawMsg *json.RawMessage) (BotCommandScope, error) {
if rawMsg == nil {
return nil, nil
}
var objMap map[string]interface{}
err := json.Unmarshal(*rawMsg, &objMap)
if err != nil {
return nil, err
}
switch BotCommandScopeEnum(objMap["@type"].(string)) {
case BotCommandScopeDefaultType:
var botCommandScopeDefault BotCommandScopeDefault
err := json.Unmarshal(*rawMsg, &botCommandScopeDefault)
return &botCommandScopeDefault, err
case BotCommandScopeAllPrivateChatsType:
var botCommandScopeAllPrivateChats BotCommandScopeAllPrivateChats
err := json.Unmarshal(*rawMsg, &botCommandScopeAllPrivateChats)
return &botCommandScopeAllPrivateChats, err
case BotCommandScopeAllGroupChatsType:
var botCommandScopeAllGroupChats BotCommandScopeAllGroupChats
err := json.Unmarshal(*rawMsg, &botCommandScopeAllGroupChats)
return &botCommandScopeAllGroupChats, err
case BotCommandScopeAllChatAdministratorsType:
var botCommandScopeAllChatAdministrators BotCommandScopeAllChatAdministrators
err := json.Unmarshal(*rawMsg, &botCommandScopeAllChatAdministrators)
return &botCommandScopeAllChatAdministrators, err
case BotCommandScopeChatType:
var botCommandScopeChat BotCommandScopeChat
err := json.Unmarshal(*rawMsg, &botCommandScopeChat)
return &botCommandScopeChat, err
case BotCommandScopeChatAdministratorsType:
var botCommandScopeChatAdministrators BotCommandScopeChatAdministrators
err := json.Unmarshal(*rawMsg, &botCommandScopeChatAdministrators)
return &botCommandScopeChatAdministrators, err
case BotCommandScopeChatMemberType:
var botCommandScopeChatMember BotCommandScopeChatMember
err := json.Unmarshal(*rawMsg, &botCommandScopeChatMember)
return &botCommandScopeChatMember, err
default:
return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))
}
}
// BotCommandScopeDefault A scope covering all users
type BotCommandScopeDefault struct {
tdCommon
}
// MessageType return the string telegram-type of BotCommandScopeDefault
func (botCommandScopeDefault *BotCommandScopeDefault) MessageType() string {
return "botCommandScopeDefault"
}
// NewBotCommandScopeDefault creates a new BotCommandScopeDefault
//
func NewBotCommandScopeDefault() *BotCommandScopeDefault {
botCommandScopeDefaultTemp := BotCommandScopeDefault{
tdCommon: tdCommon{Type: "botCommandScopeDefault"},
}
return &botCommandScopeDefaultTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeDefault *BotCommandScopeDefault) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeDefaultType
}
// BotCommandScopeAllPrivateChats A scope covering all private chats
type BotCommandScopeAllPrivateChats struct {
tdCommon
}
// MessageType return the string telegram-type of BotCommandScopeAllPrivateChats
func (botCommandScopeAllPrivateChats *BotCommandScopeAllPrivateChats) MessageType() string {
return "botCommandScopeAllPrivateChats"
}
// NewBotCommandScopeAllPrivateChats creates a new BotCommandScopeAllPrivateChats
//
func NewBotCommandScopeAllPrivateChats() *BotCommandScopeAllPrivateChats {
botCommandScopeAllPrivateChatsTemp := BotCommandScopeAllPrivateChats{
tdCommon: tdCommon{Type: "botCommandScopeAllPrivateChats"},
}
return &botCommandScopeAllPrivateChatsTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeAllPrivateChats *BotCommandScopeAllPrivateChats) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeAllPrivateChatsType
}
// BotCommandScopeAllGroupChats A scope covering all group and supergroup chats
type BotCommandScopeAllGroupChats struct {
tdCommon
}
// MessageType return the string telegram-type of BotCommandScopeAllGroupChats
func (botCommandScopeAllGroupChats *BotCommandScopeAllGroupChats) MessageType() string {
return "botCommandScopeAllGroupChats"
}
// NewBotCommandScopeAllGroupChats creates a new BotCommandScopeAllGroupChats
//
func NewBotCommandScopeAllGroupChats() *BotCommandScopeAllGroupChats {
botCommandScopeAllGroupChatsTemp := BotCommandScopeAllGroupChats{
tdCommon: tdCommon{Type: "botCommandScopeAllGroupChats"},
}
return &botCommandScopeAllGroupChatsTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeAllGroupChats *BotCommandScopeAllGroupChats) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeAllGroupChatsType
}
// BotCommandScopeAllChatAdministrators A scope covering all group and supergroup chat administrators
type BotCommandScopeAllChatAdministrators struct {
tdCommon
}
// MessageType return the string telegram-type of BotCommandScopeAllChatAdministrators
func (botCommandScopeAllChatAdministrators *BotCommandScopeAllChatAdministrators) MessageType() string {
return "botCommandScopeAllChatAdministrators"
}
// NewBotCommandScopeAllChatAdministrators creates a new BotCommandScopeAllChatAdministrators
//
func NewBotCommandScopeAllChatAdministrators() *BotCommandScopeAllChatAdministrators {
botCommandScopeAllChatAdministratorsTemp := BotCommandScopeAllChatAdministrators{
tdCommon: tdCommon{Type: "botCommandScopeAllChatAdministrators"},
}
return &botCommandScopeAllChatAdministratorsTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeAllChatAdministrators *BotCommandScopeAllChatAdministrators) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeAllChatAdministratorsType
}
// BotCommandScopeChat A scope covering all members of a chat
type BotCommandScopeChat struct {
tdCommon
ChatID int64 `json:"chat_id"` // Chat identifier
}
// MessageType return the string telegram-type of BotCommandScopeChat
func (botCommandScopeChat *BotCommandScopeChat) MessageType() string {
return "botCommandScopeChat"
}
// NewBotCommandScopeChat creates a new BotCommandScopeChat
//
// @param chatID Chat identifier
func NewBotCommandScopeChat(chatID int64) *BotCommandScopeChat {
botCommandScopeChatTemp := BotCommandScopeChat{
tdCommon: tdCommon{Type: "botCommandScopeChat"},
ChatID: chatID,
}
return &botCommandScopeChatTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeChat *BotCommandScopeChat) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeChatType
}
// BotCommandScopeChatAdministrators A scope covering all administrators of a chat
type BotCommandScopeChatAdministrators struct {
tdCommon
ChatID int64 `json:"chat_id"` // Chat identifier
}
// MessageType return the string telegram-type of BotCommandScopeChatAdministrators
func (botCommandScopeChatAdministrators *BotCommandScopeChatAdministrators) MessageType() string {
return "botCommandScopeChatAdministrators"
}
// NewBotCommandScopeChatAdministrators creates a new BotCommandScopeChatAdministrators
//
// @param chatID Chat identifier
func NewBotCommandScopeChatAdministrators(chatID int64) *BotCommandScopeChatAdministrators {
botCommandScopeChatAdministratorsTemp := BotCommandScopeChatAdministrators{
tdCommon: tdCommon{Type: "botCommandScopeChatAdministrators"},
ChatID: chatID,
}
return &botCommandScopeChatAdministratorsTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeChatAdministrators *BotCommandScopeChatAdministrators) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeChatAdministratorsType
}
// BotCommandScopeChatMember A scope covering a member of a chat
type BotCommandScopeChatMember struct {
tdCommon
ChatID int64 `json:"chat_id"` // Chat identifier
UserID int64 `json:"user_id"` // User identifier
}
// MessageType return the string telegram-type of BotCommandScopeChatMember
func (botCommandScopeChatMember *BotCommandScopeChatMember) MessageType() string {
return "botCommandScopeChatMember"
}
// NewBotCommandScopeChatMember creates a new BotCommandScopeChatMember
//
// @param chatID Chat identifier
// @param userID User identifier
func NewBotCommandScopeChatMember(chatID int64, userID int64) *BotCommandScopeChatMember {
botCommandScopeChatMemberTemp := BotCommandScopeChatMember{
tdCommon: tdCommon{Type: "botCommandScopeChatMember"},
ChatID: chatID,
UserID: userID,
}
return &botCommandScopeChatMemberTemp
}
// GetBotCommandScopeEnum return the enum type of this object
func (botCommandScopeChatMember *BotCommandScopeChatMember) GetBotCommandScopeEnum() BotCommandScopeEnum {
return BotCommandScopeChatMemberType
}