-
-
Save nickludlam/7602d1e31a066108447c09f717f32f3e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require"io/console" | |
class String | |
def black; "\e[30m#{self}\e[0m" end | |
def red; "\e[31m#{self}\e[0m" end | |
def green; "\e[32m#{self}\e[0m" end | |
def brown; "\e[33m#{self}\e[0m" end | |
def blue; "\e[34m#{self}\e[0m" end | |
def magenta; "\e[35m#{self}\e[0m" end | |
def cyan; "\e[36m#{self}\e[0m" end | |
def gray; "\e[37m#{self}\e[0m" end | |
def bg_black; "\e[40m#{self}\e[0m" end | |
def bg_red; "\e[41m#{self}\e[0m" end | |
def bg_green; "\e[42m#{self}\e[0m" end | |
def bg_brown; "\e[43m#{self}\e[0m" end | |
def bg_blue; "\e[44m#{self}\e[0m" end | |
def bg_magenta; "\e[45m#{self}\e[0m" end | |
def bg_cyan; "\e[46m#{self}\e[0m" end | |
def bg_gray; "\e[47m#{self}\e[0m" end | |
def bold; "\e[1m#{self}\e[22m" end | |
def italic; "\e[3m#{self}\e[23m" end | |
def underline; "\e[4m#{self}\e[24m" end | |
def blink; "\e[5m#{self}\e[25m" end | |
def reverse_color; "\e[7m#{self}\e[27m" end | |
end | |
print "Regstering...".red | |
$chars_per_keystroke = 1 | |
$fast_mode = false | |
$chars_to_consume = 0 | |
def echo_hack() | |
`stty -echo` | |
File.open(ARGV[0]).each do |line| | |
$chars_to_consume = 0 | |
line.sub!("@RED@", "\e[31m") | |
line.sub!("@GREEN@", "\e[32m") | |
line.sub!("@BLUE@", "\e[34m") | |
line.sub!("@RESET@", "\e[0m") | |
if line =~ /knock, knock, Billie./ | |
$fast_mode = true | |
elsif line =~ /334 payloads - 35 encoders/ | |
$fast_mode = false | |
end | |
$char_to_wait_at = nil | |
if line =~ /@WAIT@/ | |
$char_to_wait_at = line.index("@WAIT@") | |
# print("{FOUND WAIT #{char_to_wait_at}}") | |
line.sub!("@WAIT@", "") | |
end | |
if $fast_mode | |
print(line) | |
sleep(0.02) | |
else | |
wait_for_input_mode = false | |
char_index = 0 | |
line.split('').each do |c| | |
if $char_to_wait_at != nil && char_index == $char_to_wait_at | |
# print("{WAIT TRUE}") | |
wait_for_input_mode = true | |
end | |
if !wait_for_input_mode | |
print(c) | |
sleep(0.002) | |
char_index += 1 | |
else | |
wait_for_input_mode = false if c == "\n" | |
if ($chars_to_consume < 0) | |
print(c) | |
$chars_to_consume -= 1 | |
next | |
else | |
typed_char = STDIN.raw &:getc | |
if typed_char == 'q' | |
raise "OMG" | |
end | |
print(c) | |
$chars_to_consume = $chars_per_keystroke | |
end | |
end | |
end | |
end | |
end | |
sleep(3) | |
`stty echo` | |
end | |
begin | |
while true | |
echo_hack() | |
puts "\e[H\e[2J" | |
end | |
rescue | |
puts("Finishing".red) | |
`stty echo` | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment