diff --git a/src/controller/buffers.py b/src/controller/buffers.py index b561c9d..971b45c 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- """ A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)""" from __future__ import unicode_literals +import time import random import logging import webbrowser @@ -952,6 +953,7 @@ class chatBuffer(baseBuffer): super(chatBuffer, self).__init__(*args, **kwargs) self.reads = [] self.chats = dict() + self.peer_typing = 0 def parse_attachments(self, post): attachments = [] diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 093a801..86d3d86 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -123,6 +123,7 @@ class Controller(object): pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout") pub.subscribe(self.create_buffer, "create_buffer") pub.subscribe(self.create_empty_buffer, "create_empty_buffer") + pub.subscribe(self.user_typing, "user-typing") widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates) @@ -397,6 +398,12 @@ class Controller(object): sound = "friend_offline.ogg" self.notify(msg, sound, self.session.settings["chat"]["notifications"]) + def user_typing(self, obj): + buffer = self.search_chat_buffer(obj.user_id) + if buffer != None and buffer == self.get_current_buffer(): + user = self.session.get_user_name(obj.user_id) + output.speak(_("{user1_nom} is typing...").format(**user)) + def get_chat(self, obj=None): """ Searches or creates a chat buffer with the id of the user that is sending or receiving a message. obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server.""" diff --git a/src/presenters/longpollthread.py b/src/presenters/longpollthread.py index 6162984..1cc16d6 100644 --- a/src/presenters/longpollthread.py +++ b/src/presenters/longpollthread.py @@ -23,5 +23,7 @@ class worker(threading.Thread): pub.sendMessage("user-online", event=event) elif event.type == VkEventType.USER_OFFLINE: pub.sendMessage("user-offline", event=event) + elif event.type == VkEventType.USER_TYPING: + pub.sendMessage("user-typing", event=event) except: pub.sendMessage("longpoll-read-timeout") \ No newline at end of file