ja-thomas / RTelegram

Use telegram bots to send messages from R to your smartphone
0 stars 3 forks source link

send_image #1

Open arielp1 opened 6 years ago

arielp1 commented 6 years ago

I'm try to use send_image function but the telegram received blank image.

what's wrong?

send_image <- function(image_call, chat_id, token, file = "image"){

if(!(inherits(chat_id, "chat_id") | is.character(chat_id))){ stop("chat_id must be a chat_id object or a character string") }

if(!(inherits(token, "chat_bot") | is.character(token))){ stop("token must be a chat_bot object or a character string") }

if(inherits(chat_id, "chat_id")){ chat_id <- chat_id$chat_id }

if(inherits(token, "chat_bot")){ token <- token$token }

filename = paste0("./", "file", ".jpg")

png(filename = filename) image_call dev.off() httr::POST(url = paste0("https://api.telegram.org/bot", token, "/sendPhoto"), body = list(chat_id = chat_id, photo = httr::upload_file(filename))) }

send_image("FT.jpg", chat_id, token, file = "image")

ja-thomas commented 6 years ago

Hi,

this repo isn't really maintained anymore, sorry. The last commit was over 2 years ago and it's plausible that some calls of the telegram API changed in the meantime. Should have created unittests :(

There is a more recent wrapper for the telegram bot API here: https://cran.r-project.org/web/packages/telegram/README.html

Best