diff --git a/java/FuckingCoffee.java b/java/FuckingCoffee.java index 483e124e..417456e3 100644 --- a/java/FuckingCoffee.java +++ b/java/FuckingCoffee.java @@ -1,7 +1,7 @@ import java.net.*; import java.io.*; - -public class FuckingCoffee{ + +public class FuckingCoffee{ // creating a class private static final String MY_USERNAME = "my_username"; private static final String PASSWORD_PROMPT = "Password: "; @@ -9,17 +9,21 @@ public class FuckingCoffee{ private static final String COFFEE_MACHINE_IP = "10.10.42.42"; private static int DELAY_BEFORE_BREW = 17; private static int DELAY = 24; - - public static void main(String[] args)throws Exception{ - for(int i = 1; i< args.length ; i++){ + + public static void main(String[] args)throws Exception + { + for(int i = 1; i< args.length; i++) + { if(!args[i].contains(MY_USERNAME)){ return; } } + Socket telnet = new Socket(COFFEE_MACHINE_IP, 23); PrintWriter out = new PrintWriter(telnet.getOutputStream(), true); BufferedReader in = new BufferedReader(new InputStreamReader(telnet.getInputStream())); Thread.sleep(DELAY_BEFORE_BREW*1000); + if(!in.readLine().equals(PASSWORD_PROMPT)){ return ; } diff --git a/python3/fucking_coffee.py b/python3/fucking_coffee.py index 0268b79a..9e0bde24 100755 --- a/python3/fucking_coffee.py +++ b/python3/fucking_coffee.py @@ -13,22 +13,22 @@ def main(): # Exit early if no sessions with my_username are found. - if not any(s.startswith(b'my_username ') for s in sh('who').split(b'\n')): + if not any(s.startswith(b'my_username') for s in sh('who').split(b'\n')): return - time.sleep(17) + time.sleep(17) # sleep system for 17 seconds - conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR) + conn = telnetlib.Telnet(host=COFFEE_MACHINE_ADDR) #creating the connection conn.open() conn.expect([COFFEE_MACHINE_PROM]) conn.write(COFFEE_MACHINE_PASS) conn.write('sys brew') - time.sleep(64) + time.sleep(64) # sleep system for 16 seconds conn.write('sys pour') - conn.close() + conn.close() # closing the connection -if __name__ == '__main__': +if __name__ == '__main__': #check__name__ is equal to __main__ or not. main()