Python本地csv文件未通过SlackAPI正确发送到slack通道

2024-05-15 08:55:25 发布

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

我试图通过SlackAPI将本地csv文件发送到我用Python脚本创建的空闲通道。我的脚本执行,但文件作为私有文件发送,只有我能看到。我希望它在整个频道都能看到,看起来像这样:

Desired Output

我已经看到了其他类似的问题,但我仍然不能让这个代码做我所描述的。我是频道的所有者,我使用的是传统令牌。以下是我的代码:

from slackclient import SlackClient

sc = SlackClient('Token')

sc.api_call(
"files.upload",
filename='sample.csv',
channel='#secdevtest1',
username='AMI Rehydrator',
file=open('sample.csv', 'r').read()
)

Tags: 文件csvsample代码fromimport脚本token
1条回答
网友
1楼 · 发布于 2024-05-15 08:55:25

使用channels代替channel

此外,从here

By default all newly-uploaded files are private and only visible to the owner. They become public once they are shared into a public channel (which can happen at upload time via the channels argument).

相关问题 更多 >