mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 15:56:07 -07:00
initial agent settings
This commit is contained in:
parent
1c539f00dd
commit
50b06e041c
1 changed files with 46 additions and 4 deletions
|
@ -52,7 +52,8 @@ AGENT_IDS = {"Growl": 0,
|
||||||
"Email": 10,
|
"Email": 10,
|
||||||
"Twitter": 11,
|
"Twitter": 11,
|
||||||
"IFTTT": 12,
|
"IFTTT": 12,
|
||||||
"Telegram": 13}
|
"Telegram": 13,
|
||||||
|
"Slack":14}
|
||||||
|
|
||||||
def available_notification_agents():
|
def available_notification_agents():
|
||||||
agents = [{'name': 'Growl',
|
agents = [{'name': 'Growl',
|
||||||
|
@ -275,7 +276,24 @@ def available_notification_agents():
|
||||||
'on_intdown': plexpy.CONFIG.TELEGRAM_ON_INTDOWN,
|
'on_intdown': plexpy.CONFIG.TELEGRAM_ON_INTDOWN,
|
||||||
'on_extup': plexpy.CONFIG.TELEGRAM_ON_EXTUP,
|
'on_extup': plexpy.CONFIG.TELEGRAM_ON_EXTUP,
|
||||||
'on_intup': plexpy.CONFIG.TELEGRAM_ON_INTUP
|
'on_intup': plexpy.CONFIG.TELEGRAM_ON_INTUP
|
||||||
}
|
},
|
||||||
|
{'name': 'Slack',
|
||||||
|
'id': AGENT_IDS['Slack'],
|
||||||
|
'config_prefix': 'slack',
|
||||||
|
'has_config': True,
|
||||||
|
'state': checked(plexpy.CONFIG.SLACK_ENABLED),
|
||||||
|
'on_play': plexpy.CONFIG.SLACK_ON_PLAY,
|
||||||
|
'on_stop': plexpy.CONFIG.SLACK_ON_STOP,
|
||||||
|
'on_resume': plexpy.CONFIG.SLACK_ON_RESUME,
|
||||||
|
'on_pause': plexpy.CONFIG.SLACK_ON_PAUSE,
|
||||||
|
'on_buffer': plexpy.CONFIG.SLACK_ON_BUFFER,
|
||||||
|
'on_watched': plexpy.CONFIG.SLACK_ON_WATCHED,
|
||||||
|
'on_created': plexpy.CONFIG.SLACK_ON_CREATED,
|
||||||
|
'on_extdown': plexpy.CONFIG.SLACK_ON_EXTDOWN,
|
||||||
|
'on_intdown': plexpy.CONFIG.SLACK_ON_INTDOWN,
|
||||||
|
'on_extup': plexpy.CONFIG.SLACK_ON_EXTUP,
|
||||||
|
'on_intup': plexpy.CONFIG.SLACK_ON_INTUP
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
# OSX Notifications should only be visible if it can be used
|
# OSX Notifications should only be visible if it can be used
|
||||||
|
@ -347,6 +365,9 @@ def get_notification_agent_config(config_id):
|
||||||
elif config_id == 13:
|
elif config_id == 13:
|
||||||
telegramClient = TELEGRAM()
|
telegramClient = TELEGRAM()
|
||||||
return telegramClient.return_config_options()
|
return telegramClient.return_config_options()
|
||||||
|
elif config_id == 14:
|
||||||
|
slackClient = SLACK()
|
||||||
|
return slackClient.return_config_options()
|
||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
|
@ -398,6 +419,9 @@ def send_notification(config_id, subject, body):
|
||||||
elif config_id == 13:
|
elif config_id == 13:
|
||||||
telegramClient = TELEGRAM()
|
telegramClient = TELEGRAM()
|
||||||
telegramClient.notify(message=body, event=subject)
|
telegramClient.notify(message=body, event=subject)
|
||||||
|
elif config_id == 13:
|
||||||
|
slackClient = SLACK()
|
||||||
|
slackClient.notify(message=body, event=subject)
|
||||||
else:
|
else:
|
||||||
logger.debug(u"PlexPy Notifier :: Unknown agent id received.")
|
logger.debug(u"PlexPy Notifier :: Unknown agent id received.")
|
||||||
else:
|
else:
|
||||||
|
@ -860,7 +884,7 @@ class PUSHBULLET(object):
|
||||||
'Authorization': 'Basic %s' % base64.b64encode(plexpy.CONFIG.PUSHBULLET_APIKEY + ":")})
|
'Authorization': 'Basic %s' % base64.b64encode(plexpy.CONFIG.PUSHBULLET_APIKEY + ":")})
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
request_status = response.status
|
request_status = response.status
|
||||||
|
|
||||||
if request_status == 200:
|
if request_status == 200:
|
||||||
data = json.loads(response.read())
|
data = json.loads(response.read())
|
||||||
devices = data.get('devices', [])
|
devices = data.get('devices', [])
|
||||||
|
@ -1021,7 +1045,7 @@ class PUSHOVER(object):
|
||||||
http_handler.request("GET", "/1/sounds.json?token=" + self.application_token)
|
http_handler.request("GET", "/1/sounds.json?token=" + self.application_token)
|
||||||
response = http_handler.getresponse()
|
response = http_handler.getresponse()
|
||||||
request_status = response.status
|
request_status = response.status
|
||||||
|
|
||||||
if request_status == 200:
|
if request_status == 200:
|
||||||
data = json.loads(response.read())
|
data = json.loads(response.read())
|
||||||
sounds = data.get('sounds', {})
|
sounds = data.get('sounds', {})
|
||||||
|
@ -1574,3 +1598,21 @@ class TELEGRAM(object):
|
||||||
]
|
]
|
||||||
|
|
||||||
return config_option
|
return config_option
|
||||||
|
|
||||||
|
class SLACK(object):
|
||||||
|
"""
|
||||||
|
Slack Notifications
|
||||||
|
"""
|
||||||
|
def __init__(self):
|
||||||
|
self.enabled = plexpy.CONFIG.SLACK_ENABLED
|
||||||
|
self.slack_hook = plexpy.CONFIG.SLACK_HOOK
|
||||||
|
self.channel = plexpy.CONFIG.SLACK_CHANNEL
|
||||||
|
self.username = plexpy.CONFIG.SLACK_USERNAME
|
||||||
|
self.icon_emoji = plexpy.CONFIG.SLACK_ICON_EMOJI
|
||||||
|
|
||||||
|
def conf(self, options):
|
||||||
|
return cherrypy.config['config'].get('Telegram', options)
|
||||||
|
|
||||||
|
def notify(self, message, event)
|
||||||
|
if not message or not event:
|
||||||
|
return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue