Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions java/FuckingCoffee.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
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: ";
private static final String PASSWORD = "1234";
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 ;
}
Expand Down
12 changes: 6 additions & 6 deletions python3/fucking_coffee.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()