renamed xmpp task to jabber to avoid conflicts; added simple xmpp/jabber support to tasks
This commit is contained in:
parent
8be97eb781
commit
12040d0484
5 changed files with 41 additions and 27 deletions
31
lib/tasks/jabber.py
Normal file
31
lib/tasks/jabber.py
Normal 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)
|
||||
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue