コード例 #1
0
    def render_GET(self, request):
        # Choose a time delay to respond and the insult
        delay = random.choice((0, 1, 2, 3, 4, 5))
        insult = get_insult()

        # Register a callback to write to the request stream and close
        d = deferLater(reactor, delay, lambda: request)
        d.addCallback(self._response_and_close, insult)

        # Return a token to ask the client to keep polling / keep alive.
        return NOT_DONE_YET
コード例 #2
0
def get_insult_response(intent, session):
    """ An example of a custom intent. Same structure as welcome message, just make sure to add this intent
    in your alexa skill in order for it to work.
    """
    print("SESSION BELOW")
    print(session)
    session_attributes = {'insult_state': 1}
    card_title = "Insult"
    speech_output = "That's not very nice. I don't want to."
    reprompt_text = "I would rather not do that."

    if session.get('attributes',
                   {}) and session['attributes']['insult_state'] == 1:
        insult = get_insult()
        speech_output = intent['slots']['name']['value'] + " is a " + insult
        reprompt_text = "I said he is a " + insult

    should_end_session = False
    return build_response(
        session_attributes,
        build_speechlet_response(card_title, speech_output, reprompt_text,
                                 should_end_session))
コード例 #3
0
ファイル: birbs_bot.py プロジェクト: Zoidster/BirbBot
 def insult(self, update: Update, context: CallbackContext):
     insult = get_insult()
     print('Sending insult to ' + update.message.from_user.name + ' - ' +
           insult)
     context.bot.send_message(chat_id=update.message.chat_id,
                              text=f'{insult}')