xep 30 and 50 always reply from jid iq sent to
This commit is contained in:
@@ -3,4 +3,4 @@ from . import base
|
||||
class MatcherId(base.MatcherBase):
|
||||
|
||||
def match(self, xml):
|
||||
return xml.get('id') == self._criteria
|
||||
return xml['id'] == self._criteria
|
||||
|
||||
7
sleekxmpp/xmlstream/matcher/stanzapath.py
Normal file
7
sleekxmpp/xmlstream/matcher/stanzapath.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from . import base
|
||||
from xml.etree import cElementTree
|
||||
|
||||
class StanzaPath(base.MatcherBase):
|
||||
|
||||
def match(self, stanza):
|
||||
return stanza.match(self._criteria)
|
||||
@@ -16,6 +16,7 @@ class MatchXMLMask(base.MatcherBase):
|
||||
self.default_ns = ns
|
||||
|
||||
def match(self, xml):
|
||||
xml = xml.xml
|
||||
return self.maskcmp(xml, self._criteria, True)
|
||||
|
||||
def maskcmp(self, source, maskobj, use_ns=False, default_ns='__no_ns__'):
|
||||
|
||||
@@ -6,6 +6,7 @@ ignore_ns = False
|
||||
class MatchXPath(base.MatcherBase):
|
||||
|
||||
def match(self, xml):
|
||||
xml = xml.xml
|
||||
x = cElementTree.Element('x')
|
||||
x.append(xml)
|
||||
if not ignore_ns:
|
||||
|
||||
@@ -91,11 +91,27 @@ class ElementBase(object):
|
||||
out.append('substanzas')
|
||||
return tuple(out)
|
||||
|
||||
def find(self, item):
|
||||
return self.iterables.find(item)
|
||||
|
||||
def match(self, xml):
|
||||
return xml.tag == self.tag
|
||||
def match(self, matchstring):
|
||||
if isinstance(matchstring, str):
|
||||
nodes = matchstring.split('/')
|
||||
else:
|
||||
nodes = matchstring
|
||||
tagargs = nodes[0].split('@')
|
||||
if tagargs[0] not in (self.plugins, self.name): return False
|
||||
founditerable = False
|
||||
for iterable in self.iterables:
|
||||
founditerable = iterable.match(nodes[1:])
|
||||
if founditerable: break;
|
||||
for evals in tagargs[1:]:
|
||||
x,y = evals.split('=')
|
||||
if self[x] != y: return False
|
||||
if not founditerable and len(nodes) > 1:
|
||||
next = nodes[1].split('@')[0]
|
||||
if next in self.plugins:
|
||||
return self.plugins[next].match(nodes[1:])
|
||||
else:
|
||||
return False
|
||||
return True
|
||||
|
||||
def find(self, xpath): # for backwards compatiblity, expose elementtree interface
|
||||
return self.xml.find(xpath)
|
||||
|
||||
@@ -277,7 +277,7 @@ class XMLStream(object):
|
||||
stanza = StanzaBase(self, xmlobj)
|
||||
unhandled = True
|
||||
for handler in self.__handlers:
|
||||
if handler.match(xmlobj):
|
||||
if handler.match(stanza):
|
||||
handler.prerun(stanza)
|
||||
self.eventqueue.put(('stanza', handler, stanza))
|
||||
if handler.checkDelete(): self.__handlers.pop(self.__handlers.index(handler))
|
||||
|
||||
Reference in New Issue
Block a user