This is a generic function to send some object to telegram.
send_to_telegram(x, ..., chat_id, bot)
# S3 method for 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 gg
send_to_telegram(
x,
fileext = c("png", "pdf", "jpeg", "tiff", "bmp"),
...,
chat_id = getOption("depigner.chat_id"),
bot = getOption("depigner.bot")
)
object to send (often a character string)
further argument to pass to the sending methods (see
Bot
for specifications.)
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
) the bot object.
By default all the methods consider the bot created by a
previous run of start_bot_for_chat
.
(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.
(chr, default "png") one of the possible file format supported: "png", "pdf", "jpeg", "tiff" or "bmp"
invisible the object x.
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.
if (FALSE) {
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)
}