Skip to content

Commit 7e32cef

Browse files
committed
Update to Bot API 4.2
1 parent 98659ca commit 7e32cef

File tree

3 files changed

+105
-4
lines changed

3 files changed

+105
-4
lines changed

telebot.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version = "0.5.6.4"
1+
version = "0.5.7"
22
author = "Huy Doan"
33
description = "Async Telegram Bot API Client"
44
license = "MIT"

telebot/api.nim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ magic Animation:
141141
replyToMessageId: int {.optional.}
142142
replyMarkup: KeyboardMarkup {.optional.}
143143

144+
magic Poll:
145+
chatId: int64
146+
question: string
147+
options: seq[string]
148+
disableNotification: string {.optional.}
149+
replyToMessageId: int {.optional.}
150+
replyMarkup: KeyboardMarkup {.optional.}
144151

145152
proc getMe*(b: TeleBot): Future[User] {.async.} =
146153
## Returns basic information about the bot in form of a ``User`` object.
@@ -554,6 +561,24 @@ proc editMessageReplyMarkup*(b: TeleBot, chatId = "", messageId = 0, inlineMessa
554561
else:
555562
result = some(unmarshal(res, Message))
556563

564+
proc stopPoll*(b: TeleBot, chatId = "", messageId = 0, inlineMessageId = "", replyMarkup: KeyboardMarkup = nil): Future[Option[Poll]] {.async.} =
565+
END_POINT("stopPool")
566+
var data = newMultipartData()
567+
if chatId.len > 0:
568+
data["chat_id"] = chat_id
569+
if messageId != 0:
570+
data["message_id"] = $messageId
571+
if inlineMessageId.len != 0:
572+
data["inline_message_id"] = inlineMessageId
573+
if replyMarkup != nil:
574+
data["reply_markup"] = $replyMarkup
575+
576+
let res = await makeRequest(endpoint % b.token, data)
577+
if res.kind == JBool:
578+
result = none(Poll)
579+
else:
580+
result = some(unmarshal(res, Poll))
581+
557582
proc deleteMessage*(b: Telebot, chatId: string, messageId: int): Future[bool] {.async.} =
558583
END_POINT("deleteMessage")
559584
var data = newMultipartData()

telebot/types.nim

Lines changed: 79 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,17 @@ type
121121
title*: string
122122
address*: string
123123
foursquareId*: Option[string]
124-
foursquareName*: Option[string]
124+
foursquareType*: Option[string]
125+
126+
PollOption* = object of TelegramObject
127+
text*: string
128+
voterCount*: int
129+
130+
Poll* = object of TelegramObject
131+
id*: string
132+
question*: string
133+
options*: seq[PollOption]
134+
isClosed*: bool
125135

126136
UserProfilePhotos* = object of TelegramObject
127137
totalCount*: int
@@ -191,6 +201,7 @@ type
191201
forwardFromChat*: Option[Chat]
192202
forwardFromMessageId*: Option[int]
193203
forwardSignature*: Option[string]
204+
forwardSenderName*: Option[string]
194205
forwardDate*: Option[int]
195206
replyToMessage*: Option[ref Message]
196207
editDate*: Option[int]
@@ -211,6 +222,7 @@ type
211222
contact*: Option[Contact]
212223
location*: Option[Location]
213224
venue*: Option[Venue]
225+
poll*: Option[Poll]
214226
newChatMembers*: Option[seq[User]]
215227
newChatMember*: Option[User]
216228
leftChatMember*: Option[User]
@@ -240,6 +252,7 @@ type
240252
canRestrictMembers*: Option[bool]
241253
canPinMessages*: Option[bool]
242254
canPromoteMebers*: Option[bool]
255+
isMember*: Option[bool]
243256
canSendMessages*: Option[bool]
244257
canSendMediaMessages*: Option[bool]
245258
canSendOtherMessages*: Option[bool]
@@ -260,6 +273,7 @@ type
260273
callbackQuery*: Option[CallbackQuery]
261274
shippingQuery*: Option[ShippingQuery]
262275
preCheckoutQuery*: Option[PreCheckoutQuery]
276+
poll*: Option[Poll]
263277

264278
#------------------
265279
# Game
@@ -361,7 +375,7 @@ type
361375
venueTitle*: string
362376
venueAddress*: string
363377
foursquareId*: Option[string]
364-
foursquareName*: Option[string]
378+
foursquareType*: Option[string]
365379
of ContactMessage:
366380
phoneNumber*: string
367381
firstName*: string
@@ -455,7 +469,7 @@ type
455469
title*: string
456470
address*: string
457471
foursquareId*: Option[string]
458-
foursquareName*: Option[string]
472+
foursquareType*: Option[string]
459473

460474
InlineQueryResultContact* = object of InlineQueryResultWithThumb
461475
phoneNumber*: string
@@ -549,3 +563,65 @@ type
549563
title*: Option[string]
550564

551565
InputMediaDocument* = ref object of InputMedia
566+
567+
#------------------
568+
# Passport
569+
#------------------
570+
PassportFile* = object of TelegramObject
571+
fileId*: string
572+
fileSize*: int
573+
fileDate*: int
574+
575+
EncryptedPassportElement* = object of TelegramObject
576+
kind*: string
577+
data*: string
578+
phoneNumber*: Option[string]
579+
email*: Option[string]
580+
files*: Option[seq[PassportFile]]
581+
frontSide*: Option[PassportFile]
582+
reverseSide*: Option[PassportFile]
583+
selfie*: Option[PassportFile]
584+
translation*: Option[seq[PassportFile]]
585+
hash*: string
586+
587+
EncryptedCredentials* = object of TelegramObject
588+
data*: string
589+
hash*: string
590+
secret*: string
591+
592+
PassportData* = object of TelegramObject
593+
data: seq[EncryptedPassportElement]
594+
credentials: EncryptedCredentials
595+
596+
PassportElementError = ref object of TelegramObject
597+
source*: string
598+
kind*: string
599+
message*: string
600+
601+
PassportElementErrorDataField* = ref object of PassportElementError
602+
fieldName*: string
603+
dataHash*: string
604+
605+
PassportElementErrorFrontSide* = ref object of PassportElementError
606+
fileHash*: string
607+
608+
PassportElementErrorReverseSide* = ref object of PassportElementError
609+
fileHash*: string
610+
611+
PassportElementErrorSelfie* = ref object of PassportElementError
612+
fileHash*: string
613+
614+
PassportElementErrorFile* = ref object of PassportElementError
615+
fileHash*: string
616+
617+
PassportElementErrorFiles* = ref object of PassportElementError
618+
fileHashes*: seq[string]
619+
620+
PassportElementErrorTranslationFile* = ref object of PassportElementError
621+
fileHash*: string
622+
623+
PassportElementErrorTranslationFiles* = ref object of PassportElementError
624+
fileHashes*: seq[string]
625+
626+
PassportElementErrorUnspecified* = ref object of PassportElementError
627+
elementHash*: string

0 commit comments

Comments
 (0)