summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Baumann <derflob@derflob.de>2015-09-07 17:59:04 +0200
committerFlorian Baumann <derflob@derflob.de>2015-09-07 17:59:04 +0200
commitc16e92e9ff5b1ed5637fb00b0e1df012d8145fc5 (patch)
treefc66454775de93833f64b3c514f2dd3c5bb0f45c
parent25990eec560354b2ce58e159e424fc707c5dbfbe (diff)
downloadxmpp-c16e92e9ff5b1ed5637fb00b0e1df012d8145fc5.tar.gz
xmpp-c16e92e9ff5b1ed5637fb00b0e1df012d8145fc5.tar.bz2
working prototype
-rw-r--r--__init__.py15
1 files changed, 11 insertions, 4 deletions
diff --git a/__init__.py b/__init__.py
index 69a8735..2288df3 100644
--- a/__init__.py
+++ b/__init__.py
@@ -10,7 +10,12 @@ class OctoXMPP(octoprint.plugin.EventHandlerPlugin,
passwd = self._settings.get(["password"])
self._xmpp = ClientXMPP(jid, passwd)
- self._xmpp.add_event_handler("session_start", self._xmpp.send_presence)
+
+ def session_start(s):
+ self._xmpp.send_presence(ptype="available")
+ self._xmpp.get_roster()
+
+ self._xmpp.add_event_handler("session_start", session_start)
self._xmpp.connect()
self._xmpp.process(threaded=True)
@@ -20,7 +25,7 @@ class OctoXMPP(octoprint.plugin.EventHandlerPlugin,
def _msg_receivers(self, msg):
for r in self._settings.get(["receivers"]):
- self._xmpp.send_message(mto=r, mbody=msg)
+ self._xmpp.send_message(mto=r, mbody=msg, mtype="chat")
def on_event(self, event, data):
if (event == "PrintDone"):
@@ -33,10 +38,12 @@ class OctoXMPP(octoprint.plugin.EventHandlerPlugin,
self._msg_receivers("Druck resümiert.")
elif (event == "PrintCancelled"):
self._msg_receivers("Druck abgebrochen!")
+ elif (event == "PrintStarted"):
+ self._msg_receivers("Druck begonnen.")
else:
- self._xmpp.send_message(mto="derflob@derflob.de", mbody=event)
+ self._xmpp.send_message(mto="derflob@derflob.de", mbody=event, mtype="chat")
__plugin_name__ = "OctoXMPP"
-__plugin_version__ = "0.1.0"
+__plugin_version__ = "0.1.1"
__plugin_description__ = "Notify about some Events over XMPP."
__plugin_implementation__ = OctoXMPP()