Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
app
 
 
bin
 
 
 
 
db
 
 
lib
 
 
log
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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

register

// 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.register(alarm_name, callback, minutes, repeat)

// Example
api.alarm.register("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
// @param [Hash] options Message
api.slack.talk(message, options = {})

// Example
api.slack.talk("Hello!")
api.slack.talk("with options", {
  name: 'my_bot',
  icon: ':my_icon:'
})

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()

Setting API

Get bot name

api.setting.name

Get bot default icon

api.setting.icon

Get joined channel

api.setting.channel

Get creator name

api.setting.user

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.

You can’t perform that action at this time.