下準備
- botkit
> npm init
> npm install botkit --save
- opal
> gem install opal
ソース
- app.rb
require 'opal'
require 'native'
`const Botkit = require('botkit');`
token="[APIトークン]"
controller = Native(`Botkit.slackbot()`)
controller.spawn({ "token" => token }).startRTM do |err|
if err
exit
end
end
controller.hears('hi', ['direct_message', 'direct_mention', 'mention'], Proc.new do |bot, msg|
Native(`bot`).reply(msg, 'hi')
end)
~
実行
> opal -c app.rb > app.js
> node app.js