mirror of
https://github.com/zoriya/AnonymousGoose.git
synced 2026-06-03 22:30:56 +00:00
Allowing x commands to be disabled
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import time
|
||||
import pyxhook
|
||||
import sys
|
||||
|
||||
from term_utils import Term
|
||||
from command_helper import CommandHelper
|
||||
@@ -12,6 +13,7 @@ class AnonymousGoose:
|
||||
self.should_exit = False
|
||||
self.stopped = False
|
||||
self.tricks = []
|
||||
self.log = []
|
||||
self.keyboard_listener = pyxhook.HookManager()
|
||||
self.keyboard_listener.KeyUp = self.key_pressed
|
||||
self.keyboard_listener.HookKeyboard()
|
||||
@@ -24,7 +26,7 @@ class AnonymousGoose:
|
||||
for trick in self.tricks:
|
||||
trick.revert()
|
||||
|
||||
def run(self):
|
||||
def run(self, disable_x):
|
||||
next_trick_time = 5
|
||||
while not self.should_exit:
|
||||
try:
|
||||
@@ -33,7 +35,7 @@ class AnonymousGoose:
|
||||
time.sleep(1)
|
||||
next_trick_time -= 1
|
||||
if next_trick_time <= 0:
|
||||
trick = Trick.get_random_trick()
|
||||
trick = Trick.get_random_trick(not disable_x)
|
||||
next_trick_time = trick.delay
|
||||
trick.run()
|
||||
if trick.is_reversible:
|
||||
@@ -44,7 +46,10 @@ class AnonymousGoose:
|
||||
def key_pressed(self, key):
|
||||
if key.Ascii == 27:
|
||||
self.should_exit = True
|
||||
|
||||
else:
|
||||
self.log.append(key.key_pressed)
|
||||
print(self.log)
|
||||
|
||||
def stop(self):
|
||||
if self.stopped:
|
||||
return
|
||||
@@ -53,6 +58,8 @@ class AnonymousGoose:
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
disable_x = len(sys.argv) == 2 and sys.argv[1] == '-x'
|
||||
|
||||
goose = AnonymousGoose()
|
||||
goose.run()
|
||||
goose.run(disable_x)
|
||||
goose.stop()
|
||||
|
||||
@@ -28,7 +28,7 @@ class Trick(ABC):
|
||||
raise NotImplementedError
|
||||
|
||||
@staticmethod
|
||||
def get_random_trick():
|
||||
def get_random_trick(keep_x):
|
||||
from tricks.laughing_goose import LaughingGooseTrick
|
||||
from tricks.glorify_goose import GlorifyGooseTrick
|
||||
from tricks.anim_ascii import AnimAsciiTrick
|
||||
@@ -37,9 +37,13 @@ class Trick(ABC):
|
||||
tricks = [
|
||||
LaughingGooseTrick,
|
||||
GlorifyGooseTrick,
|
||||
#AnimAsciiTrick,
|
||||
#AnimAsciiTrick
|
||||
]
|
||||
x_tricks = [
|
||||
ReflectionTrick,
|
||||
RotationTrick
|
||||
]
|
||||
|
||||
|
||||
if keep_x:
|
||||
return random.choice(tricks + x_tricks)()
|
||||
return random.choice(tricks)()
|
||||
|
||||
Reference in New Issue
Block a user