Skip to content

Commit 977cecc

Browse files
committed
Add missing update for Bot API 5.6
1 parent 3359c47 commit 977cecc

File tree

1 file changed

+53
-19
lines changed

1 file changed

+53
-19
lines changed

src/telebot/private/api.nim

Lines changed: 53 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from tables import hasKey, `[]`
33
import types, keyboard
44

55
proc sendMessage*(b: TeleBot, chatId: int64, text: string, parseMode = "", entities: seq[MessageEntity] = @[],
6-
disableWebPagePreview = false, disableNotification = false, replyToMessageId = 0,
6+
disableWebPagePreview = false, disableNotification = false, protectContent = false, replyToMessageId = 0,
77
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
88
var data = newMultipartData()
99

@@ -19,6 +19,8 @@ proc sendMessage*(b: TeleBot, chatId: int64, text: string, parseMode = "", entit
1919
data["disable_web_page_preview"] = "true"
2020
if disableNotification:
2121
data["disable_notification"] = "true"
22+
if protectContent:
23+
data["protect_content"] = "true"
2224
if replyToMessageId != 0:
2325
data["reply_to_message_id"] = $replyToMessageId
2426
if allowSendingWithoutReply:
@@ -30,7 +32,7 @@ proc sendMessage*(b: TeleBot, chatId: int64, text: string, parseMode = "", entit
3032
result = getMessage(res)
3133

3234
proc sendPhoto*(b: TeleBot, chatId: int64, photo: string, caption = "", parseMode = "",
33-
captionEntities: seq[MessageEntity] = @[], disableNotification = false, replyToMessageId = 0,
35+
captionEntities: seq[MessageEntity] = @[], disableNotification = false, protectContent = false, replyToMessageId = 0,
3436
allowSendingWithoutReply = false,replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
3537
var data = newMultipartData()
3638

@@ -46,6 +48,8 @@ proc sendPhoto*(b: TeleBot, chatId: int64, photo: string, caption = "", parseMod
4648
data["caption_entities"] = json
4749
if disableNotification:
4850
data["disable_notification"] = "true"
51+
if protectContent:
52+
data["protect_content"] = "true"
4953
if replyToMessageId != 0:
5054
data["reply_to_message_id"] = $replyToMessageId
5155
if allowSendingWithoutReply:
@@ -57,7 +61,7 @@ proc sendPhoto*(b: TeleBot, chatId: int64, photo: string, caption = "", parseMod
5761
result = getMessage(res)
5862

5963
proc sendAudio*(b: TeleBot, chatId: int64, audio: string, caption = "", parseMode = "", captionEntities: seq[MessageEntity] = @[],
60-
duration = 0, performer = "", title = "", thumb = "", disableNotification = false, replyToMessageId = 0,
64+
duration = 0, performer = "", title = "", thumb = "", disableNotification = false, protectContent = false, replyToMessageId = 0,
6165
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
6266
var data = newMultipartData()
6367

@@ -81,6 +85,8 @@ proc sendAudio*(b: TeleBot, chatId: int64, audio: string, caption = "", parseMod
8185
data.addData("thumb", thumb, true)
8286
if disableNotification:
8387
data["disable_notification"] = "true"
88+
if protectContent:
89+
data["protect_content"] = "true"
8490
if replyToMessageId != 0:
8591
data["reply_to_message_id"] = $replyToMessageId
8692
if allowSendingWithoutReply:
@@ -93,7 +99,7 @@ proc sendAudio*(b: TeleBot, chatId: int64, audio: string, caption = "", parseMod
9399

94100
proc sendDocument*(b: TeleBot, chatId: int64, document: string, thumb = "", caption = "",
95101
disableContentTypeDetection = false, parseMode = "", captionEntities: seq[MessageEntity] = @[], disableNotification = false,
96-
replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
102+
protectContent = false, replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
97103
var data = newMultipartData()
98104

99105
data["chat_id"] = $chatId
@@ -112,6 +118,8 @@ proc sendDocument*(b: TeleBot, chatId: int64, document: string, thumb = "", capt
112118
data["caption_entities"] = json
113119
if disableNotification:
114120
data["disable_notification"] = "true"
121+
if protectContent:
122+
data["protect_content"] = "true"
115123
if replyToMessageId != 0:
116124
data["reply_to_message_id"] = $replyToMessageId
117125
if allowSendingWithoutReply:
@@ -122,14 +130,16 @@ proc sendDocument*(b: TeleBot, chatId: int64, document: string, thumb = "", capt
122130
let res = await makeRequest(b, procName, data)
123131
result = getMessage(res)
124132

125-
proc sendSticker*(b: TeleBot, chatId: int64, sticker: string, disableNotification = false, replyToMessageId = 0,
133+
proc sendSticker*(b: TeleBot, chatId: int64, sticker: string, disableNotification = false, protectContent = false, replyToMessageId = 0,
126134
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
127135
var data = newMultipartData()
128136

129137
data["chat_id"] = $chatId
130138
data.addData("sticker", sticker, true)
131139
if disableNotification:
132140
data["disable_notification"] = "true"
141+
if protectContent:
142+
data["protect_content"] = "true"
133143
if replyToMessageId != 0:
134144
data["reply_to_message_id"] = $replyToMessageId
135145
if allowSendingWithoutReply:
@@ -142,7 +152,7 @@ proc sendSticker*(b: TeleBot, chatId: int64, sticker: string, disableNotificatio
142152

143153
proc sendVideo*(b: TeleBot, chatId: int64, video: string, duration = 0, width = 0, height = 0, thumb = "", caption = "",
144154
parseMode = "", captionEntities: seq[MessageEntity] = @[], supportsStreaming = false, disableNotification = false,
145-
replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
155+
protectContent = false, replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
146156
var data = newMultipartData()
147157

148158
data["chat_id"] = $chatId
@@ -167,6 +177,8 @@ proc sendVideo*(b: TeleBot, chatId: int64, video: string, duration = 0, width =
167177
data["supports_streaming"] = "true"
168178
if disableNotification:
169179
data["disable_notification"] = "true"
180+
if protectContent:
181+
data["protect_content"] = "true"
170182
if replyToMessageId != 0:
171183
data["reply_to_message_id"] = $replyToMessageId
172184
if allowSendingWithoutReply:
@@ -178,7 +190,7 @@ proc sendVideo*(b: TeleBot, chatId: int64, video: string, duration = 0, width =
178190
result = getMessage(res)
179191

180192
proc sendVoice*(b: TeleBot, chatId: int64, voice: string, caption = "", parseMode = "", captionEntities: seq[MessageEntity] = @[],
181-
duration = 0, disableNotification = false, replyToMessageId = 0,
193+
duration = 0, disableNotification = false, protectContent = false, replyToMessageId = 0,
182194
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
183195
var data = newMultipartData()
184196

@@ -196,6 +208,8 @@ proc sendVoice*(b: TeleBot, chatId: int64, voice: string, caption = "", parseMod
196208
data["duration"] = $duration
197209
if disableNotification:
198210
data["disable_notification"] = "true"
211+
if protectContent:
212+
data["protect_content"] = "true"
199213
if replyToMessageId != 0:
200214
data["reply_to_message_id"] = $replyToMessageId
201215
if allowSendingWithoutReply:
@@ -207,7 +221,7 @@ proc sendVoice*(b: TeleBot, chatId: int64, voice: string, caption = "", parseMod
207221
result = getMessage(res)
208222

209223
proc sendVideoNote*(b: TeleBot, chatId: int64, videoNote: string, duration = 0, length = 0, thumb = "",
210-
disableNotification = false, replyToMessageId = 0,
224+
disableNotification = false, protectContent = false, replyToMessageId = 0,
211225
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
212226
var data = newMultipartData()
213227

@@ -221,6 +235,8 @@ proc sendVideoNote*(b: TeleBot, chatId: int64, videoNote: string, duration = 0,
221235
data.addData("thumb", thumb, true)
222236
if disableNotification:
223237
data["disable_notification"] = "true"
238+
if protectContent:
239+
data["protect_content"] = "true"
224240
if replyToMessageId != 0:
225241
data["reply_to_message_id"] = $replyToMessageId
226242
if allowSendingWithoutReply:
@@ -232,7 +248,7 @@ proc sendVideoNote*(b: TeleBot, chatId: int64, videoNote: string, duration = 0,
232248
result = getMessage(res)
233249

234250
proc sendLocation*(b: TeleBot, chatId: int64, latitude: float, longitude: float, livePeriod = 0,
235-
heading = 0, proximityAlertRadius = 0, disableNotification = false,
251+
heading = 0, proximityAlertRadius = 0, disableNotification = false, protectContent = false,
236252
replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
237253
var data = newMultipartData()
238254

@@ -247,6 +263,8 @@ proc sendLocation*(b: TeleBot, chatId: int64, latitude: float, longitude: float,
247263
data["proximity_alert_radius"] = $proximityAlertRadius
248264
if disableNotification:
249265
data["disable_notification"] = "true"
266+
if protectContent:
267+
data["protect_content"] = "true"
250268
if replyToMessageId != 0:
251269
data["reply_to_message_id"] = $replyToMessageId
252270
if allowSendingWithoutReply:
@@ -258,7 +276,7 @@ proc sendLocation*(b: TeleBot, chatId: int64, latitude: float, longitude: float,
258276
result = getMessage(res)
259277

260278
proc sendVenue*(b: TeleBot, chatId: int64, latitude: float, longitude: float, address: string, foursquareId = "", foursquareType = "",
261-
googlePlaceId = "", googlePlaceType = "", disableNotification = false, replyToMessageId = 0,
279+
googlePlaceId = "", googlePlaceType = "", disableNotification = false, protectContent = false, replyToMessageId = 0,
262280
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
263281
var data = newMultipartData()
264282

@@ -277,6 +295,8 @@ proc sendVenue*(b: TeleBot, chatId: int64, latitude: float, longitude: float, ad
277295
data["google_place_type"] = googlePlaceType
278296
if disableNotification:
279297
data["disable_notification"] = "true"
298+
if protectContent:
299+
data["protect_content"] = "true"
280300
if replyToMessageId != 0:
281301
data["reply_to_message_id"] = $replyToMessageId
282302
if allowSendingWithoutReply:
@@ -288,7 +308,7 @@ proc sendVenue*(b: TeleBot, chatId: int64, latitude: float, longitude: float, ad
288308
result = getMessage(res)
289309

290310
proc sendContact*(b: TeleBot, chatId: int64, phoneNumber: string, firstName: string, lastName = "", vcard = "",
291-
disableNotification = false, replyToMessageId = 0,
311+
disableNotification = false, protectContent = false, replyToMessageId = 0,
292312
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
293313
var data = newMultipartData()
294314

@@ -301,6 +321,8 @@ proc sendContact*(b: TeleBot, chatId: int64, phoneNumber: string, firstName: str
301321
data["vcard"] = vcard
302322
if disableNotification:
303323
data["disable_notification"] = "true"
324+
if protectContent:
325+
data["protect_content"] = "true"
304326
if replyToMessageId != 0:
305327
data["reply_to_message_id"] = $replyToMessageId
306328
if allowSendingWithoutReply:
@@ -315,8 +337,8 @@ proc sendInvoice*(b: TeleBot, chatId: int64, title: string, description: string,
315337
prices: seq[LabeledPrice], maxTipAmount = 0, suggestedTipAmounts: seq[int] = @[], startParameter = "",
316338
providerData = "", photoUrl = "", photoSize = 0, photoWidth = 0, photoHeight = 0,
317339
needName = false, needPhoneNumber = false, needEmail = false, needShippingAddress = false, sendPhoneNumberToProvider = false,
318-
sendEmailToProvider = false, isFlexible = false,
319-
disableNotification = false, replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
340+
sendEmailToProvider = false, isFlexible = false, disableNotification = false, protectContent = false, replyToMessageId = 0,
341+
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
320342
var data = newMultipartData()
321343

322344
data["chat_id"] = $chatId
@@ -362,6 +384,8 @@ proc sendInvoice*(b: TeleBot, chatId: int64, title: string, description: string,
362384
data["is_flexible"] = "true"
363385
if disableNotification:
364386
data["disable_notification"] = "true"
387+
if protectContent:
388+
data["protect_content"] = "true"
365389
if replyToMessageId != 0:
366390
data["reply_to_message_id"] = $replyToMessageId
367391
if allowSendingWithoutReply:
@@ -373,7 +397,8 @@ proc sendInvoice*(b: TeleBot, chatId: int64, title: string, description: string,
373397
result = getMessage(res)
374398

375399
proc sendAnimation*(b: TeleBot, chatId: int64, animation: string, duration = 0, width = 0, height = 0, thumb = "",
376-
caption = "", parseMode = "", captionEntities: seq[MessageEntity] = @[], disableNotification = false, replyToMessageId = 0,
400+
caption = "", parseMode = "", captionEntities: seq[MessageEntity] = @[], disableNotification = false,
401+
protectContent = false, replyToMessageId = 0,
377402
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
378403
var data = newMultipartData()
379404

@@ -397,6 +422,8 @@ proc sendAnimation*(b: TeleBot, chatId: int64, animation: string, duration = 0,
397422
data["caption_entities"] = json
398423
if disableNotification:
399424
data["disable_notification"] = "true"
425+
if protectContent:
426+
data["protect_content"] = "true"
400427
if replyToMessageId != 0:
401428
data["reply_to_message_id"] = $replyToMessageId
402429
if allowSendingWithoutReply:
@@ -410,7 +437,7 @@ proc sendAnimation*(b: TeleBot, chatId: int64, animation: string, duration = 0,
410437
proc sendPoll*(b: TeleBot, chatId: int64, question: string, options: seq[string], isAnonymous = false, kind = "",
411438
allowsMultipleAnswers = false, correctOptionId = 0, explanation = "", explanationParseMode = "",
412439
explanationEntities: seq[MessageEntity] = @[], openPeriod = 0, closeDate = 0, isClosed = false, disableNotification = false,
413-
replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
440+
protectContent = false, replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
414441
var data = newMultipartData()
415442

416443
data["chat_id"] = $chatId
@@ -442,6 +469,8 @@ proc sendPoll*(b: TeleBot, chatId: int64, question: string, options: seq[string]
442469
data["is_closed"] = "true"
443470
if disableNotification:
444471
data["disable_notification"] = "true"
472+
if protectContent:
473+
data["protect_content"] = "true"
445474
if replyToMessageId != 0:
446475
data["reply_to_message_id"] = $replyToMessageId
447476
if allowSendingWithoutReply:
@@ -452,7 +481,7 @@ proc sendPoll*(b: TeleBot, chatId: int64, question: string, options: seq[string]
452481
let res = await makeRequest(b, procName, data)
453482
result = getMessage(res)
454483

455-
proc sendDice*(b: TeleBot, chatId: int64, emoji = "", disableNotification = false, replyToMessageId = 0,
484+
proc sendDice*(b: TeleBot, chatId: int64, emoji = "", disableNotification = false, protectContent = false, replyToMessageId = 0,
456485
allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[Message] {.async.} =
457486
var data = newMultipartData()
458487

@@ -461,6 +490,8 @@ proc sendDice*(b: TeleBot, chatId: int64, emoji = "", disableNotification = fals
461490
data["emoji"] = emoji
462491
if disableNotification:
463492
data["disable_notification"] = "true"
493+
if protectContent:
494+
data["protect_content"] = "true"
464495
if replyToMessageId != 0:
465496
data["reply_to_message_id"] = $replyToMessageId
466497
if allowSendingWithoutReply:
@@ -484,7 +515,7 @@ proc close*(b: TeleBot): Future[bool] {.async.} =
484515
let res = await makeRequest(b, procName)
485516
result = unmarshal(res, bool)
486517

487-
proc forwardMessage*(b: TeleBot, chatId, fromChatId: string, messageId: int, disableNotification = false): Future[Message] {.async.} =
518+
proc forwardMessage*(b: TeleBot, chatId, fromChatId: string, messageId: int, disableNotification = false, protectContent = false): Future[Message] {.async.} =
488519
var data = newMultipartData()
489520

490521
data["chat_id"] = chatId
@@ -493,12 +524,13 @@ proc forwardMessage*(b: TeleBot, chatId, fromChatId: string, messageId: int, dis
493524

494525
if disableNotification:
495526
data["disable_notification"] = "true"
496-
527+
if protectContent:
528+
data["protect_content"] = "true"
497529
let res = await makeRequest(b, procName, data)
498530
result = getMessage(res)
499531

500532
proc copyMessage*(b: TeleBot, chatId, fromChatId: string, messageId: int, caption = "", parseMode = "",
501-
captionEntities: seq[MessageEntity] = @[], disableNotification = false,
533+
captionEntities: seq[MessageEntity] = @[], disableNotification = false, protectContent = false,
502534
replyToMessageId = 0, allowSendingWithoutReply = false, replyMarkup: KeyboardMarkup = nil): Future[MessageId] {.async.} =
503535
var data = newMultipartData()
504536

@@ -515,6 +547,8 @@ proc copyMessage*(b: TeleBot, chatId, fromChatId: string, messageId: int, captio
515547
data["caption_entities"] = json
516548
if disableNotification:
517549
data["disable_notification"] = "true"
550+
if protectContent:
551+
data["protect_content"] = "true"
518552
if replyToMessageId != 0:
519553
data["reply_to_message_id"] = $replyToMessageId
520554
if allowSendingWithoutReply:

0 commit comments

Comments
 (0)