Closed virtualstaticvoid closed 2 years ago
This PR adds the capability to receive Telegram updates via Webhook delivery.
Following the pattern established in the Updater class, the Webhook class follows similar steps for setup and running.
Updater
Webhook
# define handlers as before start <- function(bot, update) { bot$sendMessage( chat_id = update$message$chat_id, text = sprintf( "Hello %s!", update$message$from$first_name ) ) } # instantiate Webhook webhook <- Webhook("https://example.com/webhook", Sys.getenv("TOKEN"), verbose = TRUE) # wire up handler webhook <- webhook + CommandHandler("start", start) # start polling webhook$start_server() # OR, start polling, binding to all interfaces on port 3000 webhook$start_server(host = "0.0.0.0", port = 3000) # stop polling webhook$stop_server()
A working example application can be found at virtualstaticvoid/heroku-telegram-bot-webhook which is deployed to Heroku.
Start a chat with HerokuRBot to try it out. Send /plot command to receive a simple pie chart rendered in R.
HerokuRBot
/plot
Bot$set_workhook
ip_address
drop_pending_updates
secret_token
Bot.request
I realised I haven't updated the main README page to include details of the new Webhook class, so I will add that shortly.
This PR adds the capability to receive Telegram updates via Webhook delivery.
Following the pattern established in the
Updater
class, theWebhook
class follows similar steps for setup and running.A working example application can be found at virtualstaticvoid/heroku-telegram-bot-webhook which is deployed to Heroku.
Start a chat with
HerokuRBot
to try it out. Send/plot
command to receive a simple pie chart rendered in R.All Submissions:
New Feature Submissions:
Changes to Core Features:
Proposed Changes
Bot$set_workhook
method to include all supported arguments; includingip_address
,drop_pending_updates
andsecret_token
.Bot.request
method so that when an error occurs, it is reported with the response text, which helps when debugging.