R/message_sender.R

Defines functions status start

library(telegram.bot)



bot_token <- '1018191377:AAFH_EPbFboMMJaAYkNhL7DwGqPdEEI4VvQ'
bot <- Bot(token = bot_token)
chat_id <- 72266202
document_path<- paste0("C:/Users/crist/Documents/TelegramR/","progress.txt")
updater <- Updater(token = bot_token)


#' /star command
#'
#' @param bot
#' @param update
#'
#' @return
#' @export
#'
#' @examples
#'
#'
start = function(bot, update){
  bot$sendMessage(chat_id = update$message$chat_id,
                  text = sprintf("Hello %s!", update$message$from$first_name))
}

start_handler <- CommandHandler("start", start, username = "RstudioBot")
updater <- updater + start_handler





#' /status command
#'
#' @param bot
#' @param update
#'
#' @return
#' @export
#'
#' @examples
status=function(bot, update){
bot$sendDocument(chat_id = update$message$chat_id, document = document_path)
}

status_handler <- CommandHandler("status", status, username = "RstudioBot")
updater <- updater + status_handler

# start bot
updater$start_polling()
CFehrmann/TelegramR documentation built on May 21, 2020, 12:03 a.m.