简体   繁体   English

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

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

I am using Slack real time messaging API with Python and want to send a message to a user on a channel, using@ like @hellobot create a directory test2002. 我正在将Slack实时消息传递API与Python结合使用,并希望使用@像@hellobot这样,将消息发送给频道上的用户,创建一个目录test2002。

The given code doesn't work: 给定的代码不起作用:

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

If I use: 如果我使用:

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

This sends the command as @hellobot create directory test2002 in text format and doesn't work. 这将以文本格式将命令作为@hellobot create directory test2002发送,并且不起作用。

use < !channel > 使用<!channel>

Also , check this 另外,检查一下

I have done this here put json as 我已经在这里 json作为

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

you will get 你会得到

 Hello @channel 

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

相关问题 如何向 Python 中的 Slack 频道发送消息 - How to send message to a Slack channel in Python 使用python将json消息发布到松弛通道 - post json message to slack channel using python 我们可以使用 python 脚本在 slack 中向用户发送消息吗? - Can we send message to user in slack using python script? 无法使用 slack SocketModeHandler 从 Python 中的 slack 读取通道消息 - Cannot read channel message from slack in Python using slack SocketModeHandler 通过应用bot向松弛用户发送直接消息,但不在应用通道中发送 - send direct message to slack user from a app bot but not in app channel 通过 Slack Chat 将消息发送到 Slack 消息到 Slack 频道。发布消息 API? - Send Message to Slack Message to Slack Channel through Slack Chat.Post Message API? 如何在安装 Slack 应用程序后立即向用户发送消息并创建频道 - How to send user a message and create a channel right after installation of Slack app 如何使用Webhook和Python将错误消息发送到Slack? - How to send error message to slack using webhook and Python? 如何使用日志记录发送松弛日志作为消息在python和flask中? - How to send log using logging to slack as message in python and flask? Python - 在 Python 中发送列表介绍 Slack 消息格式 - Python - Send a list intro Slack message formatting in Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM