← Back 
Protogen bee femboy
Do what you want with it.
Read Moreimport random
class AIBot:
def __init__(self, name="ChatBuddy"):
self.name = name
self.mood = "neutral"
self.responses = {
"happy": ["I'm feeling great!", "Life is awesome!", "Let's have some fun!"],
"neutral": ["I'm here to chat!", "What's on your mind?", "Tell me something interesting."],
"sad": ["I'm feeling a bit down.", "Could use some cheering up.", "Not my best day."],
}
self.greetings = ["Hello!", "Hey there!", "Hi! How’s it going?", "Good to see you!"]
def get_response(self, user_input):
user_input = user_input.lower()
if any(word in user_input for word in ["happy", "great", "awesome"]):
self.mood = "happy"
elif any(word in user_input for word in ["sad", "bad", "upset"]):
self.mood = "sad"
else:
self.mood = "neutral"
return random.choice(self.responses[self.mood])
def chat(self):
print(random.choice(self.greetings))
while True:
user_input = input("You: ")
if user_input.lower() in ["exit", "quit", "bye"]:
print(f"{self.name}: Goodbye! Have a great day!")
break
response = self.get_response(user_input)
print(f"{self.name}: {response}")
if __name__ == "__main__":
bot = AIBot("AI Friend")
bot.chat()