telegram-bot-ruby
                                
                                
                                
                                    telegram-bot-ruby copied to clipboard
                            
                            
                            
                        Maybe a silly question, how to send gifs
Hi, I have been using this tool for some time and although I don't know much about http communication it made making a simple bot really easy. Now I have updated the tool and I don't know anymore how to send documents with the Faraday support. I am trying to mimic what I see but haven't had any success.
I am trying to do something like this: bot.api.send_document(chat_id: dest, document: Faraday::UploadIO.new("file.gif","THING"))
but I don't know what to put in THING, or if it is the way to do it. Before I just plugged in a File and it worked perfectly. What is the right way of doing it?
@AAraKKe a THING is mime type for file, try to use "image/gif" for gif you can learn more here about Faraday
@BitOfUniverse thanks a lot, I tried several different types, but image/gif didn't work, that is why I was asking, maybe is something that I couldn't guess (I didn't know what mime types there were or that it was even a mime type hehe). Using "image/gif" I get this error:
Telegram API has returned the error. (error_code: "413", uri: "https://api.telegram.org/bottoken:token/sendDocument")
This happen with every gif I try to send.
Looks like your file is too large (according 413 error code). Telegram has file size limitations (50mb per file). Anyway, following code works just fine for me:
bot.api.send_document(chat_id: message.from.id, document: Faraday::UploadIO.new('test.gif', 'image/gif'))
                                    
                                    
                                    
                                
I don't know how large is too large, but this happens with all gifs, even those which are less than a copule of Mb. I also read what's the 413 error but since Telegram said that the error codes are related to Api and they might change I dont know. In any case, I will try again with different gifs, I have more than 50 and I cannot send any of them.
Thanks.
El vie., 6 may. 2016 11:19, Alexander Tipugin [email protected] escribió:
Looks like your file is too large (according 413 error code). Telegram has file size limitations (50mb per file). Anyway, following code works just fine for me:
bot.api.send_document(chat_id: message.from.id, document: Faraday::UploadIO.new('test.gif', 'image/gif'))
— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/atipugin/telegram-bot-ruby/issues/53#issuecomment-217394458
I'm sending gifs using the send_document endpoint instead of send_photo
bot.api.send_document(
          chat_id: chat_id,
          document: Faraday::UploadIO.new(file, 'image/gif')
        )
                                    
                                    
                                    
                                
i have same problem with video , and all files are less than 10 mb
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.