You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

from couchpotato.api import addApiView
14 years ago
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog
14 years ago
from couchpotato.core.plugins.base import Plugin
14 years ago
log = CPLog(__name__)
14 years ago
class Notification(Plugin):
default_title = 'CouchPotato'
test_message = 'ZOMG Lazors Pewpewpew!'
listen_to = ['movie.downloaded', 'movie.snatched']
dont_listen_to = []
14 years ago
def __init__(self):
addEvent('notify.%s' % self.getName().lower(), self.notify)
14 years ago
addApiView(self.testNotifyName(), self.test)
# Attach listeners
for listener in self.listen_to:
if not listener in self.dont_listen_to:
addEvent(listener, self.notify)
def notify(self, message = '', data = {}):
14 years ago
pass
def test(self):
test_type = self.testNotifyName()
log.info('Sending test to %s' % test_type)
success = self.notify(
message = self.test_message,
data = {}
)
return jsonified({'success': success})
def testNotifyName(self):
return 'notify.%s.test' % self.getName().lower()