def addjokes(self, conn, intCon): speak("Setting up jokes") cursor = conn.cursor() cursor.execute("SELECT * FROM JOKES") jokes = cursor.fetchall() sqlite3_insert = "INSERT INTO JOKES (id, joke, answer) VALUES (?, ?, ?)" idnum = self.countJokes(jokes) + 1 speak("What joke is it?") joke = recordAudio(intCon).lower() speak("Okay, what is the answer?") answer = recordAudio(intCon).lower() speak("Okay I am going to list it down") data_tuple = (int(idnum), joke, answer) cursor.execute(sqlite3_insert, data_tuple) conn.commit() speak("Joke added. That was lit.") Admin.admin(Admin.admin, "none", conn, intCon)
def playFavorite(): speak("Okay") os.system('cls') print("Now playing EMMAN - Teka Lang") logmusic("EMMAN - Teka Lang", "playmusc_fav") playsound(MUSIC_PATH + r'\\EMMAN - Teka Lang (Official Lyric Video).mp3') return
def createTask(conn, intCon): ''' Called for creating a new task in the database ''' ### LocVars (Local Variables) ### try: cursor = conn.cursor() # If conn is None or closed. if not conn: conn = sqlite3.connect('data.db') cursor.execute("SELECT * FROM TASKS") tasks = cursor.fetchall() speak("Okay, I am going to make a task.") # Get the ID idnum = countAllTask(tasks) + 1 speak("What's the title of the task?") # Get the Title title = recordAudio(intCon).lower() speak("What's the description?") # Get the description desc = recordAudio(intCon).lower() speak("What's week number?") # Get the week number week = recordAudio(intCon).lower() # Insert to Database data_tuple = (int(idnum), title, desc, week) sqlite_insert = """INSERT INTO TASKS (id, title, desc, week) VALUES (?, ?, ?, ?)""" # Execute and Commit cursor.execute(sqlite_insert, data_tuple) conn.commit() logtask(title, "POST") except Error: handleTaskErrors() speak("Task Inserted successfully!")
def admin(self, response, conn, intCon): os.system('cls') speak("Setup mode activated") print( "To deactivate, say something that does not familiar in the setup mode or say exit." ) validate = recordAudio(intCon).lower() if ('exit' in validate): speak("Setup mode deactivated") return if ('jokes' in validate): self.jokes.addjokes(self.jokes, conn, intCon)
def playsong(music, isRepeat): speak("Okay, choosing a music from your playlist...") os.system('cls') if isRepeat: musics = randomizeMusic() print("Now playing " + musics[0] + "...") logmusic(musics[0], "play_musc_shuf_rpt") playsound(MUSIC_PATH + fr"\\{musics[0]}") print('Music ended') playsong(music, isRepeat) musics = randomizeMusic() print("Now playing " + musics[1] + "...") logmusic(musics[0], "playmusc_shuf") playsound(MUSIC_PATH + fr"\\{musics[0]}") print('Music ended')
def guesswho(question): speak('Working for it...') question = removePrefix(question) print(question) title = wikipedia.page(question).title summary = wikipedia.summary(question) speak("Information about " + title) speak(summary)
def timer(intCon): speak("Timer starts... now.") os.system('cls') print("Say STOP to stop the timer") t = Timer() t.start() stop = recordAudio(intCon) if 'stop' in stop: elapsed = t.stop() speak("Timer stopped!") speak(elapsed)
def telljokes(conn): joke_arr = get_jokes(conn) speak(joke_arr[0]) speak(joke_arr[1])
def greet(response, conn): ''' If greets then response ''' # For counting tasks cursor = conn.cursor() try: cursor.execute("SELECT * FROM TASKS") except Error: handleTaskErrors(conn) tasks = cursor.fetchall() counted = countAllTask(tasks) if 'good morning' in response: loggreet("good morning", "morning") speak('Good morning') dateNow = date() speak(dateNow[0]) speak(dateNow[1]) speak("And you have " + str(counted) + " tasks to be done.") speak("Have a nice day.") if 'good afternoon' in response: log("good afternoon", "afternoon") speak('Good afternoon.') if 'good evening' in response: log("good evening", "evening") speak('Good evening') if 'good night' in response: log("good night", "night") speak('Good night ') speak("Let's talk tommorow ") if 'hello' in response: log("Hello", "Hello") speak('Hi') if 'hi' in response: log("Hi", 'Hi') speak('Hello')
def get_task(conn): ''' Get all the task from database ''' if not conn: conn.connect('data.db') try: cursor = conn.cursor() tasks = cursor.fetchall() cursor.execute("SELECT * FROM TASKS") tasks = cursor.fetchall() if countAllTask(tasks) == 0: speak("Looks like you haven't commanded me to create a task yet.") else: speak("Your tasks are...") logtask(None, "GET") for task in tasks: speak("Task number: " + str(task[0])) speak("Title: " + task[1]) speak("Description: " + task[2]) speak("Week Number: " + str(task[3])) except Error: handleTaskErrors(conn) speak("If you want to insert more task just command me to create.")