From 97cccf5a1d2c75837ebf171e6d2426fc3a71e005 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Thu, 24 Oct 2019 13:42:43 +0200 Subject: [PATCH] new: face expression while looking around will change dependig if the unit is with friends or alone --- pwnagotchi/agent.py | 1 + pwnagotchi/automata.py | 3 +++ pwnagotchi/defaults.yml | 2 ++ pwnagotchi/ui/faces.py | 2 ++ pwnagotchi/ui/view.py | 9 +++++++-- 5 files changed, 15 insertions(+), 2 deletions(-) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index 53aa803..5b7c6ec 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -33,6 +33,7 @@ class Agent(Client, Automata, AsyncAdvertiser, AsyncTrainer): self._current_channel = 0 self._supported_channels = utils.iface_channels(config['main']['iface']) self._view = view + self._view.set_agent(self) self._access_points = [] self._last_pwnd = None self._history = {} diff --git a/pwnagotchi/automata.py b/pwnagotchi/automata.py index b500fe3..ee703dc 100644 --- a/pwnagotchi/automata.py +++ b/pwnagotchi/automata.py @@ -32,6 +32,9 @@ class Automata(object): def set_ready(self): plugins.on('ready', self) + def in_good_mood(self): + return self._has_support_network_for(1.0) + def _has_support_network_for(self, factor): bond_factor = self._config['personality']['bond_encounters_factor'] total_encounters = sum(peer.encounters for _, peer in self._peers.items()) diff --git a/pwnagotchi/defaults.yml b/pwnagotchi/defaults.yml index a22874c..8929538 100644 --- a/pwnagotchi/defaults.yml +++ b/pwnagotchi/defaults.yml @@ -171,6 +171,8 @@ ui: faces: look_r: '( ⚆_⚆)' look_l: '(☉_☉ )' + look_r_happy: '( ◕‿◕)' + look_l_happy: '(◕‿◕ )' sleep: '(⇀‿‿↼)' sleep2: '(≖‿‿≖)' awake: '(◕‿‿◕)' diff --git a/pwnagotchi/ui/faces.py b/pwnagotchi/ui/faces.py index d90b549..f94eb0b 100644 --- a/pwnagotchi/ui/faces.py +++ b/pwnagotchi/ui/faces.py @@ -1,5 +1,7 @@ LOOK_R = '( ⚆_⚆)' LOOK_L = '(☉_☉ )' +LOOK_R_HAPPY = '( ◕‿◕)' +LOOK_L_HAPPY = '(◕‿◕ )' SLEEP = '(⇀‿‿↼)' SLEEP2 = '(≖‿‿≖)' AWAKE = '(◕‿‿◕)' diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 11047f3..e7fb80c 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -26,6 +26,7 @@ class View(object): # setup faces from the configuration in case the user customized them faces.load_from_config(config['ui']['faces']) + self._agent = None self._render_cbs = [] self._config = config self._canvas = None @@ -89,6 +90,9 @@ class View(object): ROOT = self + def set_agent(self, agent): + self._agent = agent + def has_element(self, key): self._state.has_element(key) @@ -248,10 +252,11 @@ class View(object): self.set('status', self._voice.on_awakening()) else: self.set('status', self._voice.on_waiting(int(secs))) + good_mood = self._agent.in_good_mood() if step % 2 == 0: - self.set('face', faces.LOOK_R) + self.set('face', faces.LOOK_R_HAPPY if good_mood else faces.LOOK_R) else: - self.set('face', faces.LOOK_L) + self.set('face', faces.LOOK_L_HAPPY if good_mood else faces.LOOK_L) time.sleep(part) secs -= part