我想使用 fbchat 接收消息。它不起作用:它只写“正在侦听...”,当我从另一个帐户向我的帐户发送任何消息时,它不会使它成为已读或打印的用户信息,但不会显示任何错误。
该代码有什么问题?
from fbchat import Client, log
from fbchat.models import *
class tony(Client):
def onMessage(self, author_id=None, message_object=None, thread_id=None, thread_type=ThreadType.USER, **kwargs):
# Mark message as read
self.markAsRead(author_id)
# Print info on console
log.info("Message {} from {} in {}".format(message_object, thread_id, thread_type))
# Message Text
msgText = message_object.text
print(msgText)
client.send(Message(text="hi"), thread_id=thread_id, thread_type=ThreadType.USER)
# Create an object of our class, enter your email and password for facebook.
client = tony("my_email", "my_pass")
# Listen for new message
client.listen()
任何帮助将不胜感激。