Skip to content

Commit

Permalink
Change webhook endpoint to a secret one
Browse files Browse the repository at this point in the history
  • Loading branch information
nspacestd committed Jan 14, 2016
1 parent 5ad8b10 commit 195f7ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -22,7 +22,7 @@ The token that the [BotFather](https://core.telegram.org/bots#botfather) gives y

**TELEGRAM_WEBHOOK** (optional)

You can specify a [webhook](https://core.telegram.org/bots/api#setwebhook) URL which the adapter will register with Telegram. This URL will receive updates from Telegram. The adapter automatically registers an endpoint with Hubot at http://your-hobot-host/hubot/telegram/receive.
You can specify a [webhook](https://core.telegram.org/bots/api#setwebhook) URL. The adapter will register TELEGRAM_WEBHOOK/TELEGRAM_TOKEN with Telegram and listen there.

**TELEGRAM_INTERVAL** (optional)

Expand Down Expand Up @@ -68,4 +68,4 @@ robot.respond(/(.*)/i, function (res) {
## Contributors

* Luke Simone - [https://github.com/lukefx](https://github.com/lukefx)
* Chris Brand - [https://github.com/arcturial](https://github.com/arcturial)
* Chris Brand - [https://github.com/arcturial](https://github.com/arcturial)
7 changes: 5 additions & 2 deletions src/telegram.coffee
Expand Up @@ -217,11 +217,14 @@ class Telegram extends Adapter

if @webhook

@api.invoke 'setWebHook', { url: @webhook }, (err, result) ->
endpoint = @webhook + '/' + @token
@robot.logger.debug 'Listening on ' + endpoint

@api.invoke 'setWebHook', { url: endpoint }, (err, result) ->
if (err)
self.emit 'error', err

@robot.router.post "/hubot/telegram/receive", (req, res) =>
@robot.router.post "/" + @token, (req, res) =>
if req.body.message
self.handleUpdate req.body

Expand Down

0 comments on commit 195f7ea

Please sign in to comment.