@@ -10,8 +10,6 @@ import (
10
10
botsgocore "github.com/bots-go-framework/bots-go-core"
11
11
"net/url"
12
12
"strconv"
13
- "strings"
14
- "time"
15
13
)
16
14
17
15
// APIResponse is a response from the Telegram API with the result
@@ -194,86 +192,6 @@ func (c *Chat) IsChannel() bool {
194
192
return c .Type == "channel"
195
193
}
196
194
197
- // Message is returned by almost every request, and contains data about almost anything.
198
- type Message struct {
199
- MessageID int `json:"message_id"`
200
- From * User `json:"from,omitempty"` // optional
201
- Date int `json:"date"`
202
- Chat * Chat `json:"chat,omitempty"`
203
- ForwardFrom * User `json:"forward_from,omitempty"` // optional
204
- ForwardDate int `json:"forward_date,omitempty"` // optional
205
- ReplyToMessage * Message `json:"reply_to_message,omitempty"` // optional
206
- Text string `json:"text,omitempty"` // optional
207
- Entities * []MessageEntity `json:"entities,omitempty"` // optional
208
- Audio * Audio `json:"audio,omitempty"` // optional
209
- Document * Document `json:"document,omitempty"` // optional
210
- Photo * []PhotoSize `json:"photo,omitempty"` // optional
211
- Sticker * Sticker `json:"sticker,omitempty"` // optional
212
- Video * Video `json:"video,omitempty"` // optional
213
- Voice * Voice `json:"voice,omitempty"` // optional
214
- Caption string `json:"caption,omitempty"` // optional
215
- Contact * Contact `json:"contact,omitempty"` // optional
216
- Location * Location `json:"location,omitempty"` // optional
217
- Venue * Venue `json:"venue,omitempty"` // optional
218
- NewChatParticipant * ChatMember `json:"new_chat_participant,omitempty"` // Obsolete
219
- NewChatMember * ChatMember `json:"new_chat_member,omitempty"` // Obsolete
220
- NewChatMembers []ChatMember `json:"new_chat_members,omitempty"` // optional
221
- LeftChatMember * ChatMember `json:"left_chat_member,omitempty"` // optional
222
- NewChatTitle string `json:"new_chat_title,omitempty"` // optional
223
- NewChatPhoto * []PhotoSize `json:"new_chat_photo,omitempty"` // optional
224
- DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"` // optional
225
- GroupChatCreated bool `json:"group_chat_created,omitempty"` // optional
226
- SuperGroupChatCreated bool `json:"supergroup_chat_created,omitempty"` // optional
227
- ChannelChatCreated bool `json:"channel_chat_created,omitempty"` // optional
228
- MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"` // optional
229
- MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"` // optional
230
- PinnedMessage * Message `json:"pinned_message,omitempty"` // optional
231
- }
232
-
233
- // Time converts the message timestamp into a Time.
234
- func (m * Message ) Time () time.Time {
235
- return time .Unix (int64 (m .Date ), 0 )
236
- }
237
-
238
- // IsCommand returns true if message starts with '/'.
239
- func (m * Message ) IsCommand () bool {
240
- return m .Text != "" && m .Text [0 ] == '/'
241
- }
242
-
243
- // Command checks if the message was a command and if it was, returns the
244
- // command. If the Message was not a command, it returns an empty string.
245
- //
246
- // If the command contains the at bot syntax, it removes the bot name.
247
- func (m * Message ) Command () string {
248
- if ! m .IsCommand () {
249
- return ""
250
- }
251
-
252
- command := strings .SplitN (m .Text , " " , 2 )[0 ][1 :]
253
-
254
- if i := strings .Index (command , "@" ); i != - 1 {
255
- command = command [:i ]
256
- }
257
-
258
- return command
259
- }
260
-
261
- // CommandArguments checks if the message was a command and if it was,
262
- // returns all text after the command name. If the Message was not a
263
- // command, it returns an empty string.
264
- func (m * Message ) CommandArguments () string {
265
- if ! m .IsCommand () {
266
- return ""
267
- }
268
-
269
- split := strings .SplitN (m .Text , " " , 2 )
270
- if len (split ) != 2 {
271
- return ""
272
- }
273
-
274
- return strings .SplitN (m .Text , " " , 2 )[1 ]
275
- }
276
-
277
195
// MessageEntity contains information about data in a Message.
278
196
type MessageEntity struct {
279
197
Type string `json:"type"`
@@ -424,12 +342,27 @@ type KeyboardButtonRequestUsers struct {
424
342
// Must be unique within the message
425
343
RequestID int `json:"request_id"`
426
344
427
- UserIsBot bool `json:"user_is_bot,omitempty"`
428
- UserIsPremium bool `json:"user_is_premium,omitempty"`
429
- MaxQuantity int `json:"max_quantity,omitempty"` // The maximum number of users to be selected; 1-10. Defaults to 1.
430
- RequestName bool `json:"request_name,omitempty"`
345
+ // Optional.
346
+ // Pass True to request bots, pass False to request regular users.
347
+ // If not specified, no additional restrictions are applied.
348
+ UserIsBot bool `json:"user_is_bot,omitempty"`
349
+
350
+ // Optional.
351
+ // Pass True to request premium users, pass False to request non-premium users.
352
+ // If not specified, no additional restrictions are applied.
353
+ UserIsPremium bool `json:"user_is_premium,omitempty"`
354
+
355
+ // Optional. The maximum number of users to be selected; 1-10. Defaults to 1.
356
+ MaxQuantity int `json:"max_quantity,omitempty"`
357
+
358
+ // Optional. Pass True to request the users' first and last names
359
+ RequestName bool `json:"request_name,omitempty"`
360
+
361
+ // Optional. Pass True to request the users' usernames
431
362
RequestUsername bool `json:"request_username,omitempty"`
432
- RequestPhoto bool `json:"request_photo,omitempty"`
363
+
364
+ // Optional. Pass True to request the users' photos
365
+ RequestPhoto bool `json:"request_photo,omitempty"`
433
366
}
434
367
435
368
// KeyboardButtonRequestChat represents a request from the bot to send a chat
0 commit comments