Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

add subscribe command for notifications #29

Merged
merged 1 commit into from May 29, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions plugins/notify.py
Expand Up @@ -9,3 +9,18 @@ def send_notification(self, build_id, text):
notification_list = self.load("notify_{}".format(build_id), '')
self.say("{} BuildID: {}, Message: {}".format(notification_list, build_id, text))

@respond_to("^subscribe (@?)(?P<user>\w*) to (?P<build_id>\w*)")
def subscribe(self, message, user, build_id):
"""
subscribe [user] to [buildid]: request to be notified when builds complete
"""
if user == "me":
user = message.sender.nick

notification_list = "{} @{}".format(
self.load("notify_" + build_id, ''),
user)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notification_list = "{} @{}".format(self.load("notify_" + build_id, ''), user) would be clearer.

self.save('notify_{}'.format(build_id), notification_list)
self.say("OK, I'll tell {} when I hear about {}".format(', '.join(notification_list.replace("@", "").strip().split(" ")), build_id))