我正在使用 fbmq 为 python 上的 Messenger 制作一个简单的机器人,可以处理快速问题。
当用户在我的工作时间之外向我的 Facebook 页面发短信时,我让机器人发送消息。
working_hours = [12,13,14,15,16]
if messaging_event.get('message') and (now.hour no in working_hours):
page.send(sender_id, "Sorry we are closed!"
由于人们通常在不止一条消息中表达他们想要的东西,因此他们的聊天中充斥着“我们已关闭消息!”
我不太喜欢那个,因为我想给用户一个机会留言,以便我明天回答。
你知道我可以用什么方法让机器人发送“我们关门了!” 用户每发送 5 条消息?
我试过这个:
count = 0
if (count / 3 == 1):
page.send(sender_id, "Sorry we are closed!")
count = 0
if messaging_event.get('message') and (now.hour no in working_hours):
count += 1
但它没有用。如果您有任何想法,我怎么能意识到我会非常感激:)
// 我尝试了一个while循环。
for messaging_event in messaging:
sender_id = messaging_event['sender']['id']
recipient_id = messaging_event['recipient']['id']
messaging_event.get('postback'):
messaging_event.get('message'):
while (now.hour not in working_hours):
count = 0
if (count/3 == 1):
page.send(sender_id, "Hello")
if messaging_event.get('message'):
count += 1
但它没有用。Facebook 向机器人发送消息时收到错误消息。