Made notification subject optional per single-line standard.

Added option to include custom (plex) emoticon at the beginning of each notification.  (Feature only relevant to Hipchat.)
This commit is contained in:
aboron 2016-07-08 09:36:45 -04:00
parent 2b6fa769f7
commit e5bcd1f94e
2 changed files with 41 additions and 19 deletions

View file

@ -212,6 +212,25 @@ _CONFIG_DEFINITIONS = {
'HTTP_PROXY': (int, 'General', 0), 'HTTP_PROXY': (int, 'General', 0),
'HTTP_ROOT': (str, 'General', ''), 'HTTP_ROOT': (str, 'General', ''),
'HTTP_USERNAME': (str, 'General', ''), 'HTTP_USERNAME': (str, 'General', ''),
'HIPCHAT_URL': (str, 'Hipchat', ''),
'HIPCHAT_COLOR': (str, 'Hipchat', 'green'),
'HIPCHAT_INCL_SUBJECT': (int, 'Hipchat', 1),
'HIPCHAT_INCL_EMOTICON': (int, 'Hipchat', 0),
'HIPCHAT_ENABLED': (int, 'Hipchat', 0),
'HIPCHAT_ON_PLAY': (int, 'Hipchat', 0),
'HIPCHAT_ON_STOP': (int, 'Hipchat', 0),
'HIPCHAT_ON_PAUSE': (int, 'Hipchat', 0),
'HIPCHAT_ON_RESUME': (int, 'Hipchat', 0),
'HIPCHAT_ON_BUFFER': (int, 'Hipchat', 0),
'HIPCHAT_ON_WATCHED': (int, 'Hipchat', 0),
'HIPCHAT_ON_CREATED': (int, 'Hipchat', 0),
'HIPCHAT_ON_EXTDOWN': (int, 'Hipchat', 0),
'HIPCHAT_ON_INTDOWN': (int, 'Hipchat', 0),
'HIPCHAT_ON_EXTUP': (int, 'Hipchat', 0),
'HIPCHAT_ON_INTUP': (int, 'Hipchat', 0),
'HIPCHAT_ON_PMSUPDATE': (int, 'Hipchat', 0),
'HIPCHAT_ON_CONCURRENT': (int, 'Hipchat', 0),
'HIPCHAT_ON_NEWDEVICE': (int, 'Hipchat', 0),
'INTERFACE': (str, 'General', 'default'), 'INTERFACE': (str, 'General', 'default'),
'IP_LOGGING_ENABLE': (int, 'General', 0), 'IP_LOGGING_ENABLE': (int, 'General', 0),
'IFTTT_KEY': (str, 'IFTTT', ''), 'IFTTT_KEY': (str, 'IFTTT', ''),
@ -250,23 +269,6 @@ _CONFIG_DEFINITIONS = {
'JOIN_ON_PMSUPDATE': (int, 'Join', 0), 'JOIN_ON_PMSUPDATE': (int, 'Join', 0),
'JOIN_ON_CONCURRENT': (int, 'Join', 0), 'JOIN_ON_CONCURRENT': (int, 'Join', 0),
'JOIN_ON_NEWDEVICE': (int, 'Join', 0), 'JOIN_ON_NEWDEVICE': (int, 'Join', 0),
'HIPCHAT_URL': (str, 'Hipchat', ''),
'HIPCHAT_COLOR': (str, 'Hipchat', 'green'),
'HIPCHAT_ENABLED': (int, 'Hipchat', 0),
'HIPCHAT_ON_PLAY': (int, 'Hipchat', 0),
'HIPCHAT_ON_STOP': (int, 'Hipchat', 0),
'HIPCHAT_ON_PAUSE': (int, 'Hipchat', 0),
'HIPCHAT_ON_RESUME': (int, 'Hipchat', 0),
'HIPCHAT_ON_BUFFER': (int, 'Hipchat', 0),
'HIPCHAT_ON_WATCHED': (int, 'Hipchat', 0),
'HIPCHAT_ON_CREATED': (int, 'Hipchat', 0),
'HIPCHAT_ON_EXTDOWN': (int, 'Hipchat', 0),
'HIPCHAT_ON_INTDOWN': (int, 'Hipchat', 0),
'HIPCHAT_ON_EXTUP': (int, 'Hipchat', 0),
'HIPCHAT_ON_INTUP': (int, 'Hipchat', 0),
'HIPCHAT_ON_PMSUPDATE': (int, 'Hipchat', 0),
'HIPCHAT_ON_CONCURRENT': (int, 'Hipchat', 0),
'HIPCHAT_ON_NEWDEVICE': (int, 'Hipchat', 0),
'JOURNAL_MODE': (str, 'Advanced', 'wal'), 'JOURNAL_MODE': (str, 'Advanced', 'wal'),
'LAUNCH_BROWSER': (int, 'General', 1), 'LAUNCH_BROWSER': (int, 'General', 1),
'LOG_BLACKLIST': (int, 'General', 1), 'LOG_BLACKLIST': (int, 'General', 1),

View file

@ -2754,12 +2754,20 @@ class HIPCHAT(object):
def __init__(self): def __init__(self):
self.apiurl = plexpy.CONFIG.HIPCHAT_URL self.apiurl = plexpy.CONFIG.HIPCHAT_URL
self.color = plexpy.CONFIG.HIPCHAT_COLOR self.color = plexpy.CONFIG.HIPCHAT_COLOR
self.incl_subject = plexpy.CONFIG.HIPCHAT_INCL_SUBJECT
self.incl_emoticon = plexpy.CONFIG.HIPCHAT_INCL_EMOTICON
def notify(self, message, subject): def notify(self, message, subject):
if not message or not subject: if not message or not subject:
return return
text = '(plex) ' + subject.encode('utf-8') + ': ' + message.encode('utf-8') if self.incl_subject:
text = subject.encode('utf-8') + ': ' + message.encode('utf-8')
else:
text = message.encode('utf-8')
if self.incl_emoticon:
text = '(plex) ' + text
data = {'color': self.color, data = {'color': self.color,
'message': text, 'message': text,
@ -2811,8 +2819,20 @@ class HIPCHAT(object):
'description': 'Color for the message to show up in your room. You' 'description': 'Color for the message to show up in your room. You'
' may use any valid Hipchat message color value.', ' may use any valid Hipchat message color value.',
'input_type': 'text' 'input_type': 'text'
},
{'label': 'Include Subject Line',
'value': self.incl_subject,
'name': 'hipchat_incl_subject',
'description': 'Include the subject line with the notifications.',
'input_type': 'checkbox'
},
{'label': 'Include (plex) emoticon',
'value': self.incl_emoticon,
'name': 'hipchat_incl_emoticon',
'description': 'Include (plex) emoticon tag at the beginning of all notifications.'
' Create a custom emoticon <a href="' + helpers.anon_url('https://www.hipchat.com/emoticons/') + '" target="_blank">here</a>.',
'input_type': 'checkbox'
} }
] ]
return config_option return config_option