繁体   English   中英

使用Python在频道上向用户发送Slack消息

[英]Send a Slack message to a user on a channel using Python

我正在将Slack实时消息传递API与Python结合使用,并希望使用@像@hellobot这样,将消息发送给频道上的用户,创建一个目录test2002。

给定的代码不起作用:

slack_client.api_call("chat.postMessage", channel='#bot',text="create directory test2002",username='ecstesting1989')

如果我使用:

slack_client.api_call("chat.postMessage", channel='#bot',text="@hellobot create directory test2002",username='ecstesting1989')

这将以文本格式将命令作为@hellobot create directory test2002发送,并且不起作用。

使用<!channel>

另外,检查一下

我已经在这里 json作为

 {
   "text": "Hello <!channel|>"
 }

你会得到

 Hello @channel 

暂无
暂无

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

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