简体   繁体   English

我如何获得一个通过 Python 发送消息以发布 @here 并 ping 通道的 slack 机器人?

[英]How do I get a slack bot that is sending a message via Python to post @here and ping the channel?

Currently my slack app / bot will post a message being sent via Python that has @here or @channel in the text but the @here or @channel won't be highlighted or actually ping the channel.目前,我的 slack 应用程序/机器人将发布通过 Python 发送的消息,该消息在文本中包含 @here 或 @channel,但不会突出显示 @here 或 @channel,也不会实际 ping 通道。 Here is the code:这是代码:

import slack
def slack_notif(slackchannel,message):
        client = slack.WebClient(token='xxxmytokenxxx')
        client.chat_postMessage(channel=slackchannel, text=message)
slack_notif(
        slackchannel = 'mychannel',
        message = '<@here> This is a test'
        )

Output = @here This is a test输出 = @here 这是一个测试

Intended output:预期输出:

To use @here & @channel as 'mentions',要将@here@channel用作“提及”,

they are marked as :它们被标记为:

<!here> & <!channel> <!here> & <!channel>

暂无
暂无

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

相关问题 使用python将json消息发布到松弛通道 - post json message to slack channel using python 如何使用Slack API将格式化的消息发布到通道中 - How to post formatted message into a channel with Slack API 使用 python 将文件上传到 slack 时,如何从 None KeyError: [SLACK_BOT_TOKEN_HERE]` 解决 `raise KeyError(key)`? - How do I resolve `raise KeyError(key) from None KeyError: [SLACK_BOT_TOKEN_HERE]` while uploading file to slack using python? 如何向 Python 中的 Slack 频道发送消息 - How to send message to a Slack channel in Python 如何通过没有渠道的闲聊机器人向几个人发送消息? - How to message several people with a slack bot without a channel? 如何使用 selenium 制作 python 机器人来检查电报频道何时收到新消息? - How do I make a python bot with selenium that checks when a new message has arrived from a Telegram channel? 如何使用 Discord 机器人从 channel.history 获取消息内容? - How do I get message contents from channel.history using a Discord bot? 如何将整数与机器人读取的不和谐通道中的消息进行比较? - How do I compare an integer with a message in a discord channel read by a bot? Slack Bot Python:如何知道接收到的消息是在组消息中还是在直接消息中 - Slack bot python: How to know if received message was in a group or a direct message 用 Python 编写 Discord 机器人 - 如何让机器人 ping @everyone? - Programming a Discord bot in Python- How do I make the bot ping @everyone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM