send_to_telegram {depigner}R Documentation

Send something to telegram

Description

This is a generic function to send some object to telegram.

Usage

send_to_telegram(x, ..., chat_id, bot)

## S3 method for class 'character'
send_to_telegram(
  x,
  type = c("message", "photo", "document", "audio", "animation", "video", "voice",
    "sticker", "location", "videonote"),
  ...,
  chat_id = getOption("depigner.chat_id"),
  bot = getOption("depigner.bot")
)

## S3 method for class 'gg'
send_to_telegram(
  x,
  fileext = c("png", "pdf", "jpeg", "tiff", "bmp"),
  ...,
  chat_id = getOption("depigner.chat_id"),
  bot = getOption("depigner.bot")
)

Arguments

x

object to send (often a character string)

...

further argument to pass to the sending methods (see Bot for specifications.)

chat_id

chat_id in which send the object. By default all the methods consider the chat_id defined in the previous run of start_bot_for_chat.

bot

(Bot) the bot object. By default all the methods consider the bot created by a previous run of start_bot_for_chat.

type

(chr, default = "message") the type of text represent x. I.e., if not "message", it is normally considered as a path to the corresponding object. For further clarification see Bot help page.

fileext

(chr, default "png") one of the possible file format supported: "png", "pdf", "jpeg", "tiff" or "bmp"

Details

By default it use the bot and chat_id configured by start_bot_for_chat. The user can pass a custom bot or chat_id providing them to the corresponding argument.

Value

invisible the object x.

Examples

## Not run: 
  library(depigner)
  library(ggplot2)

  start_bot_for_chat()
  send_to_telegram("hello world")

  gg <- ggplot(mtcars, aes(x = mpg, y = hp, colour = cyl)) +
  geom_point()

  send_to_telegram(
    "following an `mtcars` coloured plot",
    parse_mode = "Markdown"
  )
  send_to_telegram(gg)

## End(Not run)

[Package depigner version 0.8.4 Index]