Add Hacker easter egg
This commit is contained in:
parent
9daccaee06
commit
0c1505bf0b
4
main.py
4
main.py
@ -6,6 +6,7 @@ from modules.swap.SwapModule import SwapModule
|
||||
from modules.systemupdate.Systemupdate import Systemupdate
|
||||
from modules.vim.VimModule import VimModule
|
||||
from modules.teamspeak.Teamspeak import Teamspeak
|
||||
from modules.hacker.Hacker import Hacker
|
||||
|
||||
modules = {
|
||||
"helloworld": HelloWorld().run,
|
||||
@ -13,7 +14,8 @@ modules = {
|
||||
"swap": SwapModule().run,
|
||||
"update": Systemupdate().run,
|
||||
"vim": VimModule().run,
|
||||
"teamspeak": Teamspeak
|
||||
"teamspeak": Teamspeak,
|
||||
"hacker": Hacker
|
||||
}
|
||||
|
||||
fire.Fire(modules)
|
||||
|
29
modules/hacker/Hacker.py
Normal file
29
modules/hacker/Hacker.py
Normal file
@ -0,0 +1,29 @@
|
||||
import subprocess
|
||||
from os import path
|
||||
import os
|
||||
import random
|
||||
|
||||
|
||||
class Hacker:
|
||||
|
||||
def run_bash(self):
|
||||
try:
|
||||
subprocess.run("bash hacker.sh", shell=True, cwd=path.dirname(__file__))
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
def run_py(self):
|
||||
columns = int(os.popen('stty size', 'r').read().split()[1]) # length of current line
|
||||
try:
|
||||
while True:
|
||||
num_to_show = random.randint(0, 1)
|
||||
count = random.randint(3, columns // 20)
|
||||
hacker = " " * columns
|
||||
for i in range(count):
|
||||
pos = random.randint(0, columns)
|
||||
hacker = hacker[:pos] + str(num_to_show) + hacker[pos+1:]
|
||||
print("\033[92m" + hacker)
|
||||
except KeyboardInterrupt:
|
||||
print(columns)
|
||||
print("Finished")
|
||||
print("\033[0m")
|
29
modules/hacker/hacker.sh
Normal file
29
modules/hacker/hacker.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
width="$(tput cols)"
|
||||
width=$((width / 4))
|
||||
|
||||
printf "$width"
|
||||
|
||||
printf "\e[32m\n"
|
||||
while :
|
||||
do
|
||||
for ((i=1;i<=width;i++))
|
||||
do
|
||||
((r = $RANDOM % 2))
|
||||
if (($RANDOM % 5 == 1))
|
||||
then
|
||||
if (($RANDOM % 4 == 1))
|
||||
then
|
||||
v+="\e[1m $r "
|
||||
else
|
||||
v+="\e[2m $r "
|
||||
fi
|
||||
else
|
||||
v+=" "
|
||||
fi
|
||||
done
|
||||
printf "$v\n"
|
||||
v=""
|
||||
done
|
||||
;;
|
Loading…
Reference in New Issue
Block a user