start_bot_for_chat {depigner}R Documentation

Set up a Telegram bot

Description

This function set up what is necessary to telegram.bot package to be used in a more easy way by the function provided by the depigner.

Usage

start_bot_for_chat(
  chat_name = Sys.getenv("R_telegram_default_chat_name"),
  bot_name = getOption("depigner.bot_name")
)

Arguments

chat_name

(chr, NA) The name of the chat you want to the bot send.is linked to. If NA (default) it uses the default chat of the bot.

bot_name

(chr, NULL) This argument should be left NULL. If NULL, the function bring the bot name from the environmental variable "R_telegram_bot_name". You can pass another bot's name here as a character string too (note that in this case in the .Renviron you must have an entry like 'R_TELEGRAM_BOT_<yourbotname>=......' containing the token related to the bot).

Details

Before you can use the depigner facilities (or the telegram.bot ones) to use your bot to chat with Telegram from R, you have to set the bot up.

To set up a bot in telegram, find @BotFather on telegram. Send the message \start to it, and then send the message \newbot to it too. Next you have to follow the very simple instruction it gives you. At the end of the process, save your bot token and never share it publicly!!

After your bot is created, go to your bot default chat profile and send the message \start.

Now you can return to R and put both the bot's name and token into the .Renviron file. To access to it you can use edit_r_environ which will open the '.Renviron' file, ready to be modified.

You need to insert two lines, namely the one for your bot's name:

'R_telegram_bot_name=<name_of_my_bot>'

and one for its token:

'R_TELEGRAM_BOT_<name_of_my_bot>="1234567879:AbcD..."

Next, restart R and you are ready to use al the (simple) functionality of the depigner package, or the flexible and complete ones from the telegram.bot package.

Value

invisible()

Examples

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

## End(Not run)

[Package depigner version 0.8.4 Index]