From fd5a19b145b3b835fd525ca686a011f43a27b7c1 Mon Sep 17 00:00:00 2001 From: Huy Doan Date: Tue, 22 Aug 2023 12:22:20 +0700 Subject: [PATCH] Bot API 6.8 --- src/telebot/private/api.nim | 10 ++++++---- src/telebot/private/types.nim | 18 ++++++++++++++++-- telebot.nimble | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/telebot/private/api.nim b/src/telebot/private/api.nim index f377b2a..907a13d 100644 --- a/src/telebot/private/api.nim +++ b/src/telebot/private/api.nim @@ -299,7 +299,7 @@ proc banChatSenderChat*(b: TeleBot, chatId: ChatId, senderChatId: int, untilDate proc unbanChatSenderChat*(b: TeleBot, chatId: ChatId, senderChatId: int): Future[bool] {.api, async.} -proc getUpdates*(b: TeleBot, offset, limit = 0, timeout = 50, allowedUpdates: seq[string] = @[]): Future[JsonNode] {.async.} = +proc getUpdates*(b: TeleBot, offset = 0, limit = 0, timeout = 50, allowedUpdates: seq[string] = @[]): Future[JsonNode] {.async.} = var data = newMultipartData() if offset > 0: @@ -347,7 +347,7 @@ proc cleanUpdates*(b: TeleBot) {.async.} = while updates.len >= 100: updates = await b.getUpdates() -proc loop(b: TeleBot, timeout = 50, offset, limit = 0) {.async.} = +proc loop(b: TeleBot, timeout = 50, offset = 0, limit = 0) {.async.} = try: let me = waitFor b.getMe() b.id = me.id @@ -366,12 +366,12 @@ proc loop(b: TeleBot, timeout = 50, offset, limit = 0) {.async.} = let update = unmarshal(item, Update) asyncCheck b.handleUpdate(update) -proc poll*(b: TeleBot, timeout = 50, offset, limit = 0, clean = false) = +proc poll*(b: TeleBot, timeout = 50, offset = 0, limit = 0, clean = false) = if clean: waitFor b.cleanUpdates() waitFor loop(b, timeout, offset, limit) -proc pollAsync*(b: TeleBot, timeout = 50, offset, limit = 0, clean = false) {.async.} = +proc pollAsync*(b: TeleBot, timeout = 50, offset = 0, limit = 0, clean = false) {.async.} = if clean: await b.cleanUpdates() await loop(b, timeout, offset, limit) @@ -415,3 +415,5 @@ proc reopenGeneralForumTopic*(b: TeleBot, chatId: ChatId): Future[bool] {.api, a proc hideGeneralForumTopic*(b: TeleBot, chatId: ChatId): Future[bool] {.api, async.} proc unhideGeneralForumTopic*(b: TeleBot, chatId: ChatId): Future[bool] {.api, async.} + +proc unpinAllGeneralForumTopicMessages*(b: TeleBot, chatId: ChatId): Future[bool] {.api, async.} diff --git a/src/telebot/private/types.nim b/src/telebot/private/types.nim index 70b549c..f520fee 100644 --- a/src/telebot/private/types.nim +++ b/src/telebot/private/types.nim @@ -71,7 +71,8 @@ type isForum*:Option[bool] photo*: Option[ChatPhoto] activeUsernames*: Option[seq[string]] - emojiStatusCustomEmojiId: Option[string] + emojiStatusCustomEmojiId*: Option[string] + emojiStatusExpirationDate*: Option[int] bio*: Option[string] hasPrivateForwards*: Option[bool] joinToSendMessages*: Option[bool] @@ -116,6 +117,17 @@ type mimeType*: Option[string] fileSize*: Option[int] + Story* = object of TelegramObject + fileId*: string + fileUniqueId*: string + width*: int + height*: int + duration*: int + thumbnail*: Option[PhotoSize] + fileName*: Option[string] + mimeType*: Option[string] + fileSize*: Option[int] + Sticker* = object of TelegramObject fileId*: string fileUniqueId*: string @@ -209,7 +221,8 @@ type PollAnswer* = object of TelegramObject pollId*: string - user*: User + voterChat*: Option[Chat] + user*: Option[User] optionIds*: seq[int] Poll* = object of TelegramObject @@ -422,6 +435,7 @@ type document*: Option[Document] photo*: Option[seq[PhotoSize]] sticker*: Option[Sticker] + story*: Option[Story] video*: Option[Video] videoNote*: Option[VideoNote] voice*: Option[Voice] diff --git a/telebot.nimble b/telebot.nimble index 69126d8..1265849 100644 --- a/telebot.nimble +++ b/telebot.nimble @@ -1,4 +1,4 @@ -version = "2023.08.20" +version = "2023.08.22" author = "Huy Doan" description = "Async Telegram Bot API Client" license = "MIT"