Skip to content

Slackish help developers convert python functions to slack bot commands

Notifications You must be signed in to change notification settings

Alaanali/slackish

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Slackish

Slackish is small library that lets you convert your simple python functions into running slack bots.

sample_bot.py

from slackclient import SlackClient
from slackish import Slackish, Command

@Command
def publish(campaign, on='rtx'):
    """Publish command for publishing campaigns
    *Usage*
    `publish campaign <campaign_id> on <traffic source>`
    """
    Slackish.send("I'll publish campaign {} on {}".format(campaign, on))

@Command
def standup(task, status):
    """Standup command for updating task status
    *Usage*
    `standup task <task_id> status <some status>`
    """
    Slackish.send("I'll update my status regarding task: {}".format(task))
    Slackish.send("Task is currently at status: {}".format(status))


config = {}
config['BOT_ID'] = None
config['RTM_READ_DELAY'] = 1
config['SLACK_BOT_TOKEN'] = 'SOME-TOKEN'
config['SLACK_MENTION_REGEX'] = "^(<@(|[WU].+?)>)?(.*)"
my_bot = Slackish(SlackClient, Command.registry, **config)
my_bot.serve()

Configure the token


Open your slack channel
Select bots

Create your app

Get the access tokens and connect it to your code

config['SLACK_BOT_TOKEN'] = 'Add Your access API Token'

And run the bot

virtualenv .venv
source .venv/bin/activate
pip install -r requirements.txt
python sample_bot.py

Not sure what to tell your bot? Don't worry Slackish generate help messages based on the docstring!

About

Slackish help developers convert python functions to slack bot commands

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%