Skip to content

Commit

Permalink
fixing #17: better notification messages
Browse files Browse the repository at this point in the history
  • Loading branch information
nimdraugsael committed Feb 13, 2016
1 parent 1efd68a commit aba57ae
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ To turn on notifications
cp notifier.json.example notifier.json
```
and make proper shell commands.
Token REPLACE_MESSAGE_HERE will be replaced with your real error message.

Then use *--notify-to* parameter for running ereb.py, for example to use slack do:
```sh
python3 ereb.py --notify-to=slack
Expand Down
3 changes: 2 additions & 1 deletion lib/notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def error(self, link, message):
link = urllib.parse.quote(link)
message = urllib.parse.quote(message)

subprocess.Popen(self.cmd % "{0}\n{1}".format(link, message), shell=True, stdout=subprocess.PIPE)
notifier_cmd = self.cmd.replace('REPLACE_MESSAGE_HERE', "{0}\n{1}".format(link, message))
subprocess.Popen(notifier_cmd, shell=True, stdout=subprocess.PIPE)
else:
logging.warning("Notifications are turned off")

Expand Down
4 changes: 2 additions & 2 deletions notifier.json.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"logger": "echo '%s'",
"slack": "curl -X POST https://slack.com/api/chat.postMessage -d 'token=TOKEN&channel=CHANNEL_TO&username=ereb_bot&parse=full&link_names=1&icon_emoji=:kanye:&attachments=[{\"text\": \"%s :piska: \",\"fallback\": \"Ereb error\",\"short\":true,\"color\":\"danger\"}]' --silent > /dev/null"
"logger": "echo 'REPLACE_MESSAGE_HERE'",
"slack": "curl -X POST https://slack.com/api/chat.postMessage -d 'token=TOKEN&channel=CHANNEL_TO&username=ereb_bot&parse=full&link_names=1&icon_emoji=:kanye:&attachments=[{\"text\": \"REPLACE_MESSAGE_HERE :piska: \",\"fallback\": \"REPLACE_MESSAGE_HERE\",\"short\":true,\"color\":\"danger\"}]' --silent > /dev/null"
}

0 comments on commit aba57ae

Please sign in to comment.