【发布时间】:2018-12-10 19:15:00
【问题描述】:
我正在使用 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 向机器人发送消息时收到错误。
【问题讨论】:
标签: python python-3.x flask bots messenger