From eb6f7b3912f9f5a11862deafb262ea1b5a84fc86 Mon Sep 17 00:00:00 2001 From: Andy Voigt Date: Mon, 26 Aug 2013 17:51:10 +0200 Subject: WindowsPhoneToastNotify: add notification timeout --- module/plugins/hooks/WindowsPhoneToastNotify.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index 103180e3a..f02ce4696 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -15,19 +15,20 @@ @author: RaNaN, Godofdream, zoidberg """ -import sys, httplib +import time, httplib from module.plugins.Hook import Hook class WindowsPhoneToastNotify(Hook): __name__ = "WindowsPhoneToastNotify" - __version__ = "0.01" + __version__ = "0.02" __description__ = """Send push notifications to Windows Phone.""" __author_name__ = ("Andy Voigt") __author_mail__ = ("phone-support@hotmail.de") __config__ = [("activated", "bool", "Activated", False), ("force", "bool", "Force even if client is connected", False), - ("pushId", "pId", "pushId", ""), - ("pushUrl","pUrl","pushUrl", "")] + ("pushId", "str", "pushId", ""), + ("pushUrl","str","pushUrl", ""), + ("pushTimeout","int","Timeout between notifications in seconds","360")] def setup(self): self.info = {} @@ -50,9 +51,8 @@ class WindowsPhoneToastNotify(Hook): webservice.putheader("Content-length", "%d" % len(request)) webservice.endheaders() webservice.send(request) - #statuscode, statusmessage, header = webservice.getreply() - #result = webservice.getfile().read() webservice.close() + self.setStorage("LAST_NOTIFY", time.time()) def newCaptchaTask(self, task): if not self.getConfig("pushId") or not self.getConfig("pushUrl"): @@ -60,6 +60,9 @@ class WindowsPhoneToastNotify(Hook): if self.core.isClientConnected() and not self.getConfig("force"): return False - + + if (time.time() - self.getStorage("LAST_NOTIFY", 0)) >= self.getConf("pushTimeout"): + return False + self.doRequest() -- cgit v1.2.3 From f3271b811e0bbdd7a97f9e456f076d847e478979 Mon Sep 17 00:00:00 2001 From: Andy Voigt Date: Mon, 26 Aug 2013 21:28:46 +0200 Subject: WindowsPhoneToastNotify: fixed type of storage value --- module/plugins/hooks/WindowsPhoneToastNotify.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins') diff --git a/module/plugins/hooks/WindowsPhoneToastNotify.py b/module/plugins/hooks/WindowsPhoneToastNotify.py index f02ce4696..888862575 100644 --- a/module/plugins/hooks/WindowsPhoneToastNotify.py +++ b/module/plugins/hooks/WindowsPhoneToastNotify.py @@ -28,7 +28,7 @@ class WindowsPhoneToastNotify(Hook): ("force", "bool", "Force even if client is connected", False), ("pushId", "str", "pushId", ""), ("pushUrl","str","pushUrl", ""), - ("pushTimeout","int","Timeout between notifications in seconds","360")] + ("pushTimeout","int","Timeout between notifications in seconds","0")] def setup(self): self.info = {} @@ -61,7 +61,7 @@ class WindowsPhoneToastNotify(Hook): if self.core.isClientConnected() and not self.getConfig("force"): return False - if (time.time() - self.getStorage("LAST_NOTIFY", 0)) >= self.getConf("pushTimeout"): + if (time.time() - float(self.getStorage("LAST_NOTIFY", 0))) < self.getConf("pushTimeout"): return False self.doRequest() -- cgit v1.2.3