<jupyter_start><jupyter_text>Slackbot Small demo to show how to post a message to the OpenGrid Slack Channel  Imports and config<jupyter_code>from opengrid_dev.library.slack import Slack
from opengrid_dev import config<jupyter_output><empty_output><jupyter_text>Get URL from config file<jupyter_code>config = config.Config()
slack_url = config.get('Slack', 'webhook')<jupyter_output><empty_output><jupyter_text>Create Slackbot These settings are all optional<jupyter_code>username = 'DemoBot'
channel = "junk" # we don't want to clutter up everything
emoji = ':jack_o_lantern:'<jupyter_output><empty_output><jupyter_text>Create the actual communication object<jupyter_code>slack = Slack(url=slack_url, username=username, channel=channel, emoji=emoji)<jupyter_output><empty_output><jupyter_text>Post simple string messages Now create a message and post it<jupyter_code>message = "Hello from the demo notebook"
slack.post_text(message)<jupyter_output><empty_output><jupyter_text>You can also post multiple strings, which will be printed on separate lines<jupyter_code>slack.post_text('Hello', 'this', 'is', 'a', 'multiline', 'post')<jupyter_output><empty_output><jupyter_text>Post complex JSONs Read all about it on https://api.slack.com/docs/messages<jupyter_code>json_message = {
    "text": "This is the title text of the message",
    "attachments": [
        {
            "title": "This is a title",
            "text": """This is the main text block of the attachment. It will collapse the text if it is longer than 700 characters or 5 lines
            
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
            Aenean commodo ligula eget dolor. Aenean massa.
            Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
            Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem.
            Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu.
            In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.
            Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi.
            Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim.
            Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet.
            Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi.
            Nam eget dui.
            """,
            "fallback": "You need this little text, it is displayed in the pop-up messages and notifications",
            "color": "danger", # this will create a red line
            "fields": [
                {
                    "title": "Field 1",
                    "value": "This is a short field",
                    "short": True
                },
                {
                    "title": "Field 2",
                    "value": "This is another short field",
                    "short": True
                },
                {
                    "title": "Field 3",
                    "value": "This is a long field, it will take the full width of the screen",
                    "short": False
                }
            ]
        }
    ]
}
slack.post_json(json_message)<jupyter_output><empty_output><jupyter_text>Post a message with buttons<jupyter_code>button_message = {
    "text": "This is a test message with buttons.",
    "attachments": [
        {
            "text": "Do you want to press a button?",
            "fallback": "There are no buttons to press",
            "callback_id": "button_test",
            "color": "#3AA3E3",
            "attachment_type": "default",
            "actions": [
                {
                    "name": "neutral",
                    "text": "Neutral button",
                    "type": "button",
                    "value": "neutral"
                },
                {
                    "name": "danger",
                    "text": "Dangerous button",
                    "style": "danger",
                    "type": "button",
                    "value": "danger",
                    "confirm": {
                        "title": "Are you sure?",
                        "text": "Really?",
                        "ok_text": "Yes",
                        "dismiss_text": "No"
                    }
                }
            ]
        }
    ]
}
slack.post_json(button_message)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09515495416848538, 'fraction_numerical': 0.002182453077258839, 'mean_word_length': 2.051264980026631, 'pattern_counts': {'":': 38, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '517253', 'license': 'Apache-2.0', 'n_tokens_mistral': 1388, 'n_tokens_neox': 1315, 'n_words': 398, 'path': 'opengrid_dev/notebooks/Demo/Demo_Slackbot.ipynb', 'repo_name': 'opengridcc/opengrid_dev', 'size': '4582'}