Learn R Programming

telegram (version 0.7.1)

TGBot: TGBot

Description

Package main class (implementing the Telegram bot).

Arguments

Format

An R6Class generator object.

API Methods

forwardMessage

forward messages of any kind

getFile

get info about a file and download it

getMe

test your bot's auth token

getUpdates

receive incoming updates

getUserProfilePhotos

get a list of profile pictures for a user

sendAudio

send mp3 files

sendDocument

send general files

sendLocation

send point on the map

sendMessage

send text messages

sendPhoto

send image files

sendSticker

send .webp stickers

sendVideo

send mp4 videos

sendVoice

send ogg files encoded with OPUS

sendPoll

send a telegram poll

stopPoll

stop a telegram poll and obtain results

Methods


Method new()

Usage

TGBot$new(token, proxy)


Method set_token()

Usage

TGBot$set_token(token)


Method set_proxy()

Usage

TGBot$set_proxy(proxy)


Method set_default_chat_id()

Usage

TGBot$set_default_chat_id(chat_id)


Method req()

Usage

TGBot$req(method = NULL, body = NULL)


Method last_request()

Usage

TGBot$last_request()


Method print()

Usage

TGBot$print()


Method forwardMessage()

Usage

TGBot$forwardMessage(
  from_chat_id = NULL,
  message_id = NULL,
  disable_notification = NULL,
  chat_id = NULL
)


Method getFile()

Usage

TGBot$getFile(file_id, destfile = NULL)


Method getMe()

Usage

TGBot$getMe()


Method getUpdates()

Usage

TGBot$getUpdates(offset = NULL, limit = NULL)


Method getUserProfilePhotos()

Usage

TGBot$getUserProfilePhotos(user_id = NULL, offset = NULL, limit = NULL)


Method sendAudio()

Usage

TGBot$sendAudio(
  audio = NULL,
  caption = NULL,
  duration = NULL,
  performer = NULL,
  title = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendChatAction()

Usage

TGBot$sendChatAction(action = NULL, chat_id = NULL)


Method sendDocument()

Usage

TGBot$sendDocument(
  document = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendLocation()

Usage

TGBot$sendLocation(
  latitude = NULL,
  longitude = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendMessage()

Usage

TGBot$sendMessage(
  text = NULL,
  parse_mode = NULL,
  disable_web_page_preview = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendPhoto()

Usage

TGBot$sendPhoto(
  photo = NULL,
  caption = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendSticker()

Usage

TGBot$sendSticker(
  sticker = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendVideo()

Usage

TGBot$sendVideo(
  video = NULL,
  duration = NULL,
  caption = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendVoice()

Usage

TGBot$sendVoice(
  voice = NULL,
  duration = NULL,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method sendDice()

Usage

TGBot$sendDice(disable_notification = NULL, chat_id = NULL)


Method sendPoll()

Usage

TGBot$sendPoll(
  question = NULL,
  options = NULL,
  is_anonymous = TRUE,
  type = c("regular", "quiz"),
  allows_multiple_answers = FALSE,
  correct_option_id = NULL,
  is_closed = FALSE,
  disable_notification = NULL,
  reply_to_message_id = NULL,
  chat_id = NULL
)


Method stopPoll()

Usage

TGBot$stopPoll(message_id = NULL, chat_id = NULL)


Method clone()

The objects of this class are cloneable with this method.

Usage

TGBot$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

References

Bots: An introduction for developers and Telegram Bot API

Examples

Run this code
if (FALSE) {

## Without proxy
bot <- TGBot$new(token = bot_token('RBot'))

## With a proxy ...
prx <- list('url' = '123.45.6.78',
            'port' = 8080,
            'username' = 'user',
            'password' = 'password')
bot <- TGBot$new(token = bot_token('RBot'), proxy = prx)
##  .. or 
bot <- TGBot$new(token = bot_token('RBot'))
bot$set_proxy(proxy = prx)
}

Run the code above in your browser using DataLab