Created
February 24, 2016 04:27
-
-
Save mactkg/e4a2aa40969fe90c509c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var botkit = require('botkit') | |
var hello = require('./hello') // 同じディレクトリにあるスクリプト | |
// scripts以下に入れて,こうでもいい | |
// var hello = require('./scripts/hello') | |
if (!process.env.SLACKBOT2_TOKEN) { | |
console.log('Error: Specify token in environment') | |
process.exit(1) | |
} | |
var controller = botkit.slackbot({ | |
debug: true, | |
log: true | |
}) | |
controller.spawn({ | |
token: process.env.SLACKBOT2_TOKEN | |
}).startRTM((err) => { | |
if (err) { | |
throw new Error(err) | |
} | |
}) | |
script.register(controller) // ここで登録 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var register = (bot) => { | |
bot.hears(['hi', 'hello'], | |
'direct_message,direct_mention,mention', | |
(bot, message) => { | |
bot.reply(message, 'hello!']) | |
}) | |
} | |
module.exports = { | |
register: register | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment