Exemple #1
0
def location_chat():
    # Function which returns information on the robots current location
    if location_info == "Nothing reported yet.":
        # Handles the case the robot hasn't yet reported it's location
        return tell("I haven't reported any location yet. Check again later.")
    speech = "I was last seen in point {}".format(location_info[0])
    return tell(speech)
Exemple #2
0
def respondToUser(term):

    # Try to stop any currently running slideshows
    try:
        global task
        os.killpg(os.getpgid(task.pid), signal.SIGTERM)
        print("Slideshow succesfully terminated.")
    except Exception as e:
        print("No task to terminate.")

    # Try to close the dashboard
    try:
        global dash
        os.system("sudo pkill chromium")
        print("Dashboard closed.")
    except Exception as e:
        print("No dashboard to close.")

    # Spawn process on new thread so that the user doesn't have to wait long
    # for a response
    download_thread = threading.Thread(target=downloadPhotos, args=[term])
    download_thread.daemon = True
    download_thread.start()

    if "kids" in term.lower() or "family" in term.lower(
    ) or "children" in term.lower():
        return tell('Showing photos of your family')
        ## return statement('Showing photos of your family')
    elif "dashboard" in term.lower() or "time" in term.lower(
    ) or "calendar" in term.lower():
        return tell('Getting your dashboard')
    else:
        ## return statement('Showing photos of {}. This may take some time.'.format(term))
        return tell(
            'Showing photos of {}. This may take some time.'.format(term))
Exemple #3
0
def lateraction(entity_id, delay, switch):
    delay = calc_delay(delay)
    service = homeassistant.get_services_for_entity(entity_id, switch)
    data = {"service": service, "delay": delay, "entity_id": entity_id}
    r = appdaemon.schedule("schedule", data)
    if not r:
        return tell("Could not schedule action, please try again later")
    return tell("Ok scheduled action")
Exemple #4
0
def lateractiondate(entity_id, switch, time):
    service = homeassistant.get_services_for_entity(entity_id, switch)
    logging.debug("Service:{}".format(service))
    data = {"service": service, "time": time['time'], "entity_id": entity_id}
    r = appdaemon.schedule("timeschedule", data)
    if not r:
        return tell("Could not schedule action, please try again later")
    return tell("Ok scheduled action")
def cast_intent(q):

    result = broadcast_youtube(q)

    if result.confirmation == "Failed":
        return tell("Failed to broadcast because {}".format(result.reason))

    return tell("Casting {} on the TV".format(result.data["name"]))
Exemple #6
0
def gstatus(entity_id):
    device = entity_id
    gstate = homeassistant.get_state(entity_id=device)
    if not gstate:
        return tell("Something went wrong, try again whenever you are ready")
    logging.debug(gstate)
    state = gstate.state
    friendly_name = gstate.attributes['friendly_name']
    return tell("The {} is now {}".format(friendly_name, state))
Exemple #7
0
def desk_chat(user):
    print(user)
    speech = ""
    try:
        desk = Staff.query.filter(
            Staff.name.ilike(user)).one().staff.location_name
        speech = "{} works in {}.".format(user, desk)
        return tell(speech)
    except:
        speech = "I couldn't find user {} in the system.".format(user)
        return tell(speech)
Exemple #8
0
def metar_google(airport):
    """
    Return a spoken and display METAR response
    """
    wxret, status_code = handle_report('metar', [airport['ICAO']],
                                       ['summary', 'speech'])
    if status_code != 200:
        return assist.tell(
            'There was a problem generating the response from the website')
    speech = 'Conditions at ' + airport['name'] + '. ' + wxret['Speech']
    text = wxret['Raw-Report'] + ' —— ' + wxret['Summary']
    return assist.tell(speech, display_text=text)
Exemple #9
0
def setstatereminder(reminder, state, event):
    headers = {"Content-Type": "application/json"}
    data = {"reminder": reminder}
    r = requests.post(url_for("reminder.reminder",
                              state=state,
                              event=event,
                              _external=True),
                      data=json.dumps(data),
                      headers=headers)
    if r.status_code != 200:
        return tell("Something went wrong, please try again later")
    return tell("Ok added your reminder")
def say_hashtag(any):

    r=requests.get("https://corona.lmao.ninja/countries")
    hh=r.json()
    con=[]
    for h in hh:
        temp=h['country']
        temp2=temp.upper()
        con.append(temp2)



    mm=""
    for ss in any: 
        p=ss.capitalize()
        mm=mm+p
    print(mm)



    if mm not in con:
        # labels = 'Cases', 'Deaths', 'Recovered'
        # sizes = [, 30, 45, 10]
        r=requests.get("https://corona.lmao.ninja/all")
        cases=str(r.json()['cases'])
        deaths=str(r.json()['deaths'])
        recovered=str(r.json()['recovered'])
        updated=str(r.json()['updated'])
        speechtext="I couldn't get the country name. Here is the global data of covid'19. Overall cases are "+cases+" with total deaths of "+deaths+" and recovered patients are "+recovered+"."

        return tell(speechtext).card(
            text=speechtext,
            title='Updated global data'
        )
    else:
        url="https://corona.lmao.ninja/countries/"+mm
        r=requests.get(url)
        country=str(r.json()['country'])
        cases=str(r.json()['cases'])
        today_case=str(r.json()['todayCases'])
        deaths=str(r.json()['deaths'])
        today_death=str(r.json()['todayDeaths'])
        recovered=str(r.json()['recovered'])
        active=str(r.json()['active'])
        critical=str(r.json()['critical'])
        rarecase=str(r.json()['casesPerOneMillion'])
        speechtext="In "+country+", total cases are "+cases+". Today "+today_case+" cases were found. Total deaths are "+deaths+" and total recovered cases are "+recovered+". Active cases are "+active+"."
        ti="Updated "+country+" data"
        return tell(speechtext).card(
            text=speechtext,
            title=ti
        )
def calc(num_1,num_2,red_apple,green_apple):
    if not red_apple == "赤りんご":
        checkout_all = int(num_2) * green_price
        speech = '{}{}個でお会計{}円になります'.format(green_apple,num_2,checkout_all)
        return tell(speech)
    elif not green_apple == "青りんご":
        checkout_all = int(num_1) * red_price
        speech = '{}{}個でお会計{}円になります'.format(red_apple,num_1,checkout_all)
        return tell(speech)
    else:
        checkout_all = checkout(int(num_1) ,int(num_2))
        speech = '{}{}個と{}{}個でお会計{}円になります'.format(red_apple,num_1,green_apple,num_2,checkout_all)
        return tell(speech)
Exemple #12
0
def deletereminder(reminder):
    r = requests.get(
        url_for("reminder.reminderquery", qreminder=reminder, _external=True))
    if r.status_code != 200:
        return tell("Could not fetch state reminders at this point in time")
    data = r.json()
    if len(data) == 0:
        return tell("no matching reminder to delete")
    r = requests.delete(
        url_for("reminder.reminderquery", qreminder=reminder, _external=True))
    if r.status_code != 200:
        return tell("Could not delete reminder at this moment")
    return tell("Ok deleted")
def get_latest():
    data = d.latest
    if data is None:
        return tell('You dont have any orders yet!')

    speech = "Your current order is from {} at {}".format(data['Restaurant'], data['Pickup Time'])
    order_items = get_order_items(data)
    resp = tell(speech).build_list()
    resp.include_items(order_items)

    order_url = d.get_order_url(data['OrderId'])  # maybe move into scraper
    resp.link_out('View Order', order_url)      # and add to the order dict

    return resp
Exemple #14
0
def who():
    load_img = image.load_img(rgb_image, target_size=(32, 32))
    x = image.img_to_array(load_img)
    x = np.expand_dims(x, axis=0) / 255

    face_predict = model.predict(x)
    if face_predict < 0.5:
        print(face_labels[0], face_predict[0][0])
        return tell('あなたは{}ちゃんですね。'.format(face_labels[0]))
    elif face_predict >= 0.5:
        print(face_labels[1], face_predict[0][0])
        return tell('あなたは{}ちゃんですね。'.format(face_labels[1]))
    else:
        print('だれ?')
        return ask('だれだかよくわかりません')
Exemple #15
0
def get_id():
    try:
        userid = get_user_id(request)
        speech = "Ok, the User Id is " + userid
    except:
        speech = "An error has occured, please try later."
    return tell(speech)
Exemple #16
0
def complete(InitialWords):
    t1 = time.time()
    speech = create_sentence(InitialWords, seed=0, diversity=0.0)
    t2 = time.time()
    log('CompleteSentenceIntent "{0}" -> "{1}" Response time = {2:.1f}s'.
        format(InitialWords.encode('utf-8'), speech.encode('utf-8'), t2 - t1))
    return tell(speech)
Exemple #17
0
def change_temperature(temperature):
    try:
        userid = get_user_id(request)
        url = database(userid)[2] + "/api/printer/tool"
        headers = {
            'Content-Type': 'application/json',
            'X-Api-Key': database(userid)[3]
        }
        if temperature == "zero":
            temperature = "0"
        temperature = int(temperature)
        payload = {'command': 'target', "targets": {"tool0": temperature}}
        r = requests.post(url, headers=headers, data=json.dumps(payload))
        if r.status_code != 204:
            speech = "Error, their is a problem, the printer will not heat up, try to find the problem or try later !"
        else:
            temperature = str(temperature)
            if temperature == "0":
                speech = "Ok, cooling down"
            else:
                speech = "Ok, heating up to " + temperature + " degrees"

    except:
        speech = "An error has occured, please try later."
    return tell(speech)
Exemple #18
0
def getreminder(state, event):
    r = requests.get(
        url_for("reminder.reminder", state=state, event=event, _external=True))
    if r.status_code != 200:
        return tell("Could not fetch state reminders at this point in time")
    speech = []
    data = r.json()
    if len(data) == 0:
        return tell("no reminders currently for {} {}".format(state, event))
    resp = ask("Here is a list of reminders for {} {}".format(state, event))
    mylist = resp.build_list("Here is a list of reminders for {} {}".format(
        state, event))
    for d in data:
        new_item = build_item(title=d['reminder'])
        mylist.include_items(new_item)
    return mylist
Exemple #19
0
def local_Sales_query():  #triggers up the local(sales) intent
    response2 = print(
        'अब कृपया मुझे अपनी आज की लोकल चश्मों बिक्री का आंकड़ा बताएं')
    data = request.get_json(force=True)
    intent = data["queryresult"]["intent"]["Fathers-Occupation"]
    speech = 'Running'
    return tell(speech)
Exemple #20
0
def father_occupation_query():  # belongs to action of father's occupation
    response1 = print(
        'आपका बहोत धन्य्वाद। अब कृपया मुझे अपने पिता का व्यवसाय बताएं')
    data = request.get_json(force=True)
    intent = data["queryresult"]["intent"]["Name"]
    speech = 'Running'
    return tell(speech)
Exemple #21
0
def get_timeleft():
    try:
        userid = get_user_id(request)
        url = database(userid)[2] + "/api/job"
        headers = {
            'Content-Type': 'application/json',
            'X-Api-Key': database(userid)[3]
        }
        r = requests.get(url, headers=headers)
        json_response = r.json()
        timeleft = json_response['progress']['printTimeLeft']
        if r.status_code != 200:
            speech = "Error, their is a problem, I cannot get the time left, try to find the problem or try later !"
        else:
            if timeleft == None:
                speech = "The printer is not printing right now"
            else:
                timeleft = int(timeleft)
                timeleft = timeleft / 60
                timeleft = int(timeleft)
                timeleft = str(timeleft)
                speech = "Ok, the print has about " + timeleft + " minutes left"
    except:
        speech = "An error has occured, please try later."
    return tell(speech)
Exemple #22
0
def what():
    load_img = image.load_img(rgb_image, target_size=(32, 32))
    x = image.img_to_array(load_img)
    x = np.expand_dims(x, axis=0) / 255

    apple_predict = model.predict(x)
    if apple_predict < 0.5:
        print(apple_labels[0], apple_predict[0][0])
        return tell('これは{}ですね。わたし青りんご嫌い。'.format(apple_labels[0]))

    elif apple_predict >= 0.5:
        print(apple_labels[1], apple_predict[0][0])
        return tell('これは{}ですね。わーい、赤りんご大好き。'.format(apple_labels[1]))
    else:
        print('なにりんごかよくわかりません')
        return ask('なにりんごかよくわかりません')
Exemple #23
0
def google_member_count(meetup: str) -> tell:
    group = meetup_utils.get_group(meetup)
    details = meetup_utils.extract_details(group)
    speech_text = f"{details['name']} has {details['members']} {details['member_title']}"
    return tell(speech_text).card(
        title=details['name'],
        text=f"{details['members']} {details['member_title']}")
Exemple #24
0
def select_recipe(option1, option2, option3, food):
    print(food)
    if food != "":
        option = food
    elif option1 is not None:
        option = option1
    elif option2 is not None:
        option = option2
    else:
        option = option3

    score = {rec: 0 for rec in recipes}
    for word in food.split(" "):
        for rec in recipes:
            rec_name = set(word.lower() for word in rec.name.split(" "))
            if word.lower() in rec_name:
                score[rec] += 1

    food_chosen = np.argmax(list(score.values()))

    speech = "Okay, here's how you make it. "
    if food == "":
        speech += recipes[int(option) - 1].instructions
    else:
        speech += recipes[food_chosen].instructions

    print(recipes[food_chosen].name)
    print(speech)

    return tell(speech)
Exemple #25
0
def default():
    query = request.get_json()['result']['resolvedQuery']
    r = wolfram.query(query)
    try:
        res = next(r.results).text
    except:
        res = "Could not find an answer for you at this time"
    return tell(res)
Exemple #26
0
def MQ7_Engine_Room():
    Reading = Get_SQL_Value(Get_Assistant_Config_Values("MQ7 Engine Room"))

    if Reading < 350:
        speech = "ALARM! The MQ7 sensor in the engine room is currently reading " + Reading + " parts per milion"
    else:
        speech = "The MQ7 sensor in the engine room is currently reading " + Reading + " parts per milion"
    return tell(speech)
Exemple #27
0
def end_game(game):
    """Ends current game of One, Two, Cow."""

    speech_options = [
        "Ok, no problem! Thanks for playing One, Two Cow!",
        "Sure thing! Thanks for playing One, Two Cow!"
    ]
    return tell(choice(speech_options))
Exemple #28
0
def get_recipes_by_ingredients(ingredients, participants):
    print("with ingredients")
    recipes = SpoonacularUtils.get_recipes_by_ingridients(
        ingredients, RECIPES_TO_PULL)
    if len(recipes) == 0:
        context_manager.clear_all()
        return tell(recipe_not_exist("with {} ".format(','.join(ingredients))))
    return handle_recipes(recipes, participants, ingredients[0])
Exemple #29
0
def unlink_telegram_account():
    user = build.get_user()
    user.unlink_telegram()
    speech = f"""\
    Your account is now unlinked
    You can always re-link at {current_app.config['FRONTEND_URL']}
    """
    return tell(dedent(speech))
Exemple #30
0
def quit():
    speech = "Leaving ghost machine. See ya, sucker."
    #reset values upon quitting
    global interrupt_counter
    global frustration_level
    frustration_level = 0
    interrupt_counter = 0
    return tell(speech)
    def talk(self):
        round = len(self.players[0].history) + 1
        opp = self.players[0].name
        turns = self.turns

        if opp == '$\phi$':
            opp = 'phi'
        elif opp == '$\pi$':
            opp = 'pi'
        elif opp == '$e$':
            opp = 'e'

        if round == 1:
            msg = ask("Starting a {} round match between you and {}.  Round 1, would you like to cooperate or defect?".format(turns, opp))
        elif round > 1 and round < turns:
            move, opp_move = self._last_round_moves()
            msg = ask("In round {}, you played {}, {} played {}.  Round {}, would you like to cooperate or defect?".format(round - 1, move, opp, opp_move, round))
        elif round == turns:
            move, opp_move = self._last_round_moves()
            msg = ask("In round {}, you played {}, {} played {}. Final round, would you like to cooperate or defect?".format(round - 1, move, opp, opp_move))
        elif round > turns:
            self.result = list(zip(self.players[0].history, self.players[1].history))
            score = self.final_score()
            winner = self.winner()

            if winner == False:
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning the match is a draw.".format(score[1], opp, score[0]))
            elif str(winner) == '$\phi$':
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning phi is the winner. Better luck next time.".format(score[1], opp, score[0]))
            elif str(winner) == '$\pi$':
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning pi is the winner. Better luck next time.".format(score[1], opp, score[0]))
            elif str(winner) == '$e$':
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning e is the winner. Better luck next time.".format(score[1], opp, score[0]))
            elif str(winner) == 'you: you':
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning you are the winner.".format(score[1], opp, score[0]))
            else:
                msg = tell("End of the match, you scored {}, and {} scored {}, meaning {} is the winner. Better luck next time.".format(score[1], opp, score[0], winner))

        return msg
def bye():
    bye_msg = "Guys, this isn't the user we're looking for. You can go about your business. Move along... move along."
    return tell(bye_msg)