Skip to content
Permalink
Browse files
Fixed bugs and client no longer crashes with empty messages
  • Loading branch information
jansonsa committed Nov 21, 2017
1 parent 47e76b2 commit 4fe508669c15dabc5d8b8ad84f052b5c8b651a42
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
@@ -8,8 +8,6 @@ def findFood(text):
food = ""
for word in text:
if found == False:
if word == "get":
continue
if word in KEYWORDS:
found = True #Finds the first keyword
food = word
@@ -20,5 +18,7 @@ def findFood(text):
continue
food = food + " " + word #If multiple keywords follow each other
break # take all of them in account and the word
return food # that follows them as well e.g. "The best burger"
# that follows them as well e.g. "The best burger"

food = food.replace("get",'').replace("is",'').replace("are",'').replace("to",'').strip(' ') # Make the string neat for printing it out
return food
15 GUI.py
@@ -28,14 +28,15 @@ def clickAction():
savePreferences(userName)
entryText = filteredMessage(entryBox.get("0.0", END))
loadMyEntry(chatDispl, entryText)
client.send( entryText.encode('utf-8') ) # Encode the messsage in bits and send it to server
try:
rawmsg = client.recv(1024) # recieve up to 1024 bytes
if not(entryText == ''):
client.send( entryText.encode('utf-8') ) # Encode the messsage in bits and send it to server
try:
rawmsg = client.recv(1024) # recieve up to 1024 bytes

msg = rawmsg.decode('utf-8').rstrip('\r\n') # Decode received message from bits to string
loadOtherEntry(chatDispl, msg)
except:
print("Didnt receive a message")
msg = rawmsg.decode('utf-8').rstrip('\r\n') # Decode received message from bits to string
loadOtherEntry(chatDispl, msg)
except:
print("Didnt receive a message")
chatDispl.yview(END)#Scroll to the bottom of chat windows
entryBox.delete("0.0", END) #Erace previous message in Entry Box
except:
@@ -37,7 +37,7 @@ def findPlace(location_str='Coventry University',keyword_str='Food'):
placeWebsite = place.website
if not(place.local_phone_number == None):
placePhone = place.local_phone_number
return placeName, placeAddress, placeWebsite, placePhone # Also works as a break statement
return placeName, placeAddress, placeWebsite, placePhone # Also works as a break statement because we only need the first place

except:
placeName = None
@@ -20,8 +20,10 @@ try:
rawmsg = c.recv(1024) # recieve up to 1024 bytes

msg = rawmsg.decode('utf-8').rstrip('\r\n') # convert and clean the input

rtrnmsg = generateResponse(msg, temp) # create return message
if not(msg==''):
rtrnmsg = generateResponse(msg, temp) # create return message
else:
rtrnmsg = "I don't like empty messages"
temp = msg # Keep last message
print( '%s -> %s' % (msg,rtrnmsg) )

0 comments on commit 4fe5086

Please sign in to comment.