def ActualBot(sentence): if __name__ == '__main__': WAKE = 'hello' SERVICE = Gcalender.authenticate_google() while True: print("Listening") sentence = CInput.get_command() #sentence = SInput.VoiceCommand() if sentence.count(WAKE) > 0: speak("Im ready") sentence = CInput.get_command() #sentence = SInput.VoiceCommand() if "poweroff" in sentence or "power of" in sentence or "powerdown" in sentence or "power off" in sentence or "power down" in sentence or "powerof" in sentence: break botresponse = MIntegration.MLFunc(sentence) if botresponse == None: pass elif "weather" in botresponse: speak("Which City's weather report should I look for ?") command = input() #command = SInpuy.VoiceCommand() command = command.lower() Weather.weatherreport(command) elif "event" in botresponse: date = Gcalender.get_date(sentence) if date: Gcalender.get_events(date, SERVICE) else: speak("I dont understand") elif "mail" in botresponse: try: speak("Enter the Recipient") to = str(input()) speak("Enter the subject") subject = input() speak("What should I write?") content = input() UserEmail.SendSubEmail(to, subject, content) speak("Email has been sent") except Exception as e: print(e) speak("An Error has occured") #########BUG######## elif "search" in botresponse: speak("What should I search for ?") command = input() #command = SInput.VoiceCommand() CF.searchnet(command) elif "news" in botresponse: CF.shownews() elif "screenshot" in botresponse: CF.takescreenshot() elif "translate" in botresponse: Gtranslate.translatesentence() elif "shutdown" in botresponse: speak("Do you wish to shutdown the system ?") command = CInput.get_command() #command = SInput.VoiceCommand() if (command == 'yes' or command == 'yep' or command == 'sure'): os.system("shutdown /s /t 1") else: pass elif "restart" in botresponse: speak("Do you wish to restart the system ?") command = CInput.get_command() #command = SInput.VoiceCommand() if (command == 'yes' or command == 'yep' or command == 'sure'): os.system("shutdown /r /t 1") else: pass elif "maps" in botresponse: speak("Which place should i search for ?") place = input() #place = SInput.VoiceCommand() webbrowser.open("https://www.google.com/maps/place/" + place) elif "reddit" in botresponse: try: subreddit = input("Which subreddit ?") #subreddit = SInput.VoiceCommand() subreddit = subreddit.replace(" ", "") webbrowser.open_new_tab('www.reddit.com/r/' + subreddit) speak("Opening reddit") except Exception as e: speak("Something Went wrong") elif "note" in botresponse: speak("What should i write down ?") note_text = CInput.get_command() #note_text = SInput.VoiceCommand() Notes.instantnote(note_text) speak("I've made a note of that") elif "console" in botresponse: webbrowser.open_new_tab( "https://play.google.com/console/u/0/developers/5469473923678169464/app-list" ) elif "insta" in botresponse: speak("Initializing") CF.instagram() elif "standby" in botresponse: break elif "wiki" in botresponse: speak("What do you want me to search on wikipedia ?") wikisearch = CInput.get_command() CF.wiki(wikisearch) elif "wolfram" in botresponse: speak("Ask me") wolframquery = CInput.get_command() WRFile.wolframfunc(wolframquery) elif "read" in botresponse: EM.copydata() elif "copy" in botresponse: EM.copy() elif "paste" in botresponse: EM.paste() elif "time" in botresponse: CF.timetoday() elif "date" in botresponse: CF.daytoday() else: print("I dont understand you. Please be more specific") return
def process(self): sentence = self.lineEdit.text().lower() SERVICE = Gcalender.authenticate_google() botresponse = ModelIntegration.MLFunc(sentence) if botresponse != None: if "poweroff" in sentence or "exit" in sentence: self.close() elif "weather" in botresponse: self.setTB(speak("which City ?")) self.command = self.ShowDiag() try: self.setTB(Weather.weatherreport((self.command))) except Exception as e: self.setTB(speak("An Error Occured")) elif "event" in botresponse: date = Gcalender.get_date(sentence) if date: self.setTB(speak(Gcalender.get_events(date, SERVICE))) else: self.setTB(speak("I dont understand")) elif "mail" in botresponse: try: self.setTB("Enter the Recipient") to = self.ShowDiag() self.setTB(speak("Enter the subject")) subject = self.ShowDiag() self.setTB(speak("What should I write?")) content = self.ShowDiag() UserEmail.SendSubEmail(to, subject, content) self.setTB(speak("Email has been sent")) except Exception as e: print(e) self.setTB(speak("An Error has occured")) elif "news" in botresponse: self.setTB(speak(CF.shownews())) #Not Sorted out yet!! ####### elif "screenshot" in botresponse: self.setTB(speak(CF.takescreenshot())) elif "translate" in botresponse: self.setTB( speak("Enter the language you want to translate from")) inputlang = self.ShowDiag() self.setTB(speak("Enter the text")) userinput = self.ShowDiag() self.setTB( speak("Enter the language you want to translate to")) lang = self.ShowDiag() self.setTB( speak( Gtranslate.translatesentence(inputlang, userinput, lang))) elif "shutdown" in botresponse: self.setTB("Do you wish to shutdown the system ?") command = self.ShowDiag() if (command == 'yes' or command == 'yep' or command == 'sure'): os.system("shutdown /s /t 1") else: pass elif "restart" in botresponse: self.setTB("Do you wish to restart the system ?") command = self.ShowDiag() if (command == 'yes' or command == 'yep' or command == 'sure'): os.system("shutdown /r /t 1") else: pass elif "maps" in botresponse: #Not Sorted out!! self.setTB(speak("Which place should i search for ?")) place = self.ShowDiag() webbrowser.open("https://www.google.com/maps/place/" + place) elif "reddit" in botresponse: try: self.setTB("Which subbreddit ?") subreddit = self.ShowDiag() subreddit = subreddit.replace(" ", "") webbrowser.open_new_tab('www.reddit.com/r/' + subreddit) except Exception as e: print(e) self.setTB(speak("Something Went wrong")) elif "note" in botresponse: self.setTB("What should i write down ?") note_text = self.ShowDiag() Notes.instantnote(note_text) self.setTB(speak("I've made a note of that")) elif "console" in botresponse: self.setTB(speak("Opening your Playstore Console")) webbrowser.open_new_tab( "https://play.google.com/console/u/0/developers/5469473923678169464/app-list" ) elif "insta" in botresponse: self.setTB("Initializing") CF.instagram() elif "wiki" in botresponse: self.setTB( speak("What do you want me to search on wikipedia ?")) wikisearch = self.ShowDiag() self.setTB(speak(CF.wiki(wikisearch))) elif "wolfram" in botresponse: self.setTB(speak("Ask me")) self.wolframquery = self.ShowDiag() self.setTB( speak(wolframalphafile.wolframfunc(self.wolframquery))) elif "read" in botresponse: self.setTB(EM.copydata()) elif "copy" in botresponse: EM.copy() self.setTB("Copied") elif "paste" in botresponse: EM.paste() elif "time" in botresponse: self.setTB(speak(CF.timetoday())) elif "date" in botresponse: self.setTB(speak(CF.daytoday())) else: self.setTB( speak("I dont understand you. Please be more specific")) else: self.setTB(speak("Please try again"))