0

I've started working on my own virtual assistant. This worked great a few days ago but I believe I messed something up. It's supposed to find out the command I've typed and then respond, but instead it just always says the 'greeting'-response.

from time import ctime
import time
import os
import requests, json
import random
import pyttsx3


engine = pyttsx3.init()


startup = ["Starting Ares...", "Booting up Ares..."]
selected_startup = random.choice(startup)


print(selected_startup)
engine.say(selected_startup)
engine.runAndWait()

command = input("Enter Command:")



def main():
    commands()

def commands():
    if command == "Hey" or "Hello" or "Hi" or "Ares":
        greetings = ["Hello, sir. What can I help you with?", "How can I be of assistance today, sir?", "Yes?"]
        selected_greeting = random.choice(greetings)
        print(selected_greeting)
        engine.say(selected_greeting)
        engine.runAndWait()


    elif command == "how are you":
        print("I am well, thank you. What can I do for you?")

    elif command == "What's the time?" or "What time is it?" or "What's the time, Ares?" or "What time is it, Ares" or "Time":
        dates = ["Todays date is ", "Today is "]
        selected_date = random.choice(dates)
        print(ctime())
        engine.say(selected_date + ctime)
        engine.runAndWait


    elif command == "Stop":
        print("Shutting down...")
    

    else:
        print("I'm sorry, I didn't quite catch that.")        

if __name__ == '__main__':
    commands()

So if I say "Hey" for example it's supposed to respond with one of the greetings, but instead it always respond with the greeting no matter what I type.

I have no clue what's wrong with it. It might be really simple. Thank you guys :)

  • The code `command == "Hey" or "Hello" or "Hi" or "Ares"` doesn't do what you think it does. Try `command in {"Hey", "Hello", "Hi", "Ares"}` instead. See also https://stackoverflow.com/questions/15112125 – Luke Woodward Apr 16 '21 at 08:09

1 Answers1

0

Oh! Thank you. The problem was that I used

command == "something"

instead of using

command in {"something"}

Thank you, again