From 3f82e07b4549c21bf15755af8a304034f379035a Mon Sep 17 00:00:00 2001 From: Jan Philipp Timme Date: Thu, 15 May 2014 18:09:14 +0200 Subject: [PATCH] [TASK] Add messages to queue only once. --- twisted/plugins/monitorbot_plugin.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/twisted/plugins/monitorbot_plugin.py b/twisted/plugins/monitorbot_plugin.py index d7bc955..fd68f2b 100644 --- a/twisted/plugins/monitorbot_plugin.py +++ b/twisted/plugins/monitorbot_plugin.py @@ -65,7 +65,9 @@ class MonitorBotService(Service): path_segments = filepath.segmentsFrom(self._watch_path) new_path = '/'.join(path_segments) msg = "ftp> /%s (%s)" % (new_path, ', '.join(humanReadableMask(mask))) - self._messages.append(msg) + if msg not in self._messages: + self._messages.append(msg) + self._callid = reactor.callLater(5.0, sendQueuedMessages) def sendQueuedMessages(): @@ -75,6 +77,7 @@ class MonitorBotService(Service): else: for msg in self._messages: self._bot.msg(self._channel, msg) + self._messages = [] watchMask = ( inotify.IN_MODIFY | inotify.IN_CREATE