Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
chatBot/client_code.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
27 lines (26 sloc)
981 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
def Main(): | |
#connection to ChatBot | |
host = '127.0.0.1' | |
port = 50036 | |
thisSocket = socket.socket() | |
thisSocket.connect((host,port)) | |
#Reading first message to ChatBot | |
message = input(" Message to ChatBot: ") | |
#Continue conversation with ChatBot until end is types | |
while message != "end": | |
#send message to Chatbot | |
thisSocket.send(message.encode()) | |
#Receive Message from ChatBot | |
RMess = thisSocket.recv(1024).decode() | |
#Print message from ChatBot | |
print('Message Received from ChatBot: '+RMess) | |
#Get user message to ChatBot | |
message = input(" Foodie: ") | |
#Close Socket | |
thisSocket.close() | |
#Display conversation is over | |
print("Conversation between user and ChatBot Ended") | |
#Check if running directly from this file | |
if __name__ == '__main__': | |
Main() |