Giter Club home page Giter Club logo

hongmoa's Introduction

Build Status

Hongmoa

A neat Slack bot for Pythonistas

Dependencies

requires gevent, redis, slackclient.

$pip install -r requirements.txt

Usage

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

set your SLACK_TOKEN and REDIS_URL in settings.py. if REDIS_URL does not set, all REDIS relevant features will be ignored.

Congiure your bot

  1. Add your bot for your slack account at Custom Integration Page
  2. open settings.py
  3. set SLACK_TOKEN. You can set REDIS_URL if it's available.
  4. run $python robot.py

Play with it on the Slack

Type command with COMMAND_PREFIX (e.g. ! ) on the channel where the bot is on.

Bot is going to respond to your commands if your bot is on the channel where you type the command.

!help
!hi

Apps

Example apps are in the apps directory.

Command

Hongmoa supports multiple commands for a function

@on_command(['하이', 'hi', 'hello'])
def hello_world(robot, channel, user, tokens):
    return 'Hello world!!'

then type your command with COMMAND_PREFIX (e.g. !) on the channel that including bot like !hi or !hello or !하이

Tokenizer

Hongmoa automatically split your message into tokens by whitespaces

Let's assume that you typed !memo recall this in your channel

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

Sometimes you want tokens containing whitespaces, in that case, wrap your token with double quote(") like

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

Redis Brain

Hongmoa supports semi-permanent storage using redis as well as Hubot.

Let's assume that you typed !memo recall this in your channel

@on_command(['ㄱㅇ', '기억', 'memo'])
def redis_brain(robot, channel, user, tokens):
    assert 2 == len(tokens)
    key = tokens[0]
    value = tokens[1]
    robot.brain.set(key, value)

    return robot.brain.get(key)

then, Hongmoa would say this to the channel

Register your app

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

hongmoa's People

Contributors

haandol avatar

Watchers

James Cloos avatar shinhokang avatar

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.