Added some code to catch user_typing event. Needs view implementation

This commit is contained in:
Manuel Cortez 2019-01-11 17:00:58 -06:00
parent 2ba4233ac7
commit da9425228e
3 changed files with 11 additions and 0 deletions

View File

@ -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 = []

View File

@ -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."""

View File

@ -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")