ba0f3 / telebot.nim

Async Telegram Bot API Client implement in @Nim-Lang
MIT License
165 stars 24 forks source link

sendMediaGroup compiler error #55

Closed artemklevtsov closed 3 years ago

artemklevtsov commented 3 years ago

Seems sendMediaGroup can't accept sendMediaGroup and others.

To reproduce:

let bot = newTeleBot(API_KEY)
let doc = "file://" & getAppDir() & "/test.mid"
let media = @[
  newInputMediaDocument(doc, "file 1")
]
discard waitFor bot.sendMediaGroup($CHAT_ID, media)

Output:

~/proj/tbot/src/tbot.nim(20, 20) Error: type mismatch: got <TeleBot, string, seq[InputMediaDocument]>
but expected one of: 
proc sendMediaGroup(b: TeleBot; chatId = ""; media: seq[InputMedia];
                    disableNotification = false;
                    allowSendingWithoutReply = false; replyToMessageId = 0): Future[
    bool]
  first type mismatch at position: 3
  required type for media: seq[InputMedia]
  but expression 'media' is of type: seq[InputMediaDocument]
ba0f3 commented 3 years ago

i will check it soon

ba0f3 commented 3 years ago

@artemklevtsov I did some small changes to make it compile, Im not sure it will work or not, can you please check again? Thank you!

artemklevtsov commented 3 years ago

Now example compiles. But with let doc = "file://" & getAppDir() & "/test.mid" I got:

Exception message: No such file or directory
Additional info: "//file_upload_8570420106638733538"
Exception type: [OSError]

with let doc = getAppDir() & "/test.mid":

Exception message: Bad Request: URL host is empty
Exception type: [IOError]
artemklevtsov commented 3 years ago

After the last commit message sent successful but I got an error. Traceback:

./tbot                                                                                                                                                                          2841ms  Чт 25 фев 2021 13:00:00
/mnt/data/doc/tbot/src/tbot.nim(19) tbot
/usr/lib/nim/pure/asyncdispatch.nim(1935) waitFor
/usr/lib/nim/pure/asyncdispatch.nim(1627) poll
/usr/lib/nim/pure/asyncdispatch.nim(1368) runOnce
/usr/lib/nim/pure/asyncdispatch.nim(208) processPendingCallbacks
/usr/lib/nim/pure/asyncmacro.nim(29) sendMediaGroupNimAsyncContinue
/home/unikum/.nimble/pkgs/telebot-#head/telebot/private/api.nim(842) sendMediaGroupIter
/home/unikum/.nimble/pkgs/sam-0.1.16/sam.nim(257) toBool
/usr/lib/nim/system/assertions.nim(30) failedAssertImpl
/usr/lib/nim/system/assertions.nim(23) raiseAssert
/usr/lib/nim/system/fatal.nim(49) sysFatal
[[reraised from:
/mnt/data/doc/tbot/src/tbot.nim(19) tbot
/usr/lib/nim/pure/asyncdispatch.nim(1937) waitFor
/usr/lib/nim/pure/asyncfutures.nim(372) read
]]
Error: unhandled exception: /home/unikum/.nimble/pkgs/sam-0.1.16/sam.nim(257, 10) `node.mapper.tokens[node.pos].kind == JSMN_PRIMITIVE` 
Async traceback:
  /mnt/data/doc/tbot/src/tbot.nim(19)                                  tbot
  /usr/lib/nim/pure/asyncdispatch.nim(1935)                            waitFor
  /usr/lib/nim/pure/asyncdispatch.nim(1627)                            poll
  /usr/lib/nim/pure/asyncdispatch.nim(1368)                            runOnce
  /usr/lib/nim/pure/asyncdispatch.nim(208)                             processPendingCallbacks
  /usr/lib/nim/pure/asyncmacro.nim(29)                                 sendMediaGroupNimAsyncContinue
  /home/unikum/.nimble/pkgs/telebot-#head/telebot/private/api.nim(842) sendMediaGroupIter
  /home/unikum/.nimble/pkgs/sam-0.1.16/sam.nim(257)                    toBool
  /usr/lib/nim/system/assertions.nim(30)                               failedAssertImpl
  /usr/lib/nim/system/assertions.nim(23)                               raiseAssert
  /usr/lib/nim/system/fatal.nim(49)                                    sysFatal
Exception message: /home/unikum/.nimble/pkgs/sam-0.1.16/sam.nim(257, 10) `node.mapper.tokens[node.pos].kind == JSMN_PRIMITIVE` 
Exception type: [AssertionDefect]