aboutsummaryrefslogtreecommitdiffstats
path: root/plugin.py
blob: a88d2441343a5fcac2e9ddb0e64a4ade9ac4af02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from sleekxmpp.xmlstream.stanzabase import ElementBase, registerStanzaPlugin
from sleekxmpp.plugins import base
from sleekxmpp.xmlstream.handler.callback import Callback
from sleekxmpp.xmlstream.matcher.xpath import MatchXPath
from sleekxmpp.stanza.iq import Iq
import logging

class AliasQuery(ElementBase) :
    namespace = 'alias:query'
    name = 'query'
    plugin_attrib = 'query'
    interfaces = set(('node', 'type', 'items','object'))
    sub_interfaces = set(('items'))
    

class AliasPlugin(base.base_plugin) :
    
    def plugin_init(self) :
        self.description = 'Plugin to handle alias queries'
        registerStanzaPlugin(Iq, AliasQuery)
        
        self.xmpp.registerHandler(
            Callback('Alias queries',
                 MatchXPath('{%s}iq/{%s}query' % (self.xmpp.default_ns, 
                                  AliasQuery.namespace)),
                 self.handle_alias_query))
        
    def handle_alias_query(self, iq) :
        iq.reply().send()