diff options
Diffstat (limited to 'module/plugins/hooks/XMPPInterface.py')
-rw-r--r-- | module/plugins/hooks/XMPPInterface.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/module/plugins/hooks/XMPPInterface.py b/module/plugins/hooks/XMPPInterface.py index a96adf524..adffc04e3 100644 --- a/module/plugins/hooks/XMPPInterface.py +++ b/module/plugins/hooks/XMPPInterface.py @@ -13,7 +13,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. - + @author: RaNaN @interface-version: 0.2 """ @@ -26,18 +26,19 @@ from pyxmpp.interfaces import * from module.plugins.hooks.IRCInterface import IRCInterface + class XMPPInterface(IRCInterface, JabberClient): __name__ = "XMPPInterface" - __version__ = "0.1" + __version__ = "0.11" __description__ = """connect to jabber and let owner perform different tasks""" __config__ = [("activated", "bool", "Activated", "False"), - ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), - ("pw", "str", "Password", ""), - ("tls", "bool", "Use TLS", False), - ("owners", "str", "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), - ("info_file", "bool", "Inform about every file finished", "False"), - ("info_pack", "bool", "Inform about every package finished", "True"), - ("captcha", "bool", "Send captcha requests", "True")] + ("jid", "str", "Jabber ID", "user@exmaple-jabber-server.org"), + ("pw", "str", "Password", ""), + ("tls", "bool", "Use TLS", False), + ("owners", "str", "List of JIDs accepting commands from", "me@icq-gateway.org;some@msn-gateway.org"), + ("info_file", "bool", "Inform about every file finished", "False"), + ("info_pack", "bool", "Inform about every package finished", "True"), + ("captcha", "bool", "Send captcha requests", "True")] __author_name__ = ("RaNaN") __author_mail__ = ("RaNaN@pyload.org") @@ -69,7 +70,7 @@ class XMPPInterface(IRCInterface, JabberClient): self.interface_providers = [ VersionHandler(self), self, - ] + ] def coreReady(self): self.new_package = {} @@ -97,22 +98,22 @@ class XMPPInterface(IRCInterface, JabberClient): try: self.loop() except Exception, ex: - self.core.log.error("pyLoad XMPP: %s" % str(ex)) + self.logError("pyLoad XMPP: %s" % str(ex)) def stream_state_changed(self, state, arg): """This one is called when the state of stream connecting the component to a server changes. This will usually be used to let the user know what is going on.""" - self.log.debug("pyLoad XMPP: *** State changed: %s %r ***" % (state, arg)) + self.logDebug("pyLoad XMPP: *** State changed: %s %r ***" % (state, arg)) def disconnected(self): - self.log.debug("pyLoad XMPP: Client was disconnected") + self.logDebug("pyLoad XMPP: Client was disconnected") def stream_closed(self, stream): - self.log.debug("pyLoad XMPP: Stream was closed | %s" % stream) + self.logDebug("pyLoad XMPP: Stream was closed | %s" % stream) def stream_error(self, err): - self.log.debug("pyLoad XMPP: Stream Error: %s" % err) + self.logDebug("pyLoad XMPP: Stream Error: %s" % err) def get_message_handlers(self): """Return list of (message_type, message_handler) tuples. @@ -120,16 +121,16 @@ class XMPPInterface(IRCInterface, JabberClient): The handlers returned will be called when matching message is received in a client session.""" return [ - ("normal", self.message), - ] + ("normal", self.message), + ] def message(self, stanza): """Message handler for the component.""" subject = stanza.get_subject() body = stanza.get_body() t = stanza.get_type() - self.log.debug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(), ))) - self.log.debug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t)) + self.logDebug(u'pyLoad XMPP: Message from %s received.' % (unicode(stanza.get_from(), ))) + self.logDebug(u'pyLoad XMPP: Body: %s Subject: %s Type: %s' % (body, subject, t)) if t == "headline": # 'headline' messages should never be replied to @@ -173,7 +174,7 @@ class XMPPInterface(IRCInterface, JabberClient): messages.append(m) except Exception, e: - self.log.error("pyLoad XMPP: " + repr(e)) + self.logError("pyLoad XMPP: " + repr(e)) return messages @@ -186,7 +187,7 @@ class XMPPInterface(IRCInterface, JabberClient): def announce(self, message): """ send message to all owners""" for user in self.getConfig("owners").split(";"): - self.log.debug("pyLoad XMPP: Send message to %s" % user) + self.logDebug("pyLoad XMPP: Send message to %s" % user) to_jid = JID(user) @@ -211,7 +212,7 @@ class XMPPInterface(IRCInterface, JabberClient): class VersionHandler(object): """Provides handler for a version query. - + This class will answer version query and announce 'jabber:iq:version' namespace in the client's disco#info results.""" @@ -230,8 +231,8 @@ class VersionHandler(object): """Return list of tuples (element_name, namespace, handler) describing handlers of <iq type='get'/> stanzas""" return [ - ("query", "jabber:iq:version", self.get_version), - ] + ("query", "jabber:iq:version", self.get_version), + ] def get_iq_set_handlers(self): """Return empty list, as this class provides no <iq type='set'/> stanza handler.""" @@ -248,4 +249,3 @@ class VersionHandler(object): q.newTextChild(q.ns(), "name", "Echo component") q.newTextChild(q.ns(), "version", "1.0") return iq -
\ No newline at end of file |