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@gmail.com>2017-04-28 11:59:49 +0300
committerJohn Smith <mrdoctorwho@gmail.com>2017-04-28 11:59:49 +0300
commitea7280eb73d1b31848d90482bced61c5af36a056 (patch)
treed2ad803099d2ba841b8a970248ea1236e2264265
parent4eac76421c26e4797135344ab72432b73c994b56 (diff)
Remove user id from typing users when user receivies a message from them (fixes #172)
-rw-r--r--gateway.py14
-rw-r--r--library/longpoll.py7
2 files changed, 13 insertions, 8 deletions
diff --git a/gateway.py b/gateway.py
index 5804d37..880ba86 100644
--- a/gateway.py
+++ b/gateway.py
@@ -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