omerxx / slapybot

A CHAT-OPS python chat bot for Slack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyPI Build Status

A CHAT-OPS python chat bot for Slack based on lins05/slackbot. Slapybot uses thisbejim/Pyrebase for firebase integration, and handles smalltalk using API.AI with the help of its python sdk

Features

  • ChatOps ready - with deployment system, locking mechanism and more
  • Weather, news, wiki, gifs and many more queries
  • Small talk questions and answers with API.AI integration

Installation

pip install -r requirements.txt

Usage

Create firebase configuration

  1. Go to your firebase project url (https://console.firebase.google.com/project/)
  2. Overview > Project Settings > Service Accounts (tab) > GENERATE NEW PRIVATE KEY
  3. Download the json file and save it in your project (Make sure to add it to .gitignore file!!!)

Create firebase configuration

  1. Create firebase.py in /plugins directory

Generate the slack api token

First you need to get the slack api token for your bot. You have two options:

  1. Create a bot for your team
  2. If you use a real slack user, you can generate an api token on slack web api page.

Configure the bot

  1. Create a slackbot_settings.py and a run.py in your own instance of slackbot.
Configure the api token

Then you need to configure the API_TOKEN in a python module slackbot_settings.py, which must be located in a python import path. This will be automatically imported by the bot.

slackbot_settings.py:

API_TOKEN = "<your-api-token>"

Alternatively, you can use the environment variable SLACKBOT_API_TOKEN.

Run the bot
python run.py
Configure the default answer

Add a DEFAULT_REPLY to slackbot_settings.py:

DEFAULT_REPLY = "Sorry but I didn't understand you"
Configure the docs answer

The message attribute passed to your custom plugins has an special function message.docs_reply() that will parse all the plugins available and return the Docs in each of them.

Configure the plugins

Add your plugin modules to a PLUGINS list in slackbot_settings.py:

PLUGINS = [
    'slackbot.plugins',
    'mybot.plugins',
]

Now you can talk to your bot in your slack client!

Try it out:

@<BOT-NAME> wiki
@<BOT-NAME> random gif
@<BOT-NAME> <SOME-WORD> me
@<BOT-NAME> Whats the weather in london?
@<BOT-NAME> Get 2 news from CNN
@<BOT-NAME> Get news sources
@<BOT-NAME> deploy <SERVICE>
@<BOT-NAME> lock <SERVICE>
@<BOT-NAME> list locks
@<BOT-NAME> list services
@<BOT-NAME> add service <SERVICE-NAME>
@<BOT-NAME> unlock <SERVICE>
@<BOT-NAME> unlock all

And some easter eggs:

@<BOT-NAME> Do you know what does the fox say?
@<BOT-NAME> Who is donald trump?
@<BOT-NAME> What is the meaning of life?
@<BOT-NAME> How many woods would a wood chuck chuck

About

A CHAT-OPS python chat bot for Slack

License:MIT License


Languages

Language:Python 98.4%Language:Shell 1.6%