Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mrDoctorWho/vk4xmpp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Smith <mrdoctorwho@helldev.net>2019-09-06 05:35:38 +0300
committerJohn Smith <mrdoctorwho@helldev.net>2019-09-06 05:35:38 +0300
commit87302c58d20cd6d23adad000c613776cc2be8c3d (patch)
tree60a619ea287226a6a4dd7b6f20da88bac9dfe003
parent72a074f2a04bac12c92e45b7d01990680fda3ee0 (diff)
Change isAppUser method to users.get
-rw-r--r--gateway.py11
-rw-r--r--modules/mod_msg_main.py4
-rw-r--r--modules/mod_msg_xhtml.py6
3 files changed, 16 insertions, 5 deletions
diff --git a/gateway.py b/gateway.py
index 0477db6..a5ba21d 100644
--- a/gateway.py
+++ b/gateway.py
@@ -194,7 +194,7 @@ def getGatewayRev():
"""
Gets gateway revision using git or custom revision number
"""
- number, hash = 420, 0
+ number, hash = 460, 0
shell = os.popen("git describe --always &"
"& git log --pretty=format:''").readlines()
if shell:
@@ -279,8 +279,10 @@ class VK(object):
Checks the token
"""
try:
- int(self.engine.method("isAppUser"))
- except (api.VkApiError, TypeError, AttributeError):
+ data = self.engine.method("users.get")
+ if not data:
+ raise RuntimeError("Unable to get data for user!")
+ except api.VkApiError:
logger.error("unable to check user's token, error: %s (user: %s)",
traceback.format_exc(), self.source)
return False
@@ -578,7 +580,8 @@ class VK(object):
data = self.method("groups.getById", {"group_id": abs(gid), "fields": str.join(",", fields)})
if data:
data = data[0]
- return data
+ return data
+ raise RuntimeError("Unable to get group data")
@utils.cache
@api.repeat(3, dict, RuntimeError)
diff --git a/modules/mod_msg_main.py b/modules/mod_msg_main.py
index a1bd57d..7a3410e 100644
--- a/modules/mod_msg_main.py
+++ b/modules/mod_msg_main.py
@@ -57,6 +57,10 @@ def message_handler(cl, msg):
jidTo = msg.getTo()
destination = jidTo.getStripped()
jidFrom = msg.getFrom()
+ if isinstance(jidFrom, (str, unicode)):
+ logger.warning("Received message did not contain a valid jid: %s", msg)
+ raise xmpp.NodeProcessed()
+
source = jidFrom.getStripped()
if msg.getType() == "chat" and source in Users:
diff --git a/modules/mod_msg_xhtml.py b/modules/mod_msg_xhtml.py
index fa12a74..8122a61 100644
--- a/modules/mod_msg_xhtml.py
+++ b/modules/mod_msg_xhtml.py
@@ -9,7 +9,11 @@ import mod_xhtml
def xhtml_handler(cl, msg):
destination = msg.getTo().getStripped()
- source = msg.getFrom().getStripped()
+ source = msg.getFrom()
+ if isinstance(source, (str, unicode)):
+ logger.warning("Received message did not contain a valid jid: %s", msg)
+ raise xmpp.NodeProcessed()
+ source = source.getStripped()
if source in Users and msg.getType() == "chat":
user = Users[source]
html = msg.getTag("html")