Skip to content
Permalink
Browse files
FIX USER NOT ANSWERING FOR 3 TIMES, added change cursor on link
  • Loading branch information
mateussa committed Nov 22, 2017
1 parent 2a00d03 commit 159804397235ff1f70df225198397ae6cde6de54
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
@@ -8,24 +8,24 @@ def sendMessage(message, EOM = True): # Andre
''' Given a message input, and a False value, send the message and the ''' Given a message input, and a False value, send the message and the
client keeps wayting for another message ''' client keeps wayting for another message '''
resp = "" resp = ""
while (resp != "Received"): # If client doesn't receive message, send again while (resp != "Received"): # Check if the client received the message.
conn.send(str(message).encode()) conn.send(str(message).encode()) # Send message to client.
print("SERVER: {}".format(message)) print("SERVER: {}".format(message)) # Print the message sent.
resp = conn.recv(1024).decode() # Waits for client feedback resp = conn.recv(1024).decode() # Waits for client feedback
if (EOM): if (EOM): # If this is the last message to be sent
conn.send("EndOfMessage".encode()) conn.send("EndOfMessage".encode()) # Send a key word to the client to stop listening


def receiveMessage(): # Andre def receiveMessage(): # Andre
''' Receive a message from the client and check if received correctly, ''' Receive a message from the client and check if received correctly,
returns the message ''' returns the message '''
message = conn.recv(1024).decode() message = conn.recv(1024).decode()
if not message: # If message is None, try to receive again if not message: # If message is empty, try to receive again
sendMessage("Sorry, I couldn't get that, can you repeat?") sendMessage("Sorry, I couldn't get that, can you repeat?")
message = conn.recv(1024).decode() message = conn.recv(1024).decode()
if not message: # Couldn't receive message, exit if not message: # If message is empty again, send message and exit
sendMessage("Sorry, I not able to receive that, plese try again another day.") sendMessage("Sorry, I not able to receive that, plese try again another day.")
exit() exit()
print(message)
if (message != "END"): if (message != "END"):
print ("CLIENT: {}".format(message)) print ("CLIENT: {}".format(message))


@@ -56,15 +56,16 @@ def askSomething(answerType, sendMessages, noAnswers, defaultAnswer): # Andre
break break
break break


if (answer[1] == 2): # If the user asked a how or are question if (answer[1] == 2): # If the user asked a question
if (type(answer[0]) == str): if (type(answer[0]) == str):
sendMessage(answer[0], False) sendMessage(answer[0], False)
else: else:
sendMessage(answer[0][0], False) sendMessage(answer[0][0], False)
sendMessage(answer[0][1], False) sendMessage(answer[0][1], False)


sendMessage(noAnswers[0]) sendMessage(noAnswers[0]) # FIX WHEN THE USER DOENS ANSWER FOR 3 TIMES
noAnswers.pop(0) if (len(noAnswers) > 0):
noAnswers.pop(0)
elif (answer[1] == 5): # If the user doesn't want to answer elif (answer[1] == 5): # If the user doesn't want to answer
sendMessage("You should, it would be more fun!") sendMessage("You should, it would be more fun!")
noAnswers.pop(len(noAnswers) - 1) noAnswers.pop(len(noAnswers) - 1)
@@ -14,7 +14,7 @@ class HyperlinkManager:


self.text.tag_config("hyper", foreground="blue", underline=1) self.text.tag_config("hyper", foreground="blue", underline=1)


#self.text.tag_bind("hyper", "<Enter>", self._enter) #Removed to prevent conflict with pressing Enter to send a message self.text.tag_bind("hyper", "<Enter>", self._enter) #Removed to prevent conflict with pressing Enter to send a message
self.text.tag_bind("hyper", "<Leave>", self._leave) self.text.tag_bind("hyper", "<Leave>", self._leave)
self.text.tag_bind("hyper", "<Button-1>", self._click) self.text.tag_bind("hyper", "<Button-1>", self._click)


0 comments on commit 1598043

Please sign in to comment.