def weather(city_name): weather = Weather(unit=Unit.CELSIUS) #fk farenheit kappa location = weather.lookup_by_location('city_name') condition = location.condition weather_today = "The weather is " + str( condition.text) + "with a temperature of" + str( condition.temp) + "degrees celcius in " + city_name ptts(weather_today)
def define(speech_text): words_of_message = speech_text.split() words_of_message.remove('define') cleaned = ' '.join(words_of_message) try: wiki_data = wikipedia.summary(cleaned, sentences=2) regEx = re.compile(r'([^\(]*)\([^\)]*\) *(.*)') m = regEx.match(wiki_data) while m: wiki_data = m.group(1) + m.group(2) m = regEx.match(wiki_data) wiki_data = wiki_data.replace("'", "") ptts(wiki_data) except wikipedia.exceptions.DisambiguationError as e: ptts( 'Could you be more specific? You can choose one of the following.') #shows all the options print( "Could you be more specific? You can choose one of the following.; {0}" .format(e))
def go_to_sleep(name): ptts('All right' + name + '. Later! ') quit()
def what_is_time(): ptts("Its" + datetime.strftime(datetime.now(), '%H:%M:%S'))
def who_are_you(): ptts('My name is Melissa. Your lovely assistant')
def tell_joke(): jokes = [ 'Joke', 'Once there was an ulgy barnacle. He was so ugly, that everyone died. The end.' ] #LOL patrick ptts(random.choice(jokes))
def undefined(): ptts('Sorry i did not understant.')
def how_are_you(): ptts('I am fine. Thanks for asking.')
def where_born(city_name): ptts('You are from' + city_name)
def who_am_i(name): ptts('Your name is ' + name + ', you are the current user.')
def repeat_after(speech_text): mensaje = speech_text.split() mensaje.remove('repeat') limpio = ' '.join(mensaje) ptts(limpio)