Skip to content

Commit

Permalink
Bot API 6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ba0f3 committed Aug 22, 2023
1 parent 7b512cb commit fd5a19b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/telebot/private/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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.}
18 changes: 16 additions & 2 deletions src/telebot/private/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion telebot.nimble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "2023.08.20"
version = "2023.08.22"
author = "Huy Doan"
description = "Async Telegram Bot API Client"
license = "MIT"
Expand Down

0 comments on commit fd5a19b

Please sign in to comment.