You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've discovered that the Page.handle_message callback gets called before any function decorated with @Page.callback. I would expect that this function is called last and after other callback is executed no other callbacks are called including unless this callback returns True or something.
Here is a minimal example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
from os import getenv
from fbmq import Page, QuickReply
from flask import Flask, request
app = Flask(__name__)
page = Page(getenv('FB_PAGE_TOKEN'))
page.show_starting_button('HOLA')
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s: %(message)s',
level=logging.DEBUG)
@app.route('/webhook', methods=['GET', 'POST'])
def webhook():
if request.method == 'GET':
if request.args.get('hub.verify_token') == getenv('FB_VERIFY_TOKEN'):
return request.args.get('hub.challenge') or 'FAIL'
return 'FB_VERIFY_TOKEN does not match.'
elif request.method == 'POST':
# Maneja las solicitudes enviadas desde Facebook
if "facebookexternalhit" in request.headers.get('User-Agent'):
page.handle_webhook(request.get_data(as_text=True))
return 'OK'
@page.callback(['HOLA'])
def start_callback(payload, event):
replies = [QuickReply("Hello World!", "PAYLOAD")]
page.send(event.sender_id, "Say:", replies)
@page.callback(['PAYLOAD'])
def callback_qr_vitrina(payload, event):
print("message proceed")
@page.handle_message
def message_handler(event):
print("message was not processed?!")
The text was updated successfully, but these errors were encountered:
shackra
changed the title
Page.handle_message is called before matching function decorated with Page.callback
Page.handle_message is called before matching function decorated with Page.callback
Mar 24, 2018
See related code line in fbmq
This issue occurred because QuickReply is a type of message event. And fbmq adopts a strategy to call both callback and event handler.
You means that message handler should not activated when QuickReply callback handler defines. right? It is more intuitive way to use :)
I've discovered that the
Page.handle_message
callback gets called before any function decorated with@Page.callback
. I would expect that this function is called last and after other callback is executed no other callbacks are called including unless this callback returnsTrue
or something.Here is a minimal example:
When this example is ran, the following happens:
The text was updated successfully, but these errors were encountered: