def run_alexa(): command = take_command() print(command) if 'play' in command: song = command.replace('play', '') talk('playing' + song) pywhatkit.playonyt(song) elif 'my time' in command: time = datetime.datetime.now().strftime('%I:%M %p') print(time) talk('The current time is ' + time) elif 'who is' in command: person = command.replace('who is', '') info = wikipedia.summary(person, 3) print(info) talk(info) elif 'date' in command: talk('Sorry, i have a headache') elif 'are you single' in command: talk('Sorry, i am in a relationship with wifi') elif 'joke' in command: talk(pyjokes.get_jokes()) elif 'what is the time in' in command: tz = pytz.timezone('Europe/Berlin') berlin = datetime.datetime.now(tz).strftime('%I:%M %p') print(berlin) talk(berlin) else: talk('Please say that again.')
def index(number,language,category): jokes={} if (language == "es" or language == "gl") and category == "chuck" : errorMessage = {"error":"Zero jokes found on Chuck Norris in this language. Please try a different language."} error = jsonify(errorMessage) error.headers["Access-Control-Allow-Origin"] = "*" error.headers["Content-Type"] = "application/json" return error else: allFetchedJokes = pyjokes.get_jokes(language=language, category=category) if number <= len(allFetchedJokes): emptyDictionary={} for completeJokeList in range(len(allFetchedJokes)): emptyDictionary[completeJokeList]=allFetchedJokes[completeJokeList] for individualJokeList in range(number): jokes[individualJokeList]=emptyDictionary[individualJokeList] joke = jsonify(jokes) joke.headers["Access-Control-Allow-Origin"] = "*" joke.headers["Content-Type"] = "application/json" return joke else: jokes={"error 404":"Error 404, Joke number out of expected range"} joke = jsonify(jokes) joke.headers["Access-Control-Allow-Origin"] = "*" joke.headers["Content-Type"] = "application/json" return joke
def idjoke(n: int): jokelist = pyjokes.get_jokes() chosen_joke = jokelist[n] dict = {'joke': chosen_joke} return jsonify(dict)
def run_fernanda(): commande = prendreCommande() print(commande) if 'joue' in commande: son = commande.replace('joue','') parler('je joue le son de' + son) pywhatkit.playonyt(son) print('joue ...') elif 'heure' in commande: heure = _datetime.datetime.now().strftime('%H:%M') print(heure) parler('il est ' + heure) elif 'Bonjour' in commande: parler('Bonjour') parler('Je suis fernanda') parler('Que puis je faire pour toi') elif 'ça va' in commande: print("je vais bien et toi ") parler("je vais bien et toi ") elif 'appele' in commande: print("je m'appelle fernanda ") parler("je m'appelle fernanda ") elif 'video' in commande: son = commande.replace('joue', '') parler('je joue ' + son) pywhatkit.playonyt(son) print('joue ...') elif 'que signifie' in commande: personne = commande.replace('que signifie','') info = wikipedia.summary(personne,1) print(info) parler(info) elif 'qui est' in commande: personne = commande.replace('que est','') info = wikipedia.summary(personne,1) print(info) parler(info) elif 'date' in commande: date = _datetime.datetime.now().date() print(date) parler('aujourdhui cest le ' + date) elif 'seul' in commande: print("Je suis en couple avec ferdinand") parler( "Je suis en couple avec ferdinand") elif 'parle' in commande: parler(pjo.get_jokes()) elif 'gl' in commande: parler('Ferdinand') parler('Christian') parler('Firmin') parler('Sodjine') parler('Benjamin') parler('Kelly') parler('Adriano') elif 'journe' in commande: parler('Tout va bien et de ton coté') else: parler('Sil vous plaît jai rien entendu')
def get_random_joke(): ranNum = random.random() jokeList = pyjokes.get_jokes(category="all", language="en") ranNum = int(ranNum*len(jokeList)) joke = jokeList[ranNum] res = Response(json.dumps({"jokes": joke})) res.headers["Access-Control-Allow-Origin"] = "*" res.headers["Content-Type"] = "application/json" return res
def run_alexa(): command = take_command() print(command) if 'play' in command: song = command.replace('play', '') talk('yes madam priya Iam playing a song for you' + song) pywhatkit.playonyt(song) elif 'time' in command: time = datetime.datetime.now().strftime("%I:%M %A") print(time) talk('madam priya The current is' + time) elif 'who is' in command: person = command.replace('who is', '') info = wikipedia.summary(person, 4) print(info) talk(info) elif 'joke' in command: print(pyjokes.get_jokes()) talk(pyjokes.get_jokes()) else: talk('could you tell the command again .')
def get_specific_joke(id): jokeList = pyjokes.get_jokes(category="all", language="en") try: joke = jokeList[int(id)] res = Response(json.dumps({id: joke})) res.headers["Access-Control-Allow-Origin"] = "*" res.headers["Content-Type"] = "application/json" except: joke = "Sorry! We couldn't find a joke with the ID number "+str(id) res = Response(json.dumps({id: joke})) res.headers["Access-Control-Allow-Origin"] = "*" res.headers["Content-Type"] = "application/json" return res
def run_alexa(): command = take_command() print(command) if 'time' in command: time = datetime.datetime.now().strftime('%H:%M') talk('gaurav current time is' + time) print('gaurav current time is' + time) elif 'play' in command: song = command.replace('play', '') talk('playing' + song) print('playing' + song) pywhatkit.playonyt(song) elif 'search' in command: searches = command.replace('search', '') talk('searching for' + searches + 'on google') print('searching for' + searches + 'on google') pywhatkit.search(searches) elif 'who is' in command: wiki = command.replace('who is', '') info = wikipedia.summary(wiki, 1) print(wiki) talk(info) elif 'whatsapp message' in command: talk('tell me a whatsapp number') whatsappno = take_command() print(whatsappno) talk("tell me a message") msg = take_command() print(msg) pywhatkit.sendwhatmsg("+91" + whatsappno, msg, 15, 00) talk("message send successfully") elif 'who programmed you' in command: print("Gaurav Lokhande programmed me") talk("Gaurav Lokhande programmed me") elif 'are you single' in command: print( 'I like you but you are my best friend and i am in a relationship with your broadband name Jio Telecom' ) talk( 'I like you but you are my best friend and i am in a relationship with your broadband name Jio Telecom' ) elif 'joke' in command: jokes = pyjokes.get_jokes() talk(jokes) print(jokes) else: talk("please say it again")
def run_alexa(): command = take_command() if 'play' in command: song = command.replace('play', '') talk('playing' + song) pywhatkit.playonyt(song) elif 'time' in command: time = datetime.datetime.now().strftime('%I:%M %p') print(time) talk('current time is ' + time) elif 'who is' in command: person = command.replace('who is', '') info = wikipedia.summary(person, 1) print(info) talk(info) elif 'what is' in command: thing = command.replace('who is', '') info = wikipedia.summary(thing, 1) print(info) talk(info) elif 'date' in command: talk('I have an headache') elif 'are you single' in command: talk('I am in a relationship with my duty') elif 'i love you' in command: talk('i love you too') elif 'joke' in command: talk(pyjokes.get_jokes()) elif 'read' in command: book = open('CGM Notes Unit 1.pdf', 'rb') pdfreader = PyPDF2.PdfFileReader(book) pages = pdfreader.numPages print(pages) speaker = pyttsx3.init() page = pdfreader.getPage(1) text = page.extractText() speaker.say(text) speaker.runAndWait() else: talk('Please say again')
def pyjoke(bot, trigger): j1 = pyjokes.get_jokes(category="neutral") j2 = pyjokes.get_jokes(category="adult") bot.say(random.choice(j1 + j2))
def _jokes(): return pyjokes.get_jokes( language=request.args.get("language", "en"), category=request.args.get("category", "neutral") )
elif 'open google' in query: speak('Surfing to Google !!') webbrowser.open('www.google.com') elif 'open stack overflow' in query: speak('Surfing to Stack Overflow !!') webbrowser.open('www.stackoverflow.com') elif 'open github' in query: speak('Surfing to Github !!') webbrowser.open('www.github.com') elif 'jokes' in query: for i in pyjokes.get_jokes(): if i <= 10: speak(i) continue else: break elif 'who made you' in query: speak('My Creator is Piyush G') speak('Wanna Reach him') opt0 = command() if 'yes' in opt0: webbrowser.open( 'https://www.instagram.com/____piiyush____/') break
webbrowser.open("www.wikipedia.com") elif 'music' in input: speak("Ok Sir!!, listen this one!!") song_directory = "D:\\Songs\\Mr Shaan Songs" songs = os.listdir(song_directory) #TOOK UP ALL THE SONGS os.startfile( os.path.join(song_directory, songs[random.randint(0, 45)])) elif "change music" in input: # change the music speak("Ok sir, How's this!!") os.closefile( os.path.join(song_directory, songs[random.randint(0, 45)])) elif "jokes" in input: speak(pyjokes.get_jokes()) elif 'search' in input or 'play' in input: speak("Searching as you said " + input) query = input.replace("search", "") query = input.replace("play", "") webbrowser.open("https://www.google.com/?#q=" + query) elif 'exit' in input: speak("Ok bye Shaan! I m going!! please take care!") break elif "calculate" in input: app_id = "E9VQAV-PEKV8J37RW"
def joke(): # Tells Jokes speak(pyjokes.get_jokes())
if __name__ == '__main__': auth = tweepy.OAuthHandler('ANOwYsIT9bCuiuPQ6wlq1DN7U', 'EJ3F4HVF212S1B9qZwl4rsUKgDkkKTlaWdNhQQjijHJmoSdbIL') auth.set_access_token('1314925517158531072-43qIo3pbRY7SiyWOqVW6cQzTluTTrG', 'mbNiDAQkLNavtod8CPoqYS0QIAKqr6kF6TppAj4Yrzxrp') api = tweepy.API(auth) user = api.me() def limit_handler(cursor): try: while True: yield cursor.next() except tweepy.RateLimitError: time.sleep(300) except StopIteration: return jokes = pyjokes.get_jokes(category='all') # print(datetime.now()) for item in jokes: api.update_status(f'{datetime.now()} - All Python Joke {item} ') # print(user.name) # print(user.screen_name) # print(user.followers_count) # diff_user = api.get_user('AndreiNeagoie') # print(diff_user.name) # print(diff_user.followers_count) # public_tweets = api.home_timeline()
def joke(): speak(pyjokes.get_jokes())
def pyjoke(phenny, input): j1 = pyjokes.get_jokes(category='neutral') j2 = pyjokes.get_jokes(category='adult') phenny.say(random.choice(j1 + j2))
def test_all_jokes_are_funny(): for language in languages: jokes = get_jokes(language=language, category='all') for joke in jokes: assert True
import pyjokes import random # using get_jokes() to generate a whole list of jokes # language is german # category is twister list_of_jokes = pyjokes.get_jokes(language="en", category="all") # traversing through the generated list of jokes # Range of i may change, depending on the number of jokes # you want to display rank = random.randint(1, 100) def jokes(): return list_of_jokes[rank]
def jokes(): speak(pyjokes.get_jokes(language='en'))
def run_alexa(): global time5 command = take_command() print(command) if 'play' in command: song = command.replace('play', '') talk('playing ' + song) pywhatkit.playonyt(song) elif 'time' in command: time_india = pytz.timezone('Asia/Calcutta') time = datetime.datetime.now(time_india).strftime('%H:%M %p') talk('Current time is ' + time) elif 'what is' in command: information = command.replace("what is", '') info = wikipedia.summary(information, 5) print(info) talk(info) elif 'tell me about' in command: information2 = command.replace("tell me about", '') info2 = wikipedia.summary(information2, 10) print(info2) talk(info2) elif 'who is' in command: information3 = command.replace("who is", '') info3 = wikipedia.summary(information3, 10) print(info3) talk(info3) elif 'joke' in command: talk(pyjokes.get_joke()) elif 'jokes' in command: talk(pyjokes.get_jokes()) elif 'who the heck is' in command: person = command.replace('who the heck is', '') info4 = wikipedia.summary(person, 1) print(info4) talk(info4) elif 'date' in command: talk('sorry, I have a headache') elif 'are you single' in command: talk('I am in a relation ship with wifi') elif 'you are stupid' in command: talk( 'did you said me stupid , now see what i will do , i will screw up your pc' ) screen.rotate_to(270) screen.rotate_to(90) screen.rotate_to(180) talk('wanna say sorry') command = take_command() if 'sorry' in command: screen.rotate_to(0) elif 'who made you' in command: talk( 'i was developed by a greate man Avik , thanks to him for developing me' ) elif 'who do you like' in command: talk('of couse you but have to maintain a relationship with wifi') elif 'Do you love me' in command: talk('yes,of course i love you') elif 'boy or girl' and 'you' in command: talk('i am a girl') elif 'why your name is' in command: talk( 'my name is seven because my developers birthday comes and add up to seven and i was made on a date of seven. ' ) elif 'make a list' in command: talk('list sucessfully created. your list name is todo list') talk('tell what do want to add in this list,please one task at a time') command = take_command() task = command todo.append(task) todo elif 'message' in command: talk('tell person name') command = take_command() name = command.replace(' ', '') print(name) if name not in contacts: save_number(name) final_name = contacts[name] talk('pls tell what message you want to send') command = take_command() message = command message = str(message) print(message) talk('pls tell time if want to send now tell now') command = take_command() time_tell = command print(command) if 'now' in time_tell: time1 = pytz.timezone('Europe/London') time2 = datetime.datetime.now().strftime('%H:%M') print(time2) time3 = time2 time3 = time3.replace(':', '') time4 = list(time3) print(time4) time5 = str(time4.pop(0)) time5 = time5 + str(time4.pop(-3)) time6 = str(time4.pop(-2)) time6 = time6 + str(time4.pop(-1)) print(time5) print(time6) time5 = int(time5) time6 = int(time6) time6 = 2 + time6 pywhatkit.sendwhatmsg(final_name, message, time5, time6) talk( 'pls log in to whatsapp web on your default browser and make sure you brouser is open' ) elif 'add' and 'list' in command: talk('want do you want to add') command = take_command() task = command todo.append(task) todo elif 'search' in command: talk('getting results from google') search = pywhatkit.search(command) talk(search) elif 'how' in command: talk('getting results from google') search = pywhatkit.search(command) talk(search) else: talk('Please say the command again.')
def _jokes(): return pyjokes.get_jokes(language=request.args.get("language", "en"), category=request.args.get("category", "neutral"))
def test_all_jokes_are_funny(): for language in languages: jokes = get_jokes(language=language, category="all") for joke in jokes: assert True
def joke(): speak(pyjokes.get_jokes(language='en', category='all'))
def jokes(): number = random.randint(0, 96) joke = pyjokes.get_jokes() return joke[number]
def getJoke(cat, lang): ranNum = random.random() jokeList = pyjokes.get_jokes(category=cat, language=lang) ranNum = int(ranNum * len(jokeList)) joke = jokeList[ranNum] return joke
def send_jokes(language : str, category : str, number : int): content = pyjokes.get_jokes(language, category) return content
import pyjokes #this s for only one joke print(pyjokes.get_joke()) #this for multiple joke print(pyjokes.get_jokes())
def sendJokes(): content = pyjokes.get_jokes() return content
import pyjokes import re a = str(pyjokes.get_jokes()) re.split(r"[|]|;|}|\|{|,|", a) #b= a.split("[]"), #for i in b: # print(i)
def jokes(): speak(pj.get_jokes()) print(pj.get_jokes())
def joke(): for i in range(5): speak(pyjokes.get_jokes()[i])
def pyjoke(bot, trigger): j1 = pyjokes.get_jokes(category='neutral') j2 = pyjokes.get_jokes(category='adult') bot.say(random.choice(j1 + j2))
import pyjokes as pj print('impoerted') joke1 = pj.get_joke() print(joke1) joke2 = pj.get_jokes(language='en', category='neutral') #print(joke2) for i in range(5): print(i + 1, ".", joke2[i])
def pyjoke(bot, trigger): """Prints a random joke from the pyjoke repository""" j1 = pyjokes.get_jokes(category='neutral') j2 = pyjokes.get_jokes(category='adult') bot.say(random.choice(j1 + j2))