Ich versuche, eine Nachricht mit Slacker python api für Slack Nachrichten posten Ich bin nicht in der Lage einen Link zu meinen Nachrichten als meinen Code unten anbringt:Hinzufügen von Attachements zu Slacker Chat-Nachricht
attachments = [title, link_to_events, "More details"]
print type(attachments) # this is a list
slack = Slacker(slack_api_token)
# Send a message to #general channel
slack.chat.post_message(slack_channel, message, attachments=attachments)
In der slacker-Code, es sieht aus wie wir für eine "Liste" Variablentyp suchen:
https://github.com/os/slacker/blob/master/slacker/init.py Linie 241:
# Ensure attachments are json encoded
if attachments:
if isinstance(attachments, list):
attachments = json.dumps(attachments)
return self.post('chat.postMessage',
data={
'channel': channel,
'text': text,
'username': username,
'as_user': as_user,
'parse': parse,
'link_names': link_names,
'attachments': attachments,
'unfurl_links': unfurl_links,
'unfurl_media': unfurl_media,
'icon_url': icon_url,
'icon_emoji': icon_emoji
})
ist die Re ein Problem mit meinem Code?
FYI: Das ist, was ich in der lockeren api Dokumentation https://api.slack.com/custom-integrations gefunden habe:
{
"text": "New Help Ticket Received:",
"attachments": [
{
"title": "App hangs on reboot",
"title_link": "http://domain.com/ticket/123456",
"text": "If I restart my computer without quitting your app, it stops the reboot sequence.\nhttp://domain.com/ticket/123456",
}
]
}
Verwendung von Slacker Version 0.9.10 –