diff options
author | John Smith <mrdoctorwho@gmail.com> | 2017-04-28 11:59:49 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@gmail.com> | 2017-04-28 11:59:49 +0300 |
commit | ea7280eb73d1b31848d90482bced61c5af36a056 (patch) | |
tree | d2ad803099d2ba841b8a970248ea1236e2264265 | |
parent | 4eac76421c26e4797135344ab72432b73c994b56 (diff) |
Remove user id from typing users when user receivies a message from them (fixes #172)
-rw-r--r-- | gateway.py | 14 | ||||
-rw-r--r-- | library/longpoll.py | 7 |
2 files changed, 13 insertions, 8 deletions
@@ -728,7 +728,10 @@ class User(object): # If message wasn't sent by our user if not message["out"]: Stats["msgin"] += 1 - fromjid = vk2xmpp(message["uid"]) + frm = message["uid"] + if frm in self.typing: + del self.typing[frm] + fromjid = vk2xmpp(frm) body = uhtml(message["body"]) iter = Handlers["msg01"].__iter__() for func in iter: @@ -760,10 +763,11 @@ class User(object): Args: cTime: current time """ - for user, last in self.typing.items(): - if cTime - last > 7: - del self.typing[user] - sendMessage(self.source, vk2xmpp(user), typ="paused") + with self.sync: + for user, last in self.typing.items(): + if cTime - last > 7: + del self.typing[user] + sendMessage(self.source, vk2xmpp(user), typ="paused") def updateFriends(self, cTime): """ diff --git a/library/longpoll.py b/library/longpoll.py index 9f8a6aa..c79e219 100644 --- a/library/longpoll.py +++ b/library/longpoll.py @@ -130,9 +130,10 @@ def processPollResult(user, data): sendPresence(user.source, vk2xmpp(uid), "unavailable") elif typ == TYPE_TYPING: # user is typing - if evt[0] not in user.typing: - sendMessage(user.source, vk2xmpp(evt[0]), typ="composing") - user.typing[evt[0]] = time.time() + uid = evt[0] + if uid not in user.typing: + sendMessage(user.source, vk2xmpp(uid), typ="composing") + user.typing[uid] = time.time() retcode = CODE_FINE return retcode |