CommandHandler {telegram.bot} | R Documentation |
Handling commands
Description
Handler
class to handle Telegram commands.
Usage
CommandHandler(
command,
callback,
filters = NULL,
pass_args = FALSE,
username = NULL
)
Arguments
command |
The command or vector of commands this handler should listen for. |
callback |
The callback function for this handler.
See |
filters |
(Optional). Only allow updates with these filters. See
|
pass_args |
(Optional). Determines whether the handler should be passed
|
username |
(Optional). Bot's username, you can retrieve it from
|
Format
An R6Class
object.
Examples
## Not run:
# Initialize bot
bot <- Bot("TOKEN")
username <- bot$getMe()$username
updater <- Updater(bot = bot)
# Add a command
start <- function(bot, update) {
bot$sendMessage(
chat_id = update$message$chat_id,
text = "Hi, I am a bot!"
)
}
updater <- updater + CommandHandler("start", start, username = username)
## End(Not run)
[Package telegram.bot version 3.0.0 Index]