简体   繁体   中英

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. 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

Intended output:

To use @here & @channel as 'mentions',

they are marked as :

<!here> & <!channel>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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