R/validate_bot.R

validate_bot <- function(token){
  
  bot <- list()
  
  x <- fromJSON(paste0("https://api.telegram.org/bot", token, "/getME"))
  
  if(!x$ok){
    warning("bot not found")
  }
  else{
    
    bot$token <- token
    bot$chat_id <- x$result$id
    bot$username <- x$result$username
    bot$first_name <- x$result$first_name
  }
  
  class(bot) <- "chat_bot"
  bot
  
}
ja-thomas/RTelegram documentation built on May 18, 2019, 7:15 a.m.