new: the grid plugin now triggers an on_unread_inbox event that other plugins can intercept (see led plugin)

This commit is contained in:
Simone Margaritelli 2019-11-08 15:49:49 +01:00
parent bd61196c3c
commit 9bc7fcccb3
3 changed files with 6 additions and 0 deletions

View File

@ -89,6 +89,7 @@ main:
loaded: 'oo oo oo oo oo oo oo'
updating: 'oo oo oo oo oo oo oo'
# internet_available: 'oo oo oo oo oo oo oo'
unread_inbox: 'oo oo oo oo oo oo oo'
ready: 'oo oo oo oo oo oo oo'
ai_ready: 'oo oo oo oo oo oo oo'
ai_training_start: 'oo oo oo oo oo oo oo'

View File

@ -77,6 +77,7 @@ class Grid(plugins.Plugin):
self.unread_messages = len([m for m in messages if m['seen_at'] is None])
if self.unread_messages:
plugins.on('unread_inbox', self.unread_messages)
logging.debug("[grid] unread:%d total:%d" % (self.unread_messages, self.total_messages))
agent.view().on_unread_messages(self.unread_messages, self.total_messages)

View File

@ -73,6 +73,10 @@ class Led(plugins.Plugin):
def on_updating(self):
self._on_event('updating')
# called when there's one or more unread pwnmail messages
def on_unread_inbox(self, num_unread):
self._on_event('unread_inbox')
# called when there's internet connectivity
def on_internet_available(self, agent):
self._on_event('internet_available')