From d94b133e6384df852906da2723b02f12e5433932 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Mon, 6 Aug 2018 11:31:52 -0500 Subject: [PATCH] Update interval in buffers is configurable from global settings. Closes #223 --- doc/changelog.md | 4 ++++ src/Conf.defaults | 1 - src/app-configuration.defaults | 1 + src/controller/mainController.py | 3 ++- src/controller/settings.py | 4 ++++ src/wxUI/dialogs/configuration.py | 13 ++++++++++--- 6 files changed, 21 insertions(+), 5 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 5cfa52b7..44dd91f7 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -4,6 +4,10 @@ * Added an option in the global settings dialog to disable the Streaming features of TWBlue. TWBlue will remove all Streaming features after August 16, so this option will give people an idea about how it will be. ([#219](https://github.com/manuelcortez/TWBlue/issues/219)) * Due to Twitter API changes, Switched authorisation method to Pin-code based authorisation. When you add new accounts to TWBlue, you will be required to paste a code displayed in the Twitter website in order to grant access to TWBlue. ([#216](https://github.com/manuelcortez/TWBlue/issues/216)) +* In order to comply with latest Twitter changes, TWBlue has switched to the new method used to send and receive direct messages, according to issue [#215.](https://github.com/manuelcortez/twblue/issues/215) + * The sent direct messages buffer has been removed. All direct messages will be placed in one buffer only. + * The new method does not allow direct messages to be processed in real time. Direct messages will be updated periodically. +* After august 16 or when streaming is disabled, the events buffer will no longer be created in TWBlue. * Added a new tab called feedback, in the account settings dialog. This tab allows you to control wether automatic speech or Braille feedbak in certain events (mentions and direct messages received) is enabled. Take into account that this option will take preference over automatic reading of buffers and any kind of automatic output. ([#203](https://github.com/manuelcortez/TWBlue/issues/203)) * The spell checking dialog now has access keys defined for the most important actions. ([#211](https://github.com/manuelcortez/TWBlue/issues/211)) * TWBlue now Uses WXPython 4.0.1. This will allow us to migrate all important components to Python 3 in the future. ([#207](https://github.com/manuelcortez/TWBlue/issues/207)) diff --git a/src/Conf.defaults b/src/Conf.defaults index 55d60688..1e7c3786 100644 --- a/src/Conf.defaults +++ b/src/Conf.defaults @@ -9,7 +9,6 @@ relative_times = boolean(default=True) max_api_calls = integer(default=1) max_tweets_per_call = integer(default=100) reverse_timelines = boolean(default=False) -time_to_check_streams = integer(default=30) announce_stream_status = boolean(default=True) retweet_mode = string(default="ask") persist_size = integer(default=0) diff --git a/src/app-configuration.defaults b/src/app-configuration.defaults index 7cad4268..1cee731d 100644 --- a/src/app-configuration.defaults +++ b/src/app-configuration.defaults @@ -5,6 +5,7 @@ ignored_sessions = list(default=list()) [app-settings] language = string(default="system") +update_period = integer(default=2) hide_gui = boolean(default=False) voice_enabled = boolean(default=False) ask_at_exit = boolean(default=True) diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 64054a05..3e3807f6 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -265,7 +265,8 @@ class Controller(object): self.checker_function.start() self.save_db = RepeatingTimer(300, self.save_data_in_db) self.save_db.start() - self.update_buffers_function = RepeatingTimer(60, self.update_buffers) + log.debug("Setting updates to buffers every %d seconds..." % (60*config.app["app-settings"]["update_period"],)) + self.update_buffers_function = RepeatingTimer(60*config.app["app-settings"]["update_period"], self.update_buffers) self.update_buffers_function.start() def start(self): diff --git a/src/controller/settings.py b/src/controller/settings.py index 22254ab5..480e3567 100644 --- a/src/controller/settings.py +++ b/src/controller/settings.py @@ -68,6 +68,7 @@ class globalSettingsController(object): self.dialog.set_value("general", "use_invisible_shorcuts", config.app["app-settings"]["use_invisible_keyboard_shorcuts"]) self.dialog.set_value("general", "disable_sapi5", config.app["app-settings"]["voice_enabled"]) self.dialog.set_value("general", "hide_gui", config.app["app-settings"]["hide_gui"]) + self.dialog.set_value("general", "update_period", config.app["app-settings"]["update_period"]) self.dialog.set_value("general", "check_for_updates", config.app["app-settings"]["check_for_updates"]) self.dialog.set_value("general", "remember_mention_and_longtweet", config.app["app-settings"]["remember_mention_and_longtweet"]) proxyTypes=config.proxyTypes @@ -103,6 +104,9 @@ class globalSettingsController(object): if config.app["app-settings"]["no_streaming"] != self.dialog.get_value("general", "no_streaming"): config.app["app-settings"]["no_streaming"] = self.dialog.get_value("general", "no_streaming") self.needs_restart = True + if config.app["app-settings"]["update_period"] != self.dialog.get_value("general", "update_period"): + config.app["app-settings"]["update_period"] = self.dialog.get_value("general", "update_period") + self.needs_restart = True config.app["app-settings"]["voice_enabled"] = self.dialog.get_value("general", "disable_sapi5") config.app["app-settings"]["hide_gui"] = self.dialog.get_value("general", "hide_gui") config.app["app-settings"]["ask_at_exit"] = self.dialog.get_value("general", "ask_at_exit") diff --git a/src/wxUI/dialogs/configuration.py b/src/wxUI/dialogs/configuration.py index 3a8ebb07..2dfba02a 100644 --- a/src/wxUI/dialogs/configuration.py +++ b/src/wxUI/dialogs/configuration.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- -import baseDialog -import wx import logging as original_logger +import wx import application -from multiplatform_widgets import widgets import output import config +import baseDialog +from multiplatform_widgets import widgets class general(wx.Panel, baseDialog.BaseWXDialog): def __init__(self, parent, languages,keymaps): @@ -24,6 +24,13 @@ class general(wx.Panel, baseDialog.BaseWXDialog): sizer.Add(self.ask_at_exit, 0, wx.ALL, 5) self.no_streaming = wx.CheckBox(self, -1, _(U"Disable Streaming functions")) sizer.Add(self.no_streaming, 0, wx.ALL, 5) + updatePeriodBox = wx.BoxSizer(wx.HORIZONTAL) + updatePeriodBox.Add(wx.StaticText(self, -1, _(u"Buffer update interval, in minutes")), 0, wx.ALL, 5) + self.update_period = wx.SpinCtrl(self, wx.NewId()) + self.update_period.SetRange(1, 30) + self.update_period.SetSize(self.update_period.GetBestSize()) + updatePeriodBox.Add(self.update_period, 0, wx.ALL, 5) + sizer.Add(updatePeriodBox, 0, wx.ALL, 5) self.play_ready_sound = wx.CheckBox(self, -1, _(U"Play a sound when {0} launches").format(application.name,)) sizer.Add(self.play_ready_sound, 0, wx.ALL, 5) self.speak_ready_msg = wx.CheckBox(self, -1, _(U"Speak a message when {0} launches").format(application.name,))