diff options
author | John Smith <mrdoctorwho@gmail.com> | 2017-04-30 15:24:46 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@gmail.com> | 2017-04-30 15:24:46 +0300 |
commit | 3d350af0ca8c8a888f0f2c611e0986020822f139 (patch) | |
tree | f4f9c809d99233d960b29c62024071914ebad37d | |
parent | 471e3cce3651f0d0d1e9ac4eb3ed88d857d7f0aa (diff) |
Fix debugging output coloring
-rw-r--r-- | extensions/groupchats.py | 3 | ||||
-rw-r--r-- | gateway.py | 4 | ||||
-rw-r--r-- | library/vkapi.py | 4 |
3 files changed, 8 insertions, 3 deletions
diff --git a/extensions/groupchats.py b/extensions/groupchats.py index 9bf7717..64950c2 100644 --- a/extensions/groupchats.py +++ b/extensions/groupchats.py @@ -302,6 +302,9 @@ class Chat(object): if user not in old_users: logger.debug("groupchats: user %s has joined the chat %s (jid: %s)", user, self.jid, userObject.source) + # TODO: Transport MUST NOT request a name for each user it sees. + # It should be done with a list of users + # E.g. requesting a list of users and get a list of names name = userObject.vk.getUserData(user)["name"] self.users[int(user)] = {"name": name, "jid": jid} setAffiliation(self.jid, "member", jid) @@ -515,7 +515,7 @@ class VK(object): """ Gets user data. Such as name, photo, etc Args: - uid: the user id + uid: the user id (list or str) fields: a list of advanced fields to receive Returns: The user information @@ -525,6 +525,8 @@ class VK(object): if user and uid in user.friends: return user.friends[uid] fields = ["screen_name"] + if isinstance(uid, (list, tuple)): + uid = str.join(",", uid) data = self.method("users.get", {"user_ids": uid, "fields": str.join(",", fields)}) if data: data = data[0] diff --git a/library/vkapi.py b/library/vkapi.py index 06fdaf5..6e701ba 100644 --- a/library/vkapi.py +++ b/library/vkapi.py @@ -335,7 +335,7 @@ class APIBinding(RequestProcessor): start = time.time() if method in self.debug or self.debug == "all": Print("SENT: method %s with values %s in thread: %s" % (method, - colorizeJSON(str(values)), threading.currentThread().name)) + colorizeJSON(values), threading.currentThread().name)) response = self.post(url, values) if response: @@ -348,7 +348,7 @@ class APIBinding(RequestProcessor): if self.debug: end = time.time() - dbg = (method, colorizeJSON(str(body)), threading.currentThread().name, (end - start), self.logline) + dbg = (method, colorizeJSON(body), threading.currentThread().name, (end - start), self.logline) if method in self.debug or self.debug == "all": Print("GOT: for method %s: %s in thread: %s (%0.2fs) for %s" % dbg) |