-
-
Notifications
You must be signed in to change notification settings - Fork 126
/
tl_contacts_block_from_replies_gen.go
292 lines (264 loc) · 7.54 KB
/
tl_contacts_block_from_replies_gen.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
// Code generated by gotdgen, DO NOT EDIT.
package tg
import (
"context"
"errors"
"fmt"
"sort"
"strings"
"go.uber.org/multierr"
"github.com/gotd/td/bin"
"github.com/gotd/td/tdp"
"github.com/gotd/td/tgerr"
)
// No-op definition for keeping imports.
var (
_ = bin.Buffer{}
_ = context.Background()
_ = fmt.Stringer(nil)
_ = strings.Builder{}
_ = errors.Is
_ = multierr.AppendInto
_ = sort.Ints
_ = tdp.Format
_ = tgerr.Error{}
)
// ContactsBlockFromRepliesRequest represents TL type `contacts.blockFromReplies#29a8962c`.
// Stop getting notifications about thread replies¹ of a certain user in @replies
//
// Links:
// 1) https://core.telegram.org/api/threads
//
// See https://core.telegram.org/method/contacts.blockFromReplies for reference.
type ContactsBlockFromRepliesRequest struct {
// Flags, see TL conditional fields¹
//
// Links:
// 1) https://core.telegram.org/mtproto/TL-combinators#conditional-fields
Flags bin.Fields
// Whether to delete the specified message as well
DeleteMessage bool
// Whether to delete all @replies messages from this user as well
DeleteHistory bool
// Whether to also report this user for spam
ReportSpam bool
// ID of the message in the @replies¹ chat
//
// Links:
// 1) https://core.telegram.org/api/threads#replies
MsgID int
}
// ContactsBlockFromRepliesRequestTypeID is TL type id of ContactsBlockFromRepliesRequest.
const ContactsBlockFromRepliesRequestTypeID = 0x29a8962c
func (b *ContactsBlockFromRepliesRequest) Zero() bool {
if b == nil {
return true
}
if !(b.Flags.Zero()) {
return false
}
if !(b.DeleteMessage == false) {
return false
}
if !(b.DeleteHistory == false) {
return false
}
if !(b.ReportSpam == false) {
return false
}
if !(b.MsgID == 0) {
return false
}
return true
}
// String implements fmt.Stringer.
func (b *ContactsBlockFromRepliesRequest) String() string {
if b == nil {
return "ContactsBlockFromRepliesRequest(nil)"
}
type Alias ContactsBlockFromRepliesRequest
return fmt.Sprintf("ContactsBlockFromRepliesRequest%+v", Alias(*b))
}
// FillFrom fills ContactsBlockFromRepliesRequest from given interface.
func (b *ContactsBlockFromRepliesRequest) FillFrom(from interface {
GetDeleteMessage() (value bool)
GetDeleteHistory() (value bool)
GetReportSpam() (value bool)
GetMsgID() (value int)
}) {
b.DeleteMessage = from.GetDeleteMessage()
b.DeleteHistory = from.GetDeleteHistory()
b.ReportSpam = from.GetReportSpam()
b.MsgID = from.GetMsgID()
}
// TypeID returns type id in TL schema.
//
// See https://core.telegram.org/mtproto/TL-tl#remarks.
func (*ContactsBlockFromRepliesRequest) TypeID() uint32 {
return ContactsBlockFromRepliesRequestTypeID
}
// TypeName returns name of type in TL schema.
func (*ContactsBlockFromRepliesRequest) TypeName() string {
return "contacts.blockFromReplies"
}
// TypeInfo returns info about TL type.
func (b *ContactsBlockFromRepliesRequest) TypeInfo() tdp.Type {
typ := tdp.Type{
Name: "contacts.blockFromReplies",
ID: ContactsBlockFromRepliesRequestTypeID,
}
if b == nil {
typ.Null = true
return typ
}
typ.Fields = []tdp.Field{
{
Name: "DeleteMessage",
SchemaName: "delete_message",
Null: !b.Flags.Has(0),
},
{
Name: "DeleteHistory",
SchemaName: "delete_history",
Null: !b.Flags.Has(1),
},
{
Name: "ReportSpam",
SchemaName: "report_spam",
Null: !b.Flags.Has(2),
},
{
Name: "MsgID",
SchemaName: "msg_id",
},
}
return typ
}
// Encode implements bin.Encoder.
func (b *ContactsBlockFromRepliesRequest) Encode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode contacts.blockFromReplies#29a8962c as nil")
}
buf.PutID(ContactsBlockFromRepliesRequestTypeID)
return b.EncodeBare(buf)
}
// EncodeBare implements bin.BareEncoder.
func (b *ContactsBlockFromRepliesRequest) EncodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't encode contacts.blockFromReplies#29a8962c as nil")
}
if !(b.DeleteMessage == false) {
b.Flags.Set(0)
}
if !(b.DeleteHistory == false) {
b.Flags.Set(1)
}
if !(b.ReportSpam == false) {
b.Flags.Set(2)
}
if err := b.Flags.Encode(buf); err != nil {
return fmt.Errorf("unable to encode contacts.blockFromReplies#29a8962c: field flags: %w", err)
}
buf.PutInt(b.MsgID)
return nil
}
// SetDeleteMessage sets value of DeleteMessage conditional field.
func (b *ContactsBlockFromRepliesRequest) SetDeleteMessage(value bool) {
if value {
b.Flags.Set(0)
b.DeleteMessage = true
} else {
b.Flags.Unset(0)
b.DeleteMessage = false
}
}
// GetDeleteMessage returns value of DeleteMessage conditional field.
func (b *ContactsBlockFromRepliesRequest) GetDeleteMessage() (value bool) {
return b.Flags.Has(0)
}
// SetDeleteHistory sets value of DeleteHistory conditional field.
func (b *ContactsBlockFromRepliesRequest) SetDeleteHistory(value bool) {
if value {
b.Flags.Set(1)
b.DeleteHistory = true
} else {
b.Flags.Unset(1)
b.DeleteHistory = false
}
}
// GetDeleteHistory returns value of DeleteHistory conditional field.
func (b *ContactsBlockFromRepliesRequest) GetDeleteHistory() (value bool) {
return b.Flags.Has(1)
}
// SetReportSpam sets value of ReportSpam conditional field.
func (b *ContactsBlockFromRepliesRequest) SetReportSpam(value bool) {
if value {
b.Flags.Set(2)
b.ReportSpam = true
} else {
b.Flags.Unset(2)
b.ReportSpam = false
}
}
// GetReportSpam returns value of ReportSpam conditional field.
func (b *ContactsBlockFromRepliesRequest) GetReportSpam() (value bool) {
return b.Flags.Has(2)
}
// GetMsgID returns value of MsgID field.
func (b *ContactsBlockFromRepliesRequest) GetMsgID() (value int) {
return b.MsgID
}
// Decode implements bin.Decoder.
func (b *ContactsBlockFromRepliesRequest) Decode(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode contacts.blockFromReplies#29a8962c to nil")
}
if err := buf.ConsumeID(ContactsBlockFromRepliesRequestTypeID); err != nil {
return fmt.Errorf("unable to decode contacts.blockFromReplies#29a8962c: %w", err)
}
return b.DecodeBare(buf)
}
// DecodeBare implements bin.BareDecoder.
func (b *ContactsBlockFromRepliesRequest) DecodeBare(buf *bin.Buffer) error {
if b == nil {
return fmt.Errorf("can't decode contacts.blockFromReplies#29a8962c to nil")
}
{
if err := b.Flags.Decode(buf); err != nil {
return fmt.Errorf("unable to decode contacts.blockFromReplies#29a8962c: field flags: %w", err)
}
}
b.DeleteMessage = b.Flags.Has(0)
b.DeleteHistory = b.Flags.Has(1)
b.ReportSpam = b.Flags.Has(2)
{
value, err := buf.Int()
if err != nil {
return fmt.Errorf("unable to decode contacts.blockFromReplies#29a8962c: field msg_id: %w", err)
}
b.MsgID = value
}
return nil
}
// Ensuring interfaces in compile-time for ContactsBlockFromRepliesRequest.
var (
_ bin.Encoder = &ContactsBlockFromRepliesRequest{}
_ bin.Decoder = &ContactsBlockFromRepliesRequest{}
_ bin.BareEncoder = &ContactsBlockFromRepliesRequest{}
_ bin.BareDecoder = &ContactsBlockFromRepliesRequest{}
)
// ContactsBlockFromReplies invokes method contacts.blockFromReplies#29a8962c returning error if any.
// Stop getting notifications about thread replies¹ of a certain user in @replies
//
// Links:
// 1) https://core.telegram.org/api/threads
//
// See https://core.telegram.org/method/contacts.blockFromReplies for reference.
// Can be used by bots.
func (c *Client) ContactsBlockFromReplies(ctx context.Context, request *ContactsBlockFromRepliesRequest) (UpdatesClass, error) {
var result UpdatesBox
if err := c.rpc.Invoke(ctx, request, &result); err != nil {
return nil, err
}
return result.Updates, nil
}