From 4ae167e461d2ce2ee7435421122be6c710d903d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Sun, 14 Aug 2016 02:12:49 -0500 Subject: [PATCH] Chats can be sent by pressing enter in the text box --- changelog.md | 3 +++ src/controller/buffers.py | 11 ++++++++++- src/controller/longpoolthread.py | 5 +++++ src/wxUI/tabs/home.py | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index cb82303..1474162 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,9 @@ ## Changes in the current build () * Added a new menu in the menu bar that allows you to control the audio playback. For some actions (like play, next and back), if you are not focusing an audio buffer, the program will take the song from the "my audios" buffer. +* Added two more buffers: "Followers" and "I follow", located in the people buffer, under "friendship requests". +* Added an experimental photo viewer. Will show options for see the next and previous photo if the current post contains multiple images. +* Improved chats, now they should be more stable. ## Changes in build 2016.07.08 (08/07/2016) diff --git a/src/controller/buffers.py b/src/controller/buffers.py index cab1e7b..2fb74f8 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -490,7 +490,16 @@ class chatBuffer(baseBuffer): def send_chat_to_user(self, *args, **kwargs): text = self.tab.text.GetValue() if text == "": return - response = self.session.vk.client.messages.send(user_id=self.kwargs["user_id"], message=text) + call_threaded(self._send_message, text=text) + + def _send_message(self, text): + try: + response = self.session.vk.client.messages.send(user_id=self.kwargs["user_id"], message=text) + except VkAPIMethodError as ex: + if ex.code == 9: + output.speak(_(u"You have been sending a message that is already sent. Try to update the buffer if you can't see the new message in the history.")) + finally: + self.tab.text.SetValue("") def __init__(self, *args, **kwargs): super(chatBuffer, self).__init__(*args, **kwargs) diff --git a/src/controller/longpoolthread.py b/src/controller/longpoolthread.py index 3a8d8a2..bce0cd4 100644 --- a/src/controller/longpoolthread.py +++ b/src/controller/longpoolthread.py @@ -2,16 +2,21 @@ import threading from vk import longpool from pubsub import pub +from logging import getLogger +log = getLogger("controller.longpolThread") class worker(threading.Thread): def __init__(self, session): super(worker, self).__init__() + log.debug("Instanciating longPoll server") self.session = session self.l = longpool.LongPoll(self.session.vk.client) def run(self): while self.session.is_logged == True: + log.debug("Calling to check...") p = self.l.check() +# log.debug("check has returned " + p) for i in p: # print i.message_id, i.flags, i.from_id, i.user_id, i.mask, i.byself, i.message_flags # if i.flags == 4 or i.flags == 51 or i.flags == 49: diff --git a/src/wxUI/tabs/home.py b/src/wxUI/tabs/home.py index 95bdd75..2b64c0a 100644 --- a/src/wxUI/tabs/home.py +++ b/src/wxUI/tabs/home.py @@ -138,6 +138,7 @@ class chatTab(wx.Panel): sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.create_controls()) self.send = wx.Button(self, -1, _(u"Send")) + self.send.SetDefault() sizer.Add(self.send, 0, wx.ALL, 5) self.SetSizer(sizer)