Last active
May 15, 2018 15:42
-
-
Save senyaitiya/93267e257815b2f5ac729f5db7e8d8bd to your computer and use it in GitHub Desktop.
This file contains 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
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
Botkit Basic Template for Heroku | |
Author: okajax (https://github.com/okajax) | |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ | |
//========================================================= | |
// Botの準備 | |
//========================================================= | |
if (!process.env.token) { | |
console.log('Error: Specify token in environment'); | |
process.exit(1); | |
} | |
var Botkit = require('botkit'); | |
var os = require('os'); | |
var controller = Botkit.slackbot({ | |
debug: true, | |
}); | |
var bot = controller.spawn({ | |
token: process.env.token | |
}).startRTM(); | |
//========================================================= | |
// 基本的な受け答え | |
//========================================================= | |
// 以下がBotkitの基本形です。 | |
// controller.hears()で、マッチした単語に応じて処理を実行します。 | |
// 第一引数 ['ほげ','ふが'] の部分には、マッチさせたい単語を入れます。正規表現も使えます。 | |
// 第二引数 'direct_message,direct_mention' の部分には、反応するパターンを入れます。 | |
// [反応パターン一覧] | |
// direct_message: ダイレクトメッセージに反応します | |
// direct_mention: 先頭に@付きで発言されたメッセージに反応します | |
// mention: @付きで言及されたメッセージに反応します | |
// ambient: どんなメッセージタイプにも反応します | |
controller.hears(['@Tsuruda', 'つる', 'ツル', 'ミズゴロウ', 'mizugorou'], 'direct_message,direct_mention,mention', function (bot, message) { | |
// bot.reply()で、botに発言をさせます。 | |
bot.reply(message, ["キュエー","ゴロー!","ゴロ!","ミズゴロー","キュキュ","ミズー" ,"ミズーッ","ゴリョー","ゴリョーッ"]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment