fork download
  1. import random
  2. from datetime import datetime
  3.  
  4. installed_apps = {
  5. "calculator": "calculator.exe",
  6. "notepad": "notepad.exe",
  7. "paint": "mspaint.exe"
  8. }
  9.  
  10. installed_games = ["hades", "minecraft", "doom eternal"]
  11.  
  12. def chatbot(command):
  13. command = command.lower()
  14. if command in ["hi", "hello"]:
  15. return "Hi there! How can I help you?"
  16. elif "open" in command:
  17. app_name = command.replace("open", "").strip()
  18. if app_name in installed_apps:
  19. return f"Simulated: Opening {app_name.title()}"
  20. else:
  21. return f"I can't find '{app_name}' in installed apps."
  22. elif "what time is it" in command:
  23. now = datetime.now()
  24. return f"It's currently {now.strftime('%I:%M %p')}"
  25. elif "suggest a game" in command or "pick a game" in command:
  26. if installed_games:
  27. game = random.choice(installed_games)
  28. return f"How about playing {game.title()}?"
  29. else:
  30. return "No games found."
  31. elif "bye" in command:
  32. return "Goodbye! Have a great day."
  33. else:
  34. return "Sorry, I don't understand that."
  35.  
  36. if __name__ == "__main__":
  37. for prompt in ["hello", "suggest a game", "what time is it", "open calculator", "bye", "exit"]:
  38. print(f"You: {prompt}")
  39. if prompt.lower() in ["exit", "quit"]:
  40. print("Assistant: Session ended.")
  41. break
  42. print(f"Assistant: {chatbot(prompt)}")
Success #stdin #stdout 0.1s 14320KB
stdin
hello
How are you 
Pick a game 
Do you know me
Open hades
stdout
You: hello
Assistant: Hi there! How can I help you?
You: suggest a game
Assistant: How about playing Hades?
You: what time is it
Assistant: It's currently 12:18 AM
You: open calculator
Assistant: Simulated: Opening Calculator
You: bye
Assistant: Goodbye! Have a great day.
You: exit
Assistant: Session ended.