Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ability to send 'attachment' #15

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aneisch
Copy link

@aneisch aneisch commented Apr 28, 2015

Allows for sending attachments to a channel following guidlines at https://api.slack.com/docs/attachments.

Interact with it in a similar way to sending a message:

message = '''[
        {
            "fallback": "Required plain-text summary of the attachment.",

            "color": "#36a64f",

            "pretext": "Optional text that appears above the attachment block",

            "author_name": "Bobby Tables",
            "author_link": "http://flickr.com/bobby/",
            "author_icon": "http://flickr.com/icons/bobby.jpg",

            "title": "Slack API Documentation",
            "title_link": "https://api.slack.com/",

            "text": "Optional text that appears within the attachment",

            "fields": [
                {
                    "title": "Priority",
                    "value": "High",
                    "short": false
                }
            ],

            "image_url": "http://my-website.com/path/to/image.jpg"
        }
    ]'''

def post_attachment(recipient, message):
   client = SlackClient('TOKEN')
   client.chat_post_attachment(recipient, message, username='BotName', icon_emoji=":cop:")

post_attachment('#Channel',message)

aneisch added 2 commits April 28, 2015 11:03
Allows for sending attachments to a channel following guidlines at https://api.slack.com/docs/attachments.

Interact with it in a similar way to sending a message:

message = '''[
        {
            "fallback": "Required plain-text summary of the attachment.",

            "color": "#36a64f",

            "pretext": "Optional text that appears above the attachment block",

            "author_name": "Bobby Tables",
            "author_link": "http://flickr.com/bobby/",
            "author_icon": "http://flickr.com/icons/bobby.jpg",

            "title": "Slack API Documentation",
            "title_link": "https://api.slack.com/",

            "text": "Optional text that appears within the attachment",

            "fields": [
                {
                    "title": "Priority",
                    "value": "High",
                    "short": false
                }
            ],

            "image_url": "http://my-website.com/path/to/image.jpg"
        }
    ]'''

def post_attachment(recipient, message):
   client = SlackClient('TOKEN')
   client.chat_post_attachment(recipient, message, username='BotName', icon_emoji=":cop:")

post_attachment('#Channel',message)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant