Giter VIP home page Giter VIP logo

botheaven's Introduction

Bot Heaven

Bot farm of SLACK.

Heaven is higher than a cloud.

Code Climate Build Status Coverage Status

Deploy

Install

This is rails application.

  • System Required
    • Ruby (>2.0.0)
    • Bundler

1. Deploy bot heaven.

2. Set Environments.

SLACK_TEAM_ID=[your team id]
SLACK_APP_ID=[your app id]
SLACK_APP_SECRET=[your app secret]
SLACK_BOT_NAME=[your bot name]
SLACK_BOT_TOKEN=[your bot token]
SECRET_KEY_BASE=[any string]
RAILS_SERVE_STATIC_FILES=1 # If you use heroku.

3. Install Gems.

bundle install --path vendor/bundle

4. Migrate Database.

bundle exec rake db:migrate RAILS_ENV=production

5. Run

bundle exec rails s -e production

Bot API

Alarm API

regist

// Set alarm.
// @param [String]  alarm_name Name of alarm.
// @param [String]  callback   Name of callback.
// @param [Integer] minutes    Minutes.
// @param [Boolean] repeat     Enabled repeat.
api.alarm.regist(alarm_name, callback, minutes, repeat)

// Example
api.alarm.regist("name", "onAlarm", 1, false)

remove

// Remove alarm.
// @param [String]  alarm_name Name of alarm.
api.alarm.remove(alarm_name)

// Example
api.alarm.remove("name")

all

// Example
api.alarm.all()

clear

// Example
api.alarm.clear()

HTTP API

GET

// Get request.
// @param [String]  url      URL
// @param [Hash]    params   Parameters.
// @param [String]  callback Name of callback function.
api.http.get(url, params, callback)

// Example
api.http.get("http://www.google.co.jp/", {}, "onReceive");

POST

// Post request.
// @param [String]  url      URL
// @param [Hash]    params   Parameters.
// @param [String]  callback Name of callback function.
api.http.post(url, params, callback)

// Example
api.http.post("http://www.google.co.jp/", {}, "onReceive");

Slack API

Talk

// Talk
// @param [String] message Message
api.slack.talk(message)

// Example
api.slack.talk("Hello!")

Talk with icon

// Talk with icon
// @param [String] message    Message
// @param [String] icon_emoji Emoji Icon.
api.slack.talk_with_icon(message, icon_emoji)

// Example
api.slack.talk_with_icon("Hello!", "tofu_on_fire")

Storage API

Set value

// Set value.
// @param [String] key   Key
// @param [String] value Value
api.storage[key] = value

// Example
api.storage['name'] = 'alfa'

Get value

// Get value.
// @param [String] key   Key
api.storage[key]

// Example
api.storage['name']

Get keys.

// Example
api.storage.keys()

Clear all.

// Example
api.storage.clear()

Bot Webhook

A bot can hook a request of http://{yourhost}/bots/{bot_id}/hook.

Example

Code

function onHook(method, params) {
  slack.api.talk(params['message'])
}

Request

GET /bots/1/hook?message=hello!

In this case, A Bot will say hello!.

Licence

This project is released under the MIT license.

botheaven's People

Contributors

alfa-jpn avatar sue445 avatar yonex avatar

Watchers

James Cloos avatar  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.