From 31a89cbe4b91459fc17ab7750c54d629d2cfd598 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Fri, 1 Nov 2019 15:53:31 +0100 Subject: [PATCH] new: added new angry state (closes #486) --- pwnagotchi/automata.py | 27 ++++++++++++++++++++++----- pwnagotchi/defaults.yml | 1 + pwnagotchi/ui/faces.py | 1 + pwnagotchi/ui/view.py | 5 +++++ pwnagotchi/voice.py | 7 +++++++ 5 files changed, 36 insertions(+), 5 deletions(-) diff --git a/pwnagotchi/automata.py b/pwnagotchi/automata.py index ee703dc..d4e008f 100644 --- a/pwnagotchi/automata.py +++ b/pwnagotchi/automata.py @@ -75,6 +75,15 @@ class Automata(object): logging.info("unit is grateful instead of sad") self.set_grateful() + def set_angry(self, factor): + if not self._has_support_network_for(factor): + logging.warning("%d epochs with no activity -> angry" % self._epoch.inactive_for) + self._view.on_angry() + plugins.on('angry', self) + else: + logging.info("unit is grateful instead of angry") + self.set_grateful() + def set_excited(self): logging.warning("%d epochs with activity -> excited" % self._epoch.active_for) self._view.on_excited() @@ -103,13 +112,21 @@ class Automata(object): self._epoch.next() - # after X misses during an epoch, set the status to lonely + # after X misses during an epoch, set the status to lonely or angry if was_stale: - logging.warning("agent missed %d interactions -> lonely" % did_miss) - self.set_lonely() - # after X times being bored, the status is set to sad + factor = did_miss / self._config['personality']['max_misses_for_recon'] + if factor >= 2.0: + self.set_angry(factor) + else: + logging.warning("agent missed %d interactions -> lonely" % did_miss) + self.set_lonely() + # after X times being bored, the status is set to sad or angry elif self._epoch.inactive_for >= self._config['personality']['sad_num_epochs']: - self.set_sad() + factor = self._epoch.inactive_for / self._config['personality']['sad_num_epochs'] + if factor >= 2.0: + self.set_angry(factor) + else: + self.set_sad() # after X times being inactive, the status is set to bored elif self._epoch.inactive_for >= self._config['personality']['bored_num_epochs']: self.set_bored() diff --git a/pwnagotchi/defaults.yml b/pwnagotchi/defaults.yml index bb78d8a..4624e68 100644 --- a/pwnagotchi/defaults.yml +++ b/pwnagotchi/defaults.yml @@ -199,6 +199,7 @@ ui: smart: '(✜‿‿✜)' lonely: '(ب__ب)' sad: '(╥☁╥ )' + angry: "(-_-')" friend: '(♥‿‿♥)' broken: '(☓‿‿☓)' debug: '(#__#)' diff --git a/pwnagotchi/ui/faces.py b/pwnagotchi/ui/faces.py index f94eb0b..c47a5e9 100644 --- a/pwnagotchi/ui/faces.py +++ b/pwnagotchi/ui/faces.py @@ -16,6 +16,7 @@ DEMOTIVATED = '(≖__≖)' SMART = '(✜‿‿✜)' LONELY = '(ب__ب)' SAD = '(╥☁╥ )' +ANGRY = "(-_-')" FRIEND = '(♥‿‿♥)' BROKEN = '(☓‿‿☓)' DEBUG = '(#__#)' diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 3a4358e..71cd46b 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -284,6 +284,11 @@ class View(object): self.set('status', self._voice.on_sad()) self.update() + def on_angry(self): + self.set('face', faces.ANGRY) + self.set('status', self._voice.on_angry()) + self.update() + def on_motivated(self, reward): self.set('face', faces.MOTIVATED) self.set('status', self._voice.on_motivated(reward)) diff --git a/pwnagotchi/voice.py b/pwnagotchi/voice.py index 0d06b6c..b1abd8a 100644 --- a/pwnagotchi/voice.py +++ b/pwnagotchi/voice.py @@ -67,6 +67,13 @@ class Voice: self._('I\'m sad'), '...']) + def on_angry(self): + # passive aggressive or not? :D + return random.choice([ + '...', + self._('Leave me alone ...'), + self._('I\'m mad at you!')]) + def on_excited(self): return random.choice([ self._('I\'m living the life!'),