From 323d31514f7e438df5883ad6cb9e17cce6a296b3 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 2 May 2010 23:40:21 +0200 Subject: Added topic module --- connection/xmpp.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'connection') diff --git a/connection/xmpp.py b/connection/xmpp.py index 4104af7..4facfe8 100644 --- a/connection/xmpp.py +++ b/connection/xmpp.py @@ -25,16 +25,44 @@ class MucHandler(MucRoomHandler): MucRoomHandler.__init__(self) self.client = client + def reply(self, text): + self.room_state.send_message(text) + + def get_topic(self): + return self.room_state.subject + + def set_topic(self, topic): + self.room_state.set_subject(topic) + def message_received(self, user, stanza): - if(user.same_as(self.room_state.me)): + if(user == None or user.same_as(self.room_state.me) or stanza.get_body() == None): return for mod in self.client.module_manager.modules.itervalues(): - mod.groupchat(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, stanza.get_body(), self.room_state.send_message) + mod.groupchat(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, stanza.get_body(), self) def user_joined(self, user, stanza): if(not self.room_state.joined or user.same_as(self.room_state.me)): return + + for mod in self.client.module_manager.modules.itervalues(): + mod.join(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, stanza.get_show(), stanza.get_status(), self) + + def user_left(self, user, stanza): + if(not self.room_state.joined or user.same_as(self.room_state.me)): + return + + for mod in self.client.module_manager.modules.itervalues(): + mod.leave(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, stanza.get_show(), stanza.get_status(), self) + + def subject_changed(self, user, stanza): + topic = '' + if stanza.get_subject() != None: + topic = stanza.get_subject() + + for mod in self.client.module_manager.modules.itervalues(): + mod.topic(stanza.get_from().bare().as_unicode(), stanza.get_from().resource, topic, self) + class PresenceHandler(object): implements(IPresenceHandlersProvider) -- cgit v1.2.3