Last active
December 20, 2018 01:27
-
-
Save potato4d/cb3f181d6ab64a8ca7ad0068e4730b83 to your computer and use it in GitHub Desktop.
Botkitを利用してSlack上の発言からGitHubのIssueを作成するBotを作る ref: https://qiita.com/potato4d/items/81e9e8aef6cd57c234af
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
{ | |
"title": "Issueの題名", | |
"body" : "IssueのDesciption" | |
} |
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
const Botkit = require("botkit"); | |
const bot = Botkit.slackbot({ | |
debug: false | |
}); | |
bot.spawn("直前で取得したアクセストークンを貼り付ける").startRTM(); | |
bot.hears("(Create Issue)",["ambient","mention"], (bot, message) => { | |
bot.reply(message, message.text.split("\n")[0]); | |
}); |
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
request({ | |
url:"http://user@token:api.github.com/repos/:user/:reponame/issues" | |
method: "POST", | |
json: true, | |
headers: { | |
"Content-Type":"application/json", | |
"User-Agent": "UA(必須)" | |
}, | |
}, (err, res)=>{ | |
if(err){ | |
console.log(err); | |
return false; | |
} | |
return res; | |
}); |
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
$ npm i -S botkit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment