Exemplo n.º 1
0
def process_quick_reply(client_id, quick_reply):
    cli = Client.get_client(client_id)
    if cli is None:
        cli = Client.insert_client(client_id, None)

    results = IBMWatsonAPI.send_message(quick_reply, cli.context)
    __selectAPI(results, cli)
Exemplo n.º 2
0
def process_message(client_id, msg):
    cli = Client.get_client(client_id)
    if cli is None:
        cli = Client.insert_client(client_id, None)

    results = IBMWatsonAPI.send_message(msg, cli.context)
    print(results)
    __selectAPI(results, cli)
Exemplo n.º 3
0
def oauth2callback():
    state = session['state']
    client_id = session['client_id']

    flow = google_auth_oauthlib.flow.Flow.from_client_secrets_file(
        CLIENT_SECRET_FILE, scopes=SCOPES, state=state)
    flow.redirect_uri = url_for('oauth2callback', _external=True)

    authorization_response = request.url
    flow.fetch_token(authorization_response=authorization_response)

    credentials = flow.credentials
    Session.insert_session(client_id, state, credentials)

    FacebookAPI.send_message(client_id, 'You\'re logged in! 😁')
    cli = Client.get_client(client_id)
    NLP.process_message(client_id, cli.last_msg)

    return '<h1>Login succeeded.</h1><br><h3>Back to the Messenger!</h3>', 200