0
目前我有一個Python腳本發送一條消息給slack。我想添加額外的鏈接,但不知道如何。這是我現在的代碼。Python - 在Slack API中添加鏈接
def post_slack():
"""Post slack message."""
try:
token = 'xoxp-67503713541-67496795984-216701772021-c23bdfbe9635f1f63a4c802697147dfc'
slack = Slacker(token)
obj = slack.chat.post_message(
channel='#dataworksapp',
as_user= 'false',
username = 'DataWorksBot',
attachments=[
{
"color": "033E96",
"title": "Pressure Transducer Weekly Information",
"title_link": "https://console.cloud.google.com/storage/browser/firebase_results/?project=dataworks-356fa",
"author_name": "Master Table",
"author_link": "https://bigquery.cloud.google.com/table/dataworks-356fa:FirebaseArchive.PT_MasterTable?tab=preview",
"text": "https://bigquery.cloud.google.com/table/dataworks-356fa:FirebaseArchive.PT_MasterTable?tab=preview",
"fields": [
{
"title": "Amount Used:",
"value": "countPTserial1",
"short": 'true'
},{
"title": "Distinct Device ID's:",
"value": "countPTid1",
"short": 'true'
},{
"title": "Total Connection Time (hr):",
"value": "sumPTct2",
"short": 'true'
}
]
我一直沒有找到任何類似於「author_link」的其他字段類別,我可以設置爲等於鏈接。我可以設置"text"
等於鏈接,但如果我這樣做,我寧願將鏈接看作一個單詞,而不是整個醜聞鏈接在郵件中發送。
此外,我不能設置鏈接等於一個變量,然後設置"text"
等於該變量。當我這樣做的時候仍然顯示出整個環節。謝謝您的幫助!
我用了你的第一個建議,它完美地工作。謝謝! –