Skip to content

Commit

Permalink
chore(script): Send notification to channel
Browse files Browse the repository at this point in the history
  • Loading branch information
lgaticaq committed Jun 17, 2016
1 parent 3f6150a commit 375c4b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
npm i -S hubot-toggl-payment
```

Set environment variable *TOGGL_CHANNEL* to channel notifications.

add `["hubot-toggl-payment"]` to `external-scripts.json`.

## Examples
Expand Down
6 changes: 5 additions & 1 deletion src/script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# "simple-encryptor": "^1.0.3",
# "toggl-api": "0.0.4"
#
# Configuration:
# TOGGL_CHANNEL
#
# Commands:
# hubot toggl login <token> <password> - Login to Toggl
# hubot toggl payment <amount> <price> <password> - Close time entries for
Expand Down Expand Up @@ -85,6 +88,7 @@ module.exports = (robot) ->
amount = res.match[1]
price = res.match[2]
secret = res.match[4]
channel = process.env.TOGGL_CHANNEL or "#random"
unless res.message.room is res.message.user.name
res.reply "only use this command in a private message"
robot.send {room: res.message.user.name}, "Send me toggl command"
Expand All @@ -109,7 +113,7 @@ module.exports = (robot) ->
.then () ->
res.send message
welcome = "#{msg.message.user.name} close tasks successfull"
robot.messageRoom("#random", "#{welcome}\n#{message}")
robot.messageRoom(channel, "#{welcome}\n#{message}")
.catch (err) ->
res.reply "an error occurred in toggl"
robot.emit "error", err

0 comments on commit 375c4b1

Please sign in to comment.