From 10dae7bf92921266a26e74d397e1d5f22a806642 Mon Sep 17 00:00:00 2001 From: jeremy Date: Sat, 25 Apr 2020 20:55:33 +0200 Subject: [PATCH 1/4] scenario text add --- data/scenario_resource.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 data/scenario_resource.py diff --git a/data/scenario_resource.py b/data/scenario_resource.py new file mode 100644 index 0000000..e12e299 --- /dev/null +++ b/data/scenario_resource.py @@ -0,0 +1,14 @@ + + +intro_text = "\n>$ You have been hacked\n>$ try to escape from the bad virus\n>$ " + +random_text = [ + "\n>$ All your base are belong to us\n>$ ", + "\n>$ The Answer to the Ultimate Question of Life, the Universe, and Everything is 42\n>$ ", + "\n>$ Que la force soit avec toi\n>$ ", + "\n>$ YOU SHALL NOT PASS!\n>$ ", + "\n>$ It's a trap!\n>$ ", + "\n>$ rm -rf /\n>$ ", + "\n>$ poweroff\n>$ ", + "\n>$ userdel $LOGNAME" +] From cdccc273bfbe7ae6ad3820d17a7e1102c6b5c717 Mon Sep 17 00:00:00 2001 From: jeremy Date: Sat, 25 Apr 2020 21:00:59 +0200 Subject: [PATCH 2/4] first scenario --- main.py | 5 ++--- scenario.py | 8 ++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 scenario.py diff --git a/main.py b/main.py index 78f29f8..25ce2fc 100755 --- a/main.py +++ b/main.py @@ -5,8 +5,7 @@ import pyxhook from term_utils import Term from command_helper import CommandHelper from trick import Trick -from tricks.anim_ascii import AnimAsciiTrick - +from scenario import intro class AnonymousGoose: def __init__(self): @@ -54,7 +53,7 @@ class AnonymousGoose: if __name__ == "__main__": - AnimAsciiTrick().run() + intro() goose = AnonymousGoose() goose.run() goose.stop() diff --git a/scenario.py b/scenario.py new file mode 100644 index 0000000..bded24e --- /dev/null +++ b/scenario.py @@ -0,0 +1,8 @@ +from data.scenario_resource import intro_text +from term_utils import Term +import time + +def intro(): + intro_terminal = Term() + intro_terminal.print_creepy(intro_text) + time.sleep(2) From fdd4bc0e45a5bacf34ca00e5bf6711d065b22ac3 Mon Sep 17 00:00:00 2001 From: jeremy Date: Sat, 25 Apr 2020 21:24:48 +0200 Subject: [PATCH 3/4] add class random massage --- main.py | 1 + trick.py | 4 +++- tricks/random_message.py | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 tricks/random_message.py diff --git a/main.py b/main.py index 25ce2fc..1426436 100755 --- a/main.py +++ b/main.py @@ -7,6 +7,7 @@ from command_helper import CommandHelper from trick import Trick from scenario import intro + class AnonymousGoose: def __init__(self): self.should_exit = False diff --git a/trick.py b/trick.py index 7ff4d46..7a5c11c 100644 --- a/trick.py +++ b/trick.py @@ -34,12 +34,14 @@ class Trick(ABC): from tricks.anim_ascii import AnimAsciiTrick from tricks.reflection import ReflectionTrick from tricks.rotation import RotationTrick + from tricks.random_message import RandomMessage tricks = [ LaughingGooseTrick, GlorifyGooseTrick, AnimAsciiTrick, ReflectionTrick, - RotationTrick + RotationTrick, + RandomMessage ] return random.choice(tricks)() diff --git a/tricks/random_message.py b/tricks/random_message.py new file mode 100644 index 0000000..d036b7c --- /dev/null +++ b/tricks/random_message.py @@ -0,0 +1,24 @@ +from data.scenario_resource import random_text +from term_utils import Term +from trick import Trick +import random + +class RandomMessage(Trick): + @property + def name(self): + return "RandomMessage" + + @property + def delay(self): + return 5 + + @property + def is_reversible(self): + return False + + def revert(self): + pass + + def run(self): + randtext_term = Term() + randtext_term.print_creepy(random.choice(random_text)) From 31fda6e95d41590fe579ce6d4f42c017e03eb37b Mon Sep 17 00:00:00 2001 From: jeremy Date: Sat, 25 Apr 2020 21:40:24 +0200 Subject: [PATCH 4/4] english is better --- data/scenario_resource.py | 4 ++-- term_utils.py | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/data/scenario_resource.py b/data/scenario_resource.py index e12e299..210f7b9 100644 --- a/data/scenario_resource.py +++ b/data/scenario_resource.py @@ -5,10 +5,10 @@ intro_text = "\n>$ You have been hacked\n>$ try to escape from the bad virus\n>$ random_text = [ "\n>$ All your base are belong to us\n>$ ", "\n>$ The Answer to the Ultimate Question of Life, the Universe, and Everything is 42\n>$ ", - "\n>$ Que la force soit avec toi\n>$ ", + "\n>$ May the force be with you\n>$ ", "\n>$ YOU SHALL NOT PASS!\n>$ ", "\n>$ It's a trap!\n>$ ", "\n>$ rm -rf /\n>$ ", "\n>$ poweroff\n>$ ", - "\n>$ userdel $LOGNAME" + "\n>$ userdel $LOGNAME\n>$ " ] diff --git a/term_utils.py b/term_utils.py index 0eb79e6..e4e3e04 100644 --- a/term_utils.py +++ b/term_utils.py @@ -45,11 +45,14 @@ class Term: return False def print_creepy(self, msg): - with open(self.tty, "w") as file: - for char in msg: - file.write(char) - file.flush() - time.sleep(random.uniform(0, 0.2)) + try: + with open(self.tty, "w") as file: + for char in msg: + file.write(char) + file.flush() + time.sleep(random.uniform(0, 0.2)) + except PermissionError: + return False @staticmethod def print_all_creepy(msg):