xmpp - set from if empty
This commit is contained in:
parent
a3e7d61987
commit
32ae8468a3
1 changed files with 7 additions and 12 deletions
|
|
@ -243,6 +243,7 @@ class XMPPAsyncClient:
|
||||||
and client.state == client.READY
|
and client.state == client.READY
|
||||||
):
|
):
|
||||||
ctl_to = xml.get("to")
|
ctl_to = xml.get("to")
|
||||||
|
if not "from" in xml.attrib:
|
||||||
xml.attrib["from"] = "{}".format(self.bumper_jid)
|
xml.attrib["from"] = "{}".format(self.bumper_jid)
|
||||||
rxmlstring = ET.tostring(xml).decode("utf-8")
|
rxmlstring = ET.tostring(xml).decode("utf-8")
|
||||||
# clean up string to remove namespaces added by ET
|
# clean up string to remove namespaces added by ET
|
||||||
|
|
@ -274,8 +275,8 @@ class XMPPAsyncClient:
|
||||||
else:
|
else:
|
||||||
pingto = xml.get("to")
|
pingto = xml.get("to")
|
||||||
pingfrom = self.bumper_jid
|
pingfrom = self.bumper_jid
|
||||||
|
if not "from" in xml.attrib:
|
||||||
xml.attrib["from"] = pingfrom
|
xml.attrib["from"] = "{}".format(pingfrom)
|
||||||
pingstring = ET.tostring(xml).decode("utf-8")
|
pingstring = ET.tostring(xml).decode("utf-8")
|
||||||
# clean up string to remove namespaces added by ET
|
# clean up string to remove namespaces added by ET
|
||||||
pingstring = pingstring.replace("xmlns:ns0=", "xmlns=")
|
pingstring = pingstring.replace("xmlns:ns0=", "xmlns=")
|
||||||
|
|
@ -289,14 +290,7 @@ class XMPPAsyncClient:
|
||||||
client.bumper_jid != self.bumper_jid
|
client.bumper_jid != self.bumper_jid
|
||||||
and client.state == client.READY
|
and client.state == client.READY
|
||||||
):
|
):
|
||||||
if pingto.lower() in client.bumper_jid.lower():
|
if client.uid.lower() in pingto.lower():
|
||||||
#pingstring = '<iq type="result" id="{}" from="{}" to="{}" />'.format(
|
|
||||||
# xml.get("id"), pingfrom, pingto
|
|
||||||
#)
|
|
||||||
#xmppserverlog.debug(
|
|
||||||
# "ping from {} to {} with {}".format(pingfrom, pingto, pingstring)
|
|
||||||
#)
|
|
||||||
|
|
||||||
await client.send(pingstring)
|
await client.send(pingstring)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
@ -313,7 +307,8 @@ class XMPPAsyncClient:
|
||||||
async def _handle_result(self, xml, data):
|
async def _handle_result(self, xml, data):
|
||||||
try:
|
try:
|
||||||
ctl_to = xml.get("to")
|
ctl_to = xml.get("to")
|
||||||
xml.attrib["from"] = self.bumper_jid
|
if not "from" in xml.attrib:
|
||||||
|
xml.attrib["from"] = "{}".format(self.bumper_jid)
|
||||||
if (
|
if (
|
||||||
"errno='103' error='permission denied," in data
|
"errno='103' error='permission denied," in data
|
||||||
): # No permissions, usually if bot was last on Ecovac network
|
): # No permissions, usually if bot was last on Ecovac network
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue