-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_message.py
57 lines (49 loc) · 2.3 KB
/
read_message.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from steganography.steganography import Steganography
from spy_details import *
from select_friend import select_a_friend
from datetime import datetime
import csv
from termcolor import colored
def read_message():
sender = select_a_friend()
output_path = raw_input("Enter the name of the file?")
secret_text = Steganography.decode(output_path)
print(secret_text)
words = secret_text.split()
for i in words:
if i == "SOS" or i == "sos" or i == "save" or i == "help" or i == "Emergency" or i == "danger":
# Maintain the average number of words spoken by a spy every time a message is received from a particular spy.
friends[sender].count += len(words)
# Emergency alert
print(colored("!", 'grey', 'on_yellow')),
print(colored("!", 'grey', 'on_yellow')),
print(colored("!", 'grey', 'on_yellow'))
# Help your friend by sending him a helping message
print ("Don't panic !!")
print ("I am coming to rescue.\n\n")
# Adding the chat with the sender
new_chat = ChatMessage(spy_n= spy.name, friend_n= sender, time= datetime.now().strftime("%d %B %Y"), message=secret_text)
friends[sender].chat.append(new_chat)
# When there was no case of emergency
else:
#Adding the chat with the sender
new_chat = ChatMessage(spy_n=spy.name, friend_n=sender, time=datetime.now().strftime("%d %B %Y"), message=secret_text)
friends[sender].chat.append(new_chat)
print("Your secret message has been saved!")
# Print the avg words spoken by your friend
print "Average words said by",
print(colored(friends[sender].name, 'red'))
print "is",
print(colored(friends[sender].count, 'red'))
#
#
# # Delete a spy from your list of spies if they are speaking too much
# if len(words) > 100:
# print(colored(friends[sender].name,'red'))
# print("Removed from friends list. What a chatter box! What a drag!!!")
# # Removes that chatterbox friend
# friends.remove(friends[sender])
# # When the image contains no secret message
#
#
# print("Nothing to decode from the image as it contains no secret message.")