为什么客户。听在fbchat不能再工作了?

2024-05-28 19:15:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我想做一个聊天机器人,会自动回复。它将收集来自客户。听然后决定回复用户。在

from fbchat import log, Client

# Subclass fbchat.Client and override required methods
class EchoBot(Client):
   def onMessage(self, author_id, message_object, thread_id, thread_type, **kwargs):
       self.markAsDelivered(thread_id, message_object.uid)
       self.markAsRead(thread_id)

       log.info("{} from {} in {}".format(message_object, thread_id, thread_type.name))

       # If you're not the author, echo
       if author_id != self.uid:
           self.send(message_object, thread_id=thread_id, thread_type=thread_type)


client = EchoBot("myaccount", "mypassword")
client.listen()

到今天为止一切正常。 即使它收到消息程序仍然会被卡住客户。听在

我收到的输出是 正在登录我的帐户。。。 登录myAccount成功。 听。。。在

当我试图联系我的帐户,它仍然不会给我答复,但它只是卡住了客户。听 我想得到的输出是它将从客户。听()给我答复。在


Tags: fromselfclientlogidmessageuid客户
1条回答
网友
1楼 · 发布于 2024-05-28 19:15:28

我相信facebook已经改变了fbchat库从中获取数据的网站结构(id,classes…)(请记住fbchat不是一个官方的facebook库)。任何非官方API都可能发生这种情况。我已经托管了我的机器人24/7,突然它停止工作。你的代码完全正确。从我目前为止测试的情况来看,EchoBot类停止使用它的所有事件侦听器,但另一方面,您仍然可以使用client.send(...)发送消息,我们只能希望fbchat库的开发人员尽快解决这个问题。 更多信息请参见此处:https://github.com/carpedm20/fbchat/issues/483

相关问题 更多 >

    热门问题