Make hipchat "notify" flag optional (default off)

This commit is contained in:
Mahemoff 2014-03-19 09:55:49 +00:00
parent 324a943e12
commit b4053b67d1

View file

@ -36,6 +36,7 @@ class CallbackModule(object):
HIPCHAT_TOKEN (required): HipChat API token
HIPCHAT_ROOM (optional): HipChat room to post in. Default: ansible
HIPCHAT_FROM (optional): Name to post as. Default: ansible
HIPCHAT_NOTIFY (optional): Add notify flag to important messages ("true" or "false"). Default: false
Requires:
prettytable
@ -52,6 +53,7 @@ class CallbackModule(object):
self.token = os.getenv('HIPCHAT_TOKEN')
self.room = os.getenv('HIPCHAT_ROOM', 'ansible')
self.from_name = os.getenv('HIPCHAT_FROM', 'ansible')
self.allow_notify = (os.getenv('HIPCHAT_NOTIFY') == 'true')
if self.token is None:
self.disabled = True
@ -71,7 +73,7 @@ class CallbackModule(object):
params['message'] = msg
params['message_format'] = msg_format
params['color'] = color
params['notify'] = int(notify)
params['notify'] = int(self.allow_notify and notify)
url = ('%s?auth_token=%s' % (self.msg_uri, self.token))
try: