From 9bc7fcccb39a2ff0fc8f785de5f825e690bfbb08 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Fri, 8 Nov 2019 15:49:49 +0100 Subject: [PATCH] new: the grid plugin now triggers an on_unread_inbox event that other plugins can intercept (see led plugin) --- pwnagotchi/defaults.yml | 1 + pwnagotchi/plugins/default/grid.py | 1 + pwnagotchi/plugins/default/led.py | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/pwnagotchi/defaults.yml b/pwnagotchi/defaults.yml index 2e42fc6..0acce4d 100644 --- a/pwnagotchi/defaults.yml +++ b/pwnagotchi/defaults.yml @@ -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' diff --git a/pwnagotchi/plugins/default/grid.py b/pwnagotchi/plugins/default/grid.py index 5860939..a727e24 100644 --- a/pwnagotchi/plugins/default/grid.py +++ b/pwnagotchi/plugins/default/grid.py @@ -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) diff --git a/pwnagotchi/plugins/default/led.py b/pwnagotchi/plugins/default/led.py index 02d8e30..49d315c 100644 --- a/pwnagotchi/plugins/default/led.py +++ b/pwnagotchi/plugins/default/led.py @@ -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')