diff --git a/README.md b/README.md index e5fd3dd..e7da41e 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ #Integrations Has been tested with Nagios, works well for us. Any Pagerduty Notifier using the Pagerduty API should work without a problem. #Notifications -XMPP, email, SMS, Phone(Thanks Twilio for being awesome!), and Push notifications(thanks Pushover also) are supported at the moment. +XMPP, email, SMS, Phone(Thanks Twilio for being awesome!), and Push notifications(thanks Pushover also),and Slack are supported at the moment. #Current status Openduty is in Beta status, it can be considered stable at the moment, however major structural changes can appear anytime (not affecting the API, or the Notifier structure) diff --git a/extra/settings_prod.py.example b/extra/settings_prod.py.example index 08b7075..8ef2d9c 100644 --- a/extra/settings_prod.py.example +++ b/extra/settings_prod.py.example @@ -23,6 +23,11 @@ TWILIO_SETTINGS = { 'twiml_url': "http://www.website.org/voice.xml" } +SLACK_SETTINGS = { + 'apikey': "YOUR_SLACK_API_KEY" +} + + DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', diff --git a/notification/notifier/slack.py b/notification/notifier/slack.py index 584d868..85f3b58 100644 --- a/notification/notifier/slack.py +++ b/notification/notifier/slack.py @@ -7,7 +7,7 @@ def __init__(self, config): def notify(self, notification): slack = Slacker(self.__config['apikey']) - response = slack.chat.post_message(self.__config['channel'], notification.message) + response = slack.chat.post_message(notification.user_to_notify.profile.slack_room_name, notification.message) if not response.error: print "Slack message sent" else: diff --git a/openduty/models.py b/openduty/models.py index d299208..a106035 100644 --- a/openduty/models.py +++ b/openduty/models.py @@ -187,6 +187,7 @@ class UserProfile(models.Model): phone_number = models.CharField(max_length=50) pushover_user_key = models.CharField(max_length=50) pushover_app_key = models.CharField(max_length=50) + slack_room_name = models.CharField(max_length=50) def create_user_profile(sender, instance, created, **kwargs): diff --git a/openduty/templates/users/edit.html b/openduty/templates/users/edit.html index dd26c40..ebb2cae 100644 --- a/openduty/templates/users/edit.html +++ b/openduty/templates/users/edit.html @@ -77,6 +77,13 @@ +
+ + +
+ +
+
diff --git a/openduty/users.py b/openduty/users.py index b1d8295..6671e40 100644 --- a/openduty/users.py +++ b/openduty/users.py @@ -77,6 +77,7 @@ def save(request): profile.phone_number = request.POST['phone_number'] profile.pushover_user_key = request.POST['pushover_user_key'] profile.pushover_app_key = request.POST['pushover_app_key'] + profile.slack_room_name = request.POST['slack_room_name'] profile.save() return HttpResponseRedirect('/');