inst/doc/telegrambot-building-a-bot.R

## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----eval = FALSE-------------------------------------------------------------
# library(telegram.bot)
# 
# updater <- Updater(token = "TOKEN")

## ----eval = FALSE-------------------------------------------------------------
# file.edit(path.expand(file.path("~", ".Renviron")))

## ----eval = FALSE-------------------------------------------------------------
# R_TELEGRAM_BOT_RTelegramBot=TOKEN

## ----eval = FALSE-------------------------------------------------------------
# updater <- Updater(token = bot_token("RTelegramBot"))

## ----eval = FALSE-------------------------------------------------------------
# start <- function(bot, update) {
#   bot$sendMessage(
#     chat_id = update$message$chat_id,
#     text = sprintf("Hello %s!", update$message$from$first_name)
#   )
# }

## ----eval = FALSE-------------------------------------------------------------
# start_handler <- CommandHandler("start", start)
# updater <- updater + start_handler

## ----eval = FALSE-------------------------------------------------------------
# updater$start_polling()

Try the telegram.bot package in your browser

Any scripts or data that you put into this service are public.

telegram.bot documentation built on Nov. 5, 2025, 6:54 p.m.