Added some code to catch user_typing event. Needs view implementation
This commit is contained in:
parent
2ba4233ac7
commit
da9425228e
@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
|
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
import time
|
||||||
import random
|
import random
|
||||||
import logging
|
import logging
|
||||||
import webbrowser
|
import webbrowser
|
||||||
@ -952,6 +953,7 @@ class chatBuffer(baseBuffer):
|
|||||||
super(chatBuffer, self).__init__(*args, **kwargs)
|
super(chatBuffer, self).__init__(*args, **kwargs)
|
||||||
self.reads = []
|
self.reads = []
|
||||||
self.chats = dict()
|
self.chats = dict()
|
||||||
|
self.peer_typing = 0
|
||||||
|
|
||||||
def parse_attachments(self, post):
|
def parse_attachments(self, post):
|
||||||
attachments = []
|
attachments = []
|
||||||
|
@ -123,6 +123,7 @@ class Controller(object):
|
|||||||
pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout")
|
pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout")
|
||||||
pub.subscribe(self.create_buffer, "create_buffer")
|
pub.subscribe(self.create_buffer, "create_buffer")
|
||||||
pub.subscribe(self.create_empty_buffer, "create_empty_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.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.update_buffer, menuitem=self.window.update_buffer)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
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"
|
sound = "friend_offline.ogg"
|
||||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
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):
|
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.
|
""" 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."""
|
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
|
||||||
|
@ -23,5 +23,7 @@ class worker(threading.Thread):
|
|||||||
pub.sendMessage("user-online", event=event)
|
pub.sendMessage("user-online", event=event)
|
||||||
elif event.type == VkEventType.USER_OFFLINE:
|
elif event.type == VkEventType.USER_OFFLINE:
|
||||||
pub.sendMessage("user-offline", event=event)
|
pub.sendMessage("user-offline", event=event)
|
||||||
|
elif event.type == VkEventType.USER_TYPING:
|
||||||
|
pub.sendMessage("user-typing", event=event)
|
||||||
except:
|
except:
|
||||||
pub.sendMessage("longpoll-read-timeout")
|
pub.sendMessage("longpoll-read-timeout")
|
Loading…
Reference in New Issue
Block a user