簡體   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