summaryrefslogtreecommitdiffstats
path: root/connection
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-05-02 20:28:17 +0200
committerMatthias Schiffer <matthias@gamezock.de>2010-05-02 20:31:34 +0200
commit0277a779c9dff841e04a08a5c39fe07faa92cfe8 (patch)
tree6a935f30a31a925c2c404dbbc119040b3b9e0acd /connection
parent41fec54c305d4a81245e9e294c7fc29fed9b7b00 (diff)
downloadcurunir-0277a779c9dff841e04a08a5c39fe07faa92cfe8.tar
curunir-0277a779c9dff841e04a08a5c39fe07faa92cfe8.zip
Added modules
Diffstat (limited to 'connection')
-rw-r--r--connection/xmpp.py32
1 files changed, 18 insertions, 14 deletions
diff --git a/connection/xmpp.py b/connection/xmpp.py
index 2c45291..423cd2a 100644
--- a/connection/xmpp.py
+++ b/connection/xmpp.py
@@ -4,6 +4,7 @@ from pyxmpp.client import Client
from pyxmpp.jabber.muc import *
from pyxmpp.interface import implements
from pyxmpp.interfaces import *
+from functools import partial
class MessageHandler:
implements(IMessageHandlersProvider)
@@ -17,25 +18,23 @@ class MessageHandler:
]
def message(self, stanza):
- return Message(
- to_jid=stanza.get_from(),
- from_jid=stanza.get_to(),
- stanza_type=stanza.get_type(),
- subject=stanza.get_subject(),
- body=stanza.get_body())
-
+ pass
+
class MucHandler(MucRoomHandler):
+ def __init__(self, client):
+ MucRoomHandler.__init__(self)
+ self.client = client
+
def message_received(self, user, stanza):
if(user.same_as(self.room_state.me)):
return
- self.room_state.send_message(stanza.get_body()[::-1])
+ for mod in self.client.module_manager.modules:
+ mod.groupchat(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, stanza.get_body(), self.room_state.send_message)
def user_joined(self, user, stanza):
if(not self.room_state.joined or user.same_as(self.room_state.me)):
return
-
- self.room_state.send_message('Willkommen, ' + user.nick)
class PresenceHandler(object):
implements(IPresenceHandlersProvider)
@@ -112,9 +111,12 @@ class VersionHandler(object):
class XMPPConnection(Client):
- def __init__(self, config):
- Client.__init__(self, JID(config['jid']), config['password'], tls_settings = TLSSettings(require = True, cacert_file = config['cacertfile']))
-
+ def __init__(self, config, modman):
+ self.config = config
+ self.module_manager = modman
+
+ Client.__init__(self, JID(config['jid']), config['password'], tls_settings = TLSSettings(require = True, cacert_file = config['cacertfile']), keepalive = 60)
+
self.interface_providers = [
MessageHandler(self),
PresenceHandler(self),
@@ -125,4 +127,6 @@ class XMPPConnection(Client):
Client.authorized(self)
self.room_manager = MucRoomManager(self.stream)
self.room_manager.set_handlers()
- self.room_manager.join(JID('c3hl@conference.jabber.ccc.de'), 'curunir', MucHandler(), history_maxstanzas=0)
+
+ for room in self.config['rooms']:
+ self.room_manager.join(JID(room), self.config['nick'], MucHandler(self), history_maxstanzas=0)