Exemplo n.º 1
0
    def handle_message(self, message: Dict[str, Any],
                       bot_handler: Any) -> None:
        string = message['content'].split()
        content = "something went wrong"
        check = string[0].lower()
        if check == "calculate":
            content = Calculator.calculate(string)
        elif check == "coding_contest":
            content = Coding().getList()
        elif check.lower() == 'define':
            dictword = string[1]
            content = Dictionary.words(dictword)
        elif check.lower() == 'telljoke':
            content = Joke.tellJoke()
        elif check == "cricknews":
            content = Cricket().news()
        elif check == "proxy":
            if len(string) > 1:
                if string[1].lower() == "working":
                    content = Proxy.getWorkingProxy()
                    content = "Working Proxies in Your Area \n\n" + content
                elif string[1].lower() == "help":
                    content = Proxy.getHelpList()
                else:
                    content = WitHandler.getInfo(message['content'])
            else:
                content = Proxy.getProxyStatus()
                content = "Proxies Status--->\n\n" + content
        elif check.lower() == "play":
            try:
                pid = check_output(["pidof"], "mpg321")
                os.kill(int(pid), signal.SIGKILL)
                os.remove("hello.mp3")
                content = Music.main(string[1:])
            except:
                content = Music.main(string[1:])
            bot_handler.send_reply(message, "playing song ")
        elif check == "stop":
            pid = check_output(["pidof", "mpg321"])
            #print(int(pid))
            os.kill(int(pid), signal.SIGKILL)
            content = "Bye........:)"
            bot_handler.send_reply(message, content)
        elif check == "college_notice":
            content = Dean.getNotice()
        elif check == "add" and string[1] == "meeting":
            content = "Enter <Date> as <dd/mm/yyyy> <Time> as <hrs:min> and am/pm and purpose(one word)"

        elif len(string[0].split('/')) == 3:
            res = Meeting.AddMeeting(string)
            if res.lower() == "ok":
                content = "New Meeting successfully Added "
            else:
                content = res
        elif check == "show" and string[1].lower() == "meetings":
            content = Meeting.ShowMeeting()
        elif check == "pnr" and string[1].lower() == "status":
            content = Pnr.getpnr(string[2])
        elif check == "message" or check == "find" or check == "where":
            content = Send_message.sendMessage(string)
        # elif check=="mood":
        #     Mood.capture();
        elif check == "symptom":
            string_1 = " "
            gender = string[1]
            dob = string[2]
            st = string[3:]
            string_1 = string_1.join(st)
            content = Sympton.getExactSympton(string_1)
            try:
                content = "Please Tell me clearly\n" + content
            except:
                p = int(content)
                content = Sympton.getIssueId(str(p), gender, dob)
        elif check == "search":
            st = " "
            strlist = string[1:]
            st = st.join(strlist)
            st = FriendLocation.plot(st)
            if "https" in st:
                webbrowser.open(st)
                content = "check out below link \n" + st
            else:
                content = "Please type exact name :)\n" + st
        elif check == "getjobs":
            content = JOBS.getjobs()
        elif check == "translate":
            stri = " "
            stri = stri.join(list(string[1:]))
            content = Translate.translate(stri)
        elif check == "help":
            Help.Message()
            content = "Message sent"
        elif check == "nearby":
            content = Nearby.Place(string[1])
        else:
            #print(message['content'])
            content = WitHandler.getInfo(message['content'])
        bot_handler.send_reply(message, content)
Exemplo n.º 2
0
def mainListen():
    while True:
        x=listen().lower()
        if "news" in x:
            if "india" in x:
                playNewsIndia()
                doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
                os.system("play "+doyou+" tempo 1.1")
                # speak("Do you want me to do anything else?")
            else:
                playNews()
                doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
                os.system("play "+doyou+" tempo 1.1")
                # speak("Do you want me to do anything else?")

        elif "exit" in x or "no" in x or "no exit" in x:
            exit="Sounds/Alright-Thank-You-for-using-t1619638216.mp3"
            os.system("play "+exit+" tempo 1.1")
            # speak("Alright, Thank You for using this Voice Assistant, have a nice day.")
            break

        elif "songs" in x or "play songs" in x or "play some songs" in x or "music" in x:
            music=Music()
            music.main()
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")
        
        elif "email" in x or "send email" in x or "send" in x or "send an email" in x:
            alri="Sounds/Okay1620499210.mp3"
            os.system("play "+alri+" tempo 1.1")
            emailer()
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")

        elif "radio" in x or "play radio" in x:
            radi="Sounds/OkayPlaying-RadioEnjoy1621184618.mp3"
            os.system("play "+radi+" tempo 1.1")
            os.system("python3 radio.py")
            it_was_so_good="Sounds/It-was-so-good1621184764.mp3"
            os.system("play "+it_was_so_good+" tempo 1.1")
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")

        elif "time" in x:
            if "date" in x:
                getDate_Time()
                doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
                os.system("play "+doyou+" tempo 1.1")
            else:
                getTime()
                doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
                os.system("play "+doyou+" tempo 1.1")
        
        elif "date" in x:
                getDate()
                doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
                os.system("play "+doyou+" tempo 1.1")

        elif "age" in x or "old" in x:
            age()
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")

        elif "describe yourself" in x:
            alina="Sounds/Myself-Eleena-Alexas-little-1619638384.mp3"
            os.system("play "+alina+" tempo 1.1")
            # speak("Myself Alina, Alexa's little sister.")
            hm="greetings/How-can-I-help-you1619639087.mp3"
            os.system("play "+hm+" tempo 1.1")
            # speak("How may I help you?")

        elif "where" in x or "where am i" in x or "location" in x or "locate me" in x:
            # speak("You are currently in "+getLocation()[0]+getLocation()[1])
            # located="Sounds/You-are-currently-in1619697928.mp3"
            # os.system("play "+located+" tempo 1.1")
            # speak(getLocation()[0]+getLocation()[1])
            located="Sounds/You-are-currently-in-Valsad-Gu1619698254.mp3"
            os.system("play "+located+" tempo 1.1")
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")

        elif "monitor" in x or "home" in x or "monitor my home" in x or "house" in x:
            mt="Sounds/AlrightI-am-now-monitoring-you1620383303.mp3"
            os.system("play "+mt+" tempo 1.1")
            motion()
            break
        
        elif "vaccinations" in x or "vaccines" in x or "vaccinations have started" in x or "have vaccinations" in x or "vaccination" in x:
            ok_let_me_check="Sounds/OKLet-me-check1620390574.mp3"
            os.system("play "+ok_let_me_check+" tempo 1.1")
            time.sleep(0.5)
            vaccination()
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")

        else:
            icouldnot="Sounds/Sorry-I-could-not-do-that-at-1619638005.mp3"
            os.system("play "+icouldnot+" tempo 1.1")
            # speak("Sorry, I could not do that at this point of time, but I may get future updates")
            doyou="Sounds/Do-you-want-me-to-do-anything-1619637731.mp3"
            os.system("play "+doyou+" tempo 1.1")
            # speak("Do you want me to do anything else?")