-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatbot.py
More file actions
44 lines (39 loc) · 1.19 KB
/
Copy pathchatbot.py
File metadata and controls
44 lines (39 loc) · 1.19 KB
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
"""
Simple CLI ChatBot
Author: Your Name
Date: 2025
"""
from colorama import init, Fore, Style
# Initialize colorama
init(autoreset=True)
def get_bot_response(user_input):
"""
Returns a response based on user input.
:param user_input: str
:return: str
"""
user_input = user_input.lower()
if "hello" in user_input or "hi" in user_input:
return "Hi there! How can I help you today?"
elif "how are you" in user_input:
return "I'm just a bunch of Python code, but I'm running smoothly!"
elif "bye" in user_input:
return "Goodbye! Have a great day!"
elif "your name" in user_input:
return "I'm PyBot, your simple Python chatbot."
else:
return "Sorry, I didn't understand that."
def chat():
"""
Main chat loop.
"""
print(Fore.CYAN + "Welcome to PyBot! Type 'bye' to exit.")
while True:
user_input = input(Fore.YELLOW + "You: " + Style.RESET_ALL)
if user_input.lower() == "bye":
print(Fore.GREEN + "PyBot: " + get_bot_response(user_input))
break
response = get_bot_response(user_input)
print(Fore.GREEN + "PyBot: " + response)
if __name__ == "__main__":
chat()