Skip to content

Instantly share code, notes, and snippets.

@jg75
Last active March 16, 2016 14:23
Show Gist options
  • Save jg75/2e47546f2817816a5df1 to your computer and use it in GitHub Desktop.
Save jg75/2e47546f2817816a5df1 to your computer and use it in GitHub Desktop.
import slacker
if __name__ == '__main__':
token = '<your token>'
slack = slacker.Slacker(token)
username = 'Do Stuff Bot'
channel = '#notifications'
text = "This is a message."
attachments = [{
"fallback": "Somebody did something somewhere.",
"color": "good",
"pretext": "somebody did something",
"author_name": "somedude",
"text": "http://somewhere.example.com",
"fields": [{
"title": "Important Thing",
"value": "Whosawhamuchit",
"short": True
}, {
"title": "Value",
"value": "9000+",
"short": True
}]
}]
slack.chat.post_message(
channel,
text,
attachments=attachments,
username=username
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment