renamed xmpp task to jabber to avoid conflicts; added simple xmpp/jabber support to tasks

This commit is contained in:
Johannes Findeisen 2013-09-19 20:50:17 +02:00
commit 1e8ad1f110
5 changed files with 41 additions and 27 deletions

31
lib/tasks/jabber.py Normal file
View file

@ -0,0 +1,31 @@
"""
The Jabber task.
Uses: http://xmpppy.sourceforge.net/
"""
import xmpp
from lib.tasks.task import Task
class JabberTask(Task):
def __init__(self, **kwargs):
if not "type" in kwargs:
raise Exception("'type' not in typeDict " + str(kwargs))
if not "args" in kwargs:
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
self.set_task_type(kwargs["type"])
self.recipient = kwargs["args"]["rcpt"]
def execute(self, msg):
client = xmpp.Client('systemchaos.org')
client.connect(server=('systemchaos.org', 5222))
client.auth('linspector', 'PASSWORD', 'alert')
client.sendInitPresence()
message = xmpp.Message('hanez@systemchaos.org', msg)
message.setAttr('type', 'chat')
client.send(message)
def create(taskDict):
return JabberTask(**taskDict)

View file

@ -1,22 +0,0 @@
"""
The xmpp task.
"""
from lib.tasks.task import Task
class XmppTask(Task):
def __init__(self, **kwargs):
if not "type" in kwargs:
raise Exception("'type' not in typeDict " + str(kwargs))
if not "args" in kwargs:
raise Exception("typeDict " + str(kwargs) + " has nor arguments!")
self.set_task_type(kwargs["type"])
self.recipient = kwargs["args"]["rcpt"]
def execute_task(self, msg):
pass
def create(taskDict):
return XmppTask(**taskDict)