start_server: Start the webhook server.

View source: R/webhook.R

start_serverR Documentation

Start the webhook server.

Description

Starts the webhook for updates from Telegram. You can stop listening either by using the RStudio's interrupt R command in the session menu or with the stop_server method.

Usage

start_server(host = "127.0.0.1", port = 5001, clean = FALSE, blocking = TRUE)

Arguments

host

a string that is a valid IPv4 or IPv6 address that is owned by this server, which the application will listen on. "0.0.0.0" represents all IPv4 addresses and "::/0" represents all IPv6 addresses. Default is "127.0.0.1".

port

a number or integer that indicates the server port that should be listened on. Note that on most Unix-like systems including Linux and Mac OS X, port numbers smaller than 1025 require root privileges. Default is 5001.

clean

(Optional). Whether to clean any pending updates on Telegram servers before actually starting to poll. Default is FALSE.

blocking

(Optional). Determines whether the method blocks whilst listening for updates from Telegram. Default is TRUE.

Examples

## Not run: 
# Start webhook example
start <- function(bot, update) {
  bot$sendMessage(
    chat_id = update$message$chat_id,
    text = sprintf(
      "Hello %s!",
      update$message$from$first_name
    )
  )
}

webhook <- Webhook("https://example.com/webhook", "TOKEN") + CommandHandler("start", start)

webhook$start_server()

## End(Not run)

telegram.bot documentation built on Sept. 7, 2022, 5:07 p.m.