Git Product home page Git Product logo

honey's Introduction

Build Status

Honey

A neat Slack bot for Pythonistas

Dependencies

Python 3.4+

redis, slackclient.

$pip install -r requirements.txt

Usage

If you are using Python 2.x use 0.0.3

Like Django, you can config your bot by editing settings.py

set SLACK_TOKEN variable in settings.py. if REDIS_URL is not setted, all Redis relevant features, like redis_brain, will be disabled.

한국어 튜토리얼

Congiure your bot

  1. install dependencies
  2. Add your bot for your slack account at Custom Integration Page
  3. Copy API Token to clipboard.
  4. Open settings.py
  5. Set SLACK_TOKEN. You can set REDIS_URL if it's available.
  6. Run $python robot.py. Python 3.5.3+ is required.
  7. Invite your bot to the channel /invite @YOUR_BOT_NAME

👹 2nd step is important because RTM is working only with legacy bot.

Play with it on the Slack

Type command with Command Prefix (default is ! ) on the channel where the bot is on.

Honey is going to respond to your command kindly.

YOU: !help

Honey: Hello world!!

Apps

We call each function that you plugged-in to the Honey, the app.

Built-in and example apps are in the apps directory.

App and Command

Below is basic form of app. This just says Hello world!! to the channel when user typed the command, !hi.

from .decorators import on_command

@on_command(['hi', 'hello', '하이', 'ㅎㅇ'])
def hello_world(robot, channel, user, tokens):
    '''
        Simple app just says `Hello word!!`

        @params {object} robot - Honey bot instance
        @params {str} channel - channel name where invoked this app
        @params {str} user - user id who invoked this app
        @params {list} tokens - user input tokens
        @returns {str, str} - channel name, message
    '''
    return channel, 'Hello world!!'

And Honey supports multiple commands for each function.

The above app can be invoked the command with Command Prefix (default is !) on the channel. It would be !hello, !hi, !하이 or !ㅎㅇ

Tokenizer

Honey automatically split your message into tokens by whitespaces.

Let's assume that you typed !memo remember this with blow app.

@on_command(['memo'])
def remember(robot, channel, user, tokens):
    assert 2 == len(tokens)
    assert 'remember' == tokens[0]
    assert 'this' == tokens[1]
    return channel, tokens[1]

You may want tokens containing whitespaces. In that case, wrap your token with double quote(") like

!memo remember "kill -9 $(ps aux | grep gunicorn | grep -v 'grep' | awk '{print $2 }')"

Redis Brain

Honey supports semi-permanent storage using Redis as well as Hubot.

The full usage code is on apps/redis_brain. If you want to use the feature, just add redis_brain to APPS variable at your settings.py

Let's assume that you typed !memo whats this in your channel with below app.

after that, whenever you type !memo whats Honey will says this to the channel.

if you forgot what you memoized, just type !memo. Honey let you know what she memoized before.

Register your app

  1. Add your app and put it into apps folder
  2. open settings.py and add your app name(like hello_world) to APPS
  3. restart your bot

honey's People

Contributors

haandol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

honey's Issues

gevent dependency

I had to install gevent, redis and slackclient before running robot.py.
It would be nice to add a comment on read.me about this.
Thanks!

Convert codes to python3

python2 is going to be ended its support by Jan 1st 2020.
convert codes to python3 and use asyncio instead of gevent.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.