我想使用fbchat接收消息。这是行不通的 。该代码有什么问题?

时间:2019-12-03 06:31:11

标签: python

我想使用 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()

任何帮助将不胜感激。

0 个答案:

没有答案