This repository has been archived by the owner on Jul 3, 2022. It is now read-only.
forked from Arman92/go-tdlib
/
userPrivacySettingRule.go
295 lines (240 loc) · 12.9 KB
/
userPrivacySettingRule.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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
package tdlib
import (
"encoding/json"
"fmt"
)
// UserPrivacySettingRule Represents a single rule for managing privacy settings
type UserPrivacySettingRule interface {
GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum
}
// UserPrivacySettingRuleEnum Alias for abstract UserPrivacySettingRule 'Sub-Classes', used as constant-enum here
type UserPrivacySettingRuleEnum string
// UserPrivacySettingRule enums
const (
UserPrivacySettingRuleAllowAllType UserPrivacySettingRuleEnum = "userPrivacySettingRuleAllowAll"
UserPrivacySettingRuleAllowContactsType UserPrivacySettingRuleEnum = "userPrivacySettingRuleAllowContacts"
UserPrivacySettingRuleAllowUsersType UserPrivacySettingRuleEnum = "userPrivacySettingRuleAllowUsers"
UserPrivacySettingRuleAllowChatMembersType UserPrivacySettingRuleEnum = "userPrivacySettingRuleAllowChatMembers"
UserPrivacySettingRuleRestrictAllType UserPrivacySettingRuleEnum = "userPrivacySettingRuleRestrictAll"
UserPrivacySettingRuleRestrictContactsType UserPrivacySettingRuleEnum = "userPrivacySettingRuleRestrictContacts"
UserPrivacySettingRuleRestrictUsersType UserPrivacySettingRuleEnum = "userPrivacySettingRuleRestrictUsers"
UserPrivacySettingRuleRestrictChatMembersType UserPrivacySettingRuleEnum = "userPrivacySettingRuleRestrictChatMembers"
)
func unmarshalUserPrivacySettingRule(rawMsg *json.RawMessage) (UserPrivacySettingRule, error) {
if rawMsg == nil {
return nil, nil
}
var objMap map[string]interface{}
err := json.Unmarshal(*rawMsg, &objMap)
if err != nil {
return nil, err
}
switch UserPrivacySettingRuleEnum(objMap["@type"].(string)) {
case UserPrivacySettingRuleAllowAllType:
var userPrivacySettingRuleAllowAll UserPrivacySettingRuleAllowAll
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleAllowAll)
return &userPrivacySettingRuleAllowAll, err
case UserPrivacySettingRuleAllowContactsType:
var userPrivacySettingRuleAllowContacts UserPrivacySettingRuleAllowContacts
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleAllowContacts)
return &userPrivacySettingRuleAllowContacts, err
case UserPrivacySettingRuleAllowUsersType:
var userPrivacySettingRuleAllowUsers UserPrivacySettingRuleAllowUsers
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleAllowUsers)
return &userPrivacySettingRuleAllowUsers, err
case UserPrivacySettingRuleAllowChatMembersType:
var userPrivacySettingRuleAllowChatMembers UserPrivacySettingRuleAllowChatMembers
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleAllowChatMembers)
return &userPrivacySettingRuleAllowChatMembers, err
case UserPrivacySettingRuleRestrictAllType:
var userPrivacySettingRuleRestrictAll UserPrivacySettingRuleRestrictAll
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleRestrictAll)
return &userPrivacySettingRuleRestrictAll, err
case UserPrivacySettingRuleRestrictContactsType:
var userPrivacySettingRuleRestrictContacts UserPrivacySettingRuleRestrictContacts
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleRestrictContacts)
return &userPrivacySettingRuleRestrictContacts, err
case UserPrivacySettingRuleRestrictUsersType:
var userPrivacySettingRuleRestrictUsers UserPrivacySettingRuleRestrictUsers
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleRestrictUsers)
return &userPrivacySettingRuleRestrictUsers, err
case UserPrivacySettingRuleRestrictChatMembersType:
var userPrivacySettingRuleRestrictChatMembers UserPrivacySettingRuleRestrictChatMembers
err := json.Unmarshal(*rawMsg, &userPrivacySettingRuleRestrictChatMembers)
return &userPrivacySettingRuleRestrictChatMembers, err
default:
return nil, fmt.Errorf("Error UnMarshaling, unknown type:" + objMap["@type"].(string))
}
}
// UserPrivacySettingRuleAllowAll A rule to allow all users to do something
type UserPrivacySettingRuleAllowAll struct {
tdCommon
}
// MessageType return the string telegram-type of UserPrivacySettingRuleAllowAll
func (userPrivacySettingRuleAllowAll *UserPrivacySettingRuleAllowAll) MessageType() string {
return "userPrivacySettingRuleAllowAll"
}
// NewUserPrivacySettingRuleAllowAll creates a new UserPrivacySettingRuleAllowAll
//
func NewUserPrivacySettingRuleAllowAll() *UserPrivacySettingRuleAllowAll {
userPrivacySettingRuleAllowAllTemp := UserPrivacySettingRuleAllowAll{
tdCommon: tdCommon{Type: "userPrivacySettingRuleAllowAll"},
}
return &userPrivacySettingRuleAllowAllTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleAllowAll *UserPrivacySettingRuleAllowAll) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleAllowAllType
}
// UserPrivacySettingRuleAllowContacts A rule to allow all of a user's contacts to do something
type UserPrivacySettingRuleAllowContacts struct {
tdCommon
}
// MessageType return the string telegram-type of UserPrivacySettingRuleAllowContacts
func (userPrivacySettingRuleAllowContacts *UserPrivacySettingRuleAllowContacts) MessageType() string {
return "userPrivacySettingRuleAllowContacts"
}
// NewUserPrivacySettingRuleAllowContacts creates a new UserPrivacySettingRuleAllowContacts
//
func NewUserPrivacySettingRuleAllowContacts() *UserPrivacySettingRuleAllowContacts {
userPrivacySettingRuleAllowContactsTemp := UserPrivacySettingRuleAllowContacts{
tdCommon: tdCommon{Type: "userPrivacySettingRuleAllowContacts"},
}
return &userPrivacySettingRuleAllowContactsTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleAllowContacts *UserPrivacySettingRuleAllowContacts) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleAllowContactsType
}
// UserPrivacySettingRuleAllowUsers A rule to allow certain specified users to do something
type UserPrivacySettingRuleAllowUsers struct {
tdCommon
UserIds []int64 `json:"user_ids"` // The user identifiers, total number of users in all rules must not exceed 1000
}
// MessageType return the string telegram-type of UserPrivacySettingRuleAllowUsers
func (userPrivacySettingRuleAllowUsers *UserPrivacySettingRuleAllowUsers) MessageType() string {
return "userPrivacySettingRuleAllowUsers"
}
// NewUserPrivacySettingRuleAllowUsers creates a new UserPrivacySettingRuleAllowUsers
//
// @param userIds The user identifiers, total number of users in all rules must not exceed 1000
func NewUserPrivacySettingRuleAllowUsers(userIds []int64) *UserPrivacySettingRuleAllowUsers {
userPrivacySettingRuleAllowUsersTemp := UserPrivacySettingRuleAllowUsers{
tdCommon: tdCommon{Type: "userPrivacySettingRuleAllowUsers"},
UserIds: userIds,
}
return &userPrivacySettingRuleAllowUsersTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleAllowUsers *UserPrivacySettingRuleAllowUsers) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleAllowUsersType
}
// UserPrivacySettingRuleAllowChatMembers A rule to allow all members of certain specified basic groups and supergroups to doing something
type UserPrivacySettingRuleAllowChatMembers struct {
tdCommon
ChatIds []int64 `json:"chat_ids"` // The chat identifiers, total number of chats in all rules must not exceed 20
}
// MessageType return the string telegram-type of UserPrivacySettingRuleAllowChatMembers
func (userPrivacySettingRuleAllowChatMembers *UserPrivacySettingRuleAllowChatMembers) MessageType() string {
return "userPrivacySettingRuleAllowChatMembers"
}
// NewUserPrivacySettingRuleAllowChatMembers creates a new UserPrivacySettingRuleAllowChatMembers
//
// @param chatIds The chat identifiers, total number of chats in all rules must not exceed 20
func NewUserPrivacySettingRuleAllowChatMembers(chatIds []int64) *UserPrivacySettingRuleAllowChatMembers {
userPrivacySettingRuleAllowChatMembersTemp := UserPrivacySettingRuleAllowChatMembers{
tdCommon: tdCommon{Type: "userPrivacySettingRuleAllowChatMembers"},
ChatIds: chatIds,
}
return &userPrivacySettingRuleAllowChatMembersTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleAllowChatMembers *UserPrivacySettingRuleAllowChatMembers) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleAllowChatMembersType
}
// UserPrivacySettingRuleRestrictAll A rule to restrict all users from doing something
type UserPrivacySettingRuleRestrictAll struct {
tdCommon
}
// MessageType return the string telegram-type of UserPrivacySettingRuleRestrictAll
func (userPrivacySettingRuleRestrictAll *UserPrivacySettingRuleRestrictAll) MessageType() string {
return "userPrivacySettingRuleRestrictAll"
}
// NewUserPrivacySettingRuleRestrictAll creates a new UserPrivacySettingRuleRestrictAll
//
func NewUserPrivacySettingRuleRestrictAll() *UserPrivacySettingRuleRestrictAll {
userPrivacySettingRuleRestrictAllTemp := UserPrivacySettingRuleRestrictAll{
tdCommon: tdCommon{Type: "userPrivacySettingRuleRestrictAll"},
}
return &userPrivacySettingRuleRestrictAllTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleRestrictAll *UserPrivacySettingRuleRestrictAll) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleRestrictAllType
}
// UserPrivacySettingRuleRestrictContacts A rule to restrict all contacts of a user from doing something
type UserPrivacySettingRuleRestrictContacts struct {
tdCommon
}
// MessageType return the string telegram-type of UserPrivacySettingRuleRestrictContacts
func (userPrivacySettingRuleRestrictContacts *UserPrivacySettingRuleRestrictContacts) MessageType() string {
return "userPrivacySettingRuleRestrictContacts"
}
// NewUserPrivacySettingRuleRestrictContacts creates a new UserPrivacySettingRuleRestrictContacts
//
func NewUserPrivacySettingRuleRestrictContacts() *UserPrivacySettingRuleRestrictContacts {
userPrivacySettingRuleRestrictContactsTemp := UserPrivacySettingRuleRestrictContacts{
tdCommon: tdCommon{Type: "userPrivacySettingRuleRestrictContacts"},
}
return &userPrivacySettingRuleRestrictContactsTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleRestrictContacts *UserPrivacySettingRuleRestrictContacts) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleRestrictContactsType
}
// UserPrivacySettingRuleRestrictUsers A rule to restrict all specified users from doing something
type UserPrivacySettingRuleRestrictUsers struct {
tdCommon
UserIds []int64 `json:"user_ids"` // The user identifiers, total number of users in all rules must not exceed 1000
}
// MessageType return the string telegram-type of UserPrivacySettingRuleRestrictUsers
func (userPrivacySettingRuleRestrictUsers *UserPrivacySettingRuleRestrictUsers) MessageType() string {
return "userPrivacySettingRuleRestrictUsers"
}
// NewUserPrivacySettingRuleRestrictUsers creates a new UserPrivacySettingRuleRestrictUsers
//
// @param userIds The user identifiers, total number of users in all rules must not exceed 1000
func NewUserPrivacySettingRuleRestrictUsers(userIds []int64) *UserPrivacySettingRuleRestrictUsers {
userPrivacySettingRuleRestrictUsersTemp := UserPrivacySettingRuleRestrictUsers{
tdCommon: tdCommon{Type: "userPrivacySettingRuleRestrictUsers"},
UserIds: userIds,
}
return &userPrivacySettingRuleRestrictUsersTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleRestrictUsers *UserPrivacySettingRuleRestrictUsers) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleRestrictUsersType
}
// UserPrivacySettingRuleRestrictChatMembers A rule to restrict all members of specified basic groups and supergroups from doing something
type UserPrivacySettingRuleRestrictChatMembers struct {
tdCommon
ChatIds []int64 `json:"chat_ids"` // The chat identifiers, total number of chats in all rules must not exceed 20
}
// MessageType return the string telegram-type of UserPrivacySettingRuleRestrictChatMembers
func (userPrivacySettingRuleRestrictChatMembers *UserPrivacySettingRuleRestrictChatMembers) MessageType() string {
return "userPrivacySettingRuleRestrictChatMembers"
}
// NewUserPrivacySettingRuleRestrictChatMembers creates a new UserPrivacySettingRuleRestrictChatMembers
//
// @param chatIds The chat identifiers, total number of chats in all rules must not exceed 20
func NewUserPrivacySettingRuleRestrictChatMembers(chatIds []int64) *UserPrivacySettingRuleRestrictChatMembers {
userPrivacySettingRuleRestrictChatMembersTemp := UserPrivacySettingRuleRestrictChatMembers{
tdCommon: tdCommon{Type: "userPrivacySettingRuleRestrictChatMembers"},
ChatIds: chatIds,
}
return &userPrivacySettingRuleRestrictChatMembersTemp
}
// GetUserPrivacySettingRuleEnum return the enum type of this object
func (userPrivacySettingRuleRestrictChatMembers *UserPrivacySettingRuleRestrictChatMembers) GetUserPrivacySettingRuleEnum() UserPrivacySettingRuleEnum {
return UserPrivacySettingRuleRestrictChatMembersType
}