繁体   English   中英

FBChat和python无法发送简单消息

[英]FBChat and python can't send a simple message

所以我试图用 fbchat 给自己发送一条消息,每次我都会出错。

回溯(最近一次调用最后一次):

文件“main.py”,第 12 行,在

client.send(Message(text=msg, thread_id="christopher.batey", thread_type=ThreadType.USER))

TypeError: init () 得到了一个意外的关键字参数“thread_id”

我要拔头发了。 我从 fbchat 文档中获取 ThreadType 并且无法解决此错误。

我的代码如下所示:

from fbchat import Client

from fbchat.models import *

client = Client(my_user, my_pass)

name = "christopher.batey"

friends = client.searchForUsers(name)

friend = friends[0]

uid = friend.uid

msg = "This is a test"

sent = client.send(msg, thread_id=uid, thread_type=ThreadType.USER)

根据您的错误代码,我假设您的代码实际上是这样的:

from fbchat import Client
from fbchat.models import *

client = Client(my_user, my_pass)

name = "christopher.batey"

friends = client.searchForUsers(name)
friend = friends[0]
uid = friend.uid

msg = "This is a test"

sent = client.send(Message(text=msg, thread_id="christopher.batey", thread_type=ThreadType.USER))

最后一部分看起来像是将thread_idthread_type参数放在 Message 类中,而实际上它们是client.send()函数的参数。 它应该看起来像这样:

sent = client.send(Message(text=msg), thread_id="christopher.batey", thread_type=ThreadType.USER)

希望这能回答你的问题!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM