Skip to main content

Structured Slack bot framework.

Project description

Slaccato

Structured Slack bot framework

Installation

$ pip install slaccato

Example

General Usage

import slaccato

# Write a new method
class TestMethod(slaccato.SlackMethod):
    @property
    def execution_words(self):
        return ['테스트', 'test', 'ping']

    @property
    def help_text(self):
        return '*{}*: You can test me!'.format('/'.join(self.execution_words))

    def response(self, channel, user_command, request_user):
        response = 'Oh, {}! here I am!!!'.format(request_user)
        return channel, response
    
slack_bot = slaccato.SlackBot(
    slack_bot_token='SLACK_BOT_TOKEN',
    slack_bot_name='SLACK_BOT_NAME',
    std_out_path='/path/to/MY_LOG_FILE.log',
    std_err_path='/path/to/MY_ERR_FILE.log')

slack_bot.add_method(TestMethod)
slack_bot.run()

Test screenshot

Message Customization

Please see Slack API documentations

import slaccato

# Write a new method
class TestMethod(slaccato.SlackMethod):
    @property
    def execution_words(self):
        return ['테스트', 'test', 'ping']

    @property
    def help_text(self):
        return '*{}*: You can test me!'.format('/'.join(self.execution_words))

    def response(self, channel, user_command, request_user):
        response = [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "Danny Torrence left the following review for your property:"
                }
            },
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "<https://example.com|Overlook Hotel> \n :star: \n Doors had too many axe holes, guest in room " +
                    "237 was far too rowdy, whole place felt stuck in the 1920s."
                },
                "accessory": {
                    "type": "image",
                    "image_url": "https://images.pexels.com/photos/750319/pexels-photo-750319.jpeg",
                    "alt_text": "Haunted hotel image"
                }
            },
            {
                "type": "section",
                "fields": [
                    {
                        "type": "mrkdwn",
                        "text": "*Average Rating*\n1.0"
                    }
                ]
            }
        ]
        return channel, response

Test screenshot

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for slaccato, version 0.1.10
Filename, size File type Python version Upload date Hashes
Filename, size slaccato-0.1.10.tar.gz (6.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page