Notification update

This commit is contained in:
Ruud
2011-08-18 15:52:07 +02:00
parent b69bab4235
commit 31e57b9510
15 changed files with 112 additions and 70 deletions
+30 -3
View File
@@ -1,20 +1,47 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
log = CPLog(__name__)
class Notification(Plugin):
default_title = 'CouchPotato'
test_message = 'ZOMG Lazors Pewpewpew!'
listen_to = []
dont_listen_to = []
def __init__(self):
addEvent('notify', self.notify)
addEvent('notify.%s' % self.getName().lower(), self.notify)
def notify(self, message = '', data = {}):
addApiView(self.testNotifyName(), self.test)
def notify(self, message = '', data = {}, type = ''):
pass
def test(self):
success = self.notify(message = self.test_message)
return jsonified({'success': success})
test_type = self.testNotifyName()
log.info('Sending test to %s' % test_type)
success = self.notify(
message = self.test_message,
data = {},
type = test_type
)
#return jsonified({'success': success})
def dontNotify(self, type = ''):
return (not type in self.listen_to and len(self.listen_to) == 0 and type != self.testNotifyName()) \
or type in self.dont_listen_to \
or self.isDisabled()
def testNotifyName(self):
return 'notify.%s.test' % self.getName().lower()