|
9 | 9 | print("You must provide exactly one of these tags as an argument upon execution: --relay --break-heart --custom") |
10 | 10 | exit(0) |
11 | 11 | else: |
| 12 | + dialog = Dialog('print') |
12 | 13 |
|
13 | 14 | #1) Connect to Alice and get her key |
| 15 | + player1 = os.path.basename(sys.argv[0]).split('.', 1)[0] |
| 16 | + socket1, aes1 = setup(player1, BUFFER_DIR, BUFFER_FILE_NAME) |
14 | 17 |
|
15 | 18 | #2) Connect to Bob and get his key |
| 19 | + player2 = os.path.basename(sys.argv[0]).split('.', 1)[0] |
| 20 | + socket2, aes2 = setup(player2, BUFFER_DIR, BUFFER_FILE_NAME) |
16 | 21 |
|
17 | 22 | #3) Communication cases: |
18 | 23 | #3.1) Relay - decrypt, re-encrypt and send each message using respective keys |
19 | 24 | #3.2) Break Heart - encrypt and send messages (-> Alice: "I hate you!", -> Bob "You broke my heart...") |
20 | 25 | #3.3) Custom - prompt user to add message upon message receival from Bob/Alice, encrypt and send it |
21 | 26 |
|
22 | | - dialog = Dialog('print') |
23 | | - player = os.path.basename(sys.argv[0]).split('.', 1)[0] |
24 | | - socket, aes = setup(player, BUFFER_DIR, BUFFER_FILE_NAME) |
25 | | - |
26 | | - if CUSTOM_CHAT: |
| 27 | + if args[1] == "--custom": |
27 | 28 | dialog.prompt('Please input message...') |
28 | 29 | to_send = input() |
29 | | - else: |
| 30 | + elif args[1] == "--relay": |
30 | 31 | to_send = NICE_MSG[player] |
| 32 | + elif args[1] == "--break-heart": |
| 33 | + to_send = BAD_MSG[player] |
| 34 | + else: |
| 35 | + print("ERROR: you have an entered an invalid argument") |
| 36 | + |
31 | 37 | encrypt_and_send(to_send, aes, socket) |
32 | 38 | dialog.info('Message sent! Waiting for reply...') |
33 | 39 | received = receive_and_decrypt(aes, socket) |
|
0 commit comments