[TASK] Add messages to queue only once.

This commit is contained in:
Jan Philipp Timme 2014-05-15 18:09:14 +02:00
parent c696b62c9b
commit 3f82e07b45
1 changed files with 4 additions and 1 deletions

View File

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