src/funkyquizbot/app.py
def callback_answer(payload, event):
    "A callback for any ANSWER payload we get. "
    sender_id = event.sender_id
    page.typing_on(sender_id)
    prefix, metadata = decode_payload(payload)
    app.logger.debug('Got ANSWER: {} (correct? {})'.format(metadata, 'YES' if metadata['correct'] else 'NON'))
    if random.random() > 0.9: # ten percent of the time, send a gif
        giph = get_giphy('CORRECT' if metadata['correct'] else 'WRONG')
        if giph is not None:
            page.send(sender_id, Attachment.Image(giph.url))

    # TODO check how many we have correct
    if not metadata['correct']:
        # wrong answer
        menu(event, menutext=_("Ouch. Wrooooong!:poop: ... Try again!"))
    else:
        # answer is correct, you may continue
        page.send(sender_id, _("Right on!"))
        _prev = metadata['previous']
        notfinished = 7 > len(_prev)
        if notfinished:
            page.send(sender_id, _("You have {} correct questions, only {} to go!").format(len(_prev),
                                                                                        7-len(_prev)))
        quiz(event, _prev)
A callback for any ANSWER payload we get. 
A callback for any ANSWER payload we get.
A callback for any ANSWER payload we get .
def callback_answer(payload, event):
    sender_id = event.sender_id
    page.typing_on(sender_id)
    prefix, metadata = decode_payload(payload)
    app.logger.debug('Got ANSWER: {} (correct? {})'.format(metadata, 'YES' if metadata['correct'] else 'NON'))
    if random.random() > 0.9: 
        giph = get_giphy('CORRECT' if metadata['correct'] else 'WRONG')
        if giph is not None:
            page.send(sender_id, Attachment.Image(giph.url))
    if not metadata['correct']:
        menu(event, menutext=_("Ouch. Wrooooong!:poop: ... Try again!"))
    else:
        page.send(sender_id, _("Right on!"))
        _prev = metadata['previous']
        notfinished = 7 > len(_prev)
        if notfinished:
            page.send(sender_id, _("You have {} correct questions, only {} to go!").format(len(_prev),
                                                                                        7-len(_prev)))
        quiz(event, _prev)
def callback_answer ( payload , event ) : sender_id = event . sender_id page . typing_on ( sender_id ) prefix , metadata = decode_payload ( payload ) app . logger . debug ( 'Got ANSWER: {} (correct? {})' . format ( metadata , 'YES' if metadata [ 'correct' ] else 'NON' ) ) if random . random ( ) > 0.9 : giph = get_giphy ( 'CORRECT' if metadata [ 'correct' ] else 'WRONG' ) if giph is not None : page . send ( sender_id , Attachment . Image ( giph . url ) ) if not metadata [ 'correct' ] : menu ( event , menutext = _ ( "Ouch. Wrooooong!:poop: ... Try again!" ) ) else : page . send ( sender_id , _ ( "Right on!" ) ) _prev = metadata [ 'previous' ] notfinished = 7 > len ( _prev ) if notfinished : page . send ( sender_id , _ ( "You have {} correct questions, only {} to go!" ) . format ( len ( _prev ) , 7 - len ( _prev ) ) ) quiz ( event , _prev )
A callback for any ANSWER payload we get.
A callback for any ANSWER payload we get .
"A callback for any ANSWER payload we get. " # ten percent of the time, send a gif # TODO check how many we have correct # wrong answer # answer is correct, you may continue
payload
event