smartnode / telebot

Telegram Bot API in C
https://elmurod.net/telebot
Apache License 2.0
159 stars 35 forks source link

Failed to send file as document, server response is 400 #16

Closed denzen84 closed 5 years ago

denzen84 commented 5 years ago

ret = telebot_send_document(handle, sstgbconf.user_id, sstgbconf.docfile, true, false, 0, NULL); if (ret != TELEBOT_ERROR_NONE) { printf("Failed to send document: %d \n", ret); }

The result is:

[ERROR][telebot_core_curl_perform:95]Wrong HTTP response received, response: 400 Failed to send document: -1

Possibly changes in Telegram API ?

denzen84 commented 5 years ago

Full source code of the bot available: https://github.com/denzen84/sstgb

smartnode commented 5 years ago

Does it fail only with sending document? Or everything else (message, video)?

denzen84 commented 5 years ago

It fails only with sending documents. I tried different types (text, pdf, jpg, mp4 ...). Sending text messages, images and videos works fine.

denzen84 commented 5 years ago

So, I found and fix this bug:

telebot-core.c: line 456: return telebot_core_curl_perform(core_h, TELEBOT_METHOD_SEND_DOCUMENT, post);

there was method _TELEBOT_METHOD_SENDPHOTO instead of _TELEBOT_METHOD_SENDDOCUMENT.

denzen84 commented 5 years ago

Please update master branch :)

smartnode commented 5 years ago

Thanks for the bug fix. You may also pull request.