2016-12-31 22:10:20 +00:00
|
|
|
var request = require('request');
|
2016-12-31 05:49:12 +00:00
|
|
|
var app = require('../app.js');
|
|
|
|
var logger = require('../logging.js');
|
|
|
|
|
2016-12-31 22:02:04 +00:00
|
|
|
var regex = /[^\<]\#\d+[^\>]/;
|
2016-12-31 05:49:12 +00:00
|
|
|
|
|
|
|
exports.trigger = function(message) {
|
|
|
|
return regex.test(message.content);
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.execute = function(message) {
|
2016-12-31 22:10:20 +00:00
|
|
|
let match = regex.exec(message.content);
|
2016-12-31 05:49:12 +00:00
|
|
|
if (match) {
|
2016-12-31 22:16:08 +00:00
|
|
|
let url = `https://github.com/citra-emu/citra/pull/${match[0].trim().substring(1)}`
|
|
|
|
logger.info(url);
|
2016-12-31 22:10:20 +00:00
|
|
|
request(url, function (error, response, body) {
|
|
|
|
if (!error && response.statusCode == 200) {
|
|
|
|
message.channel.sendMessage(`Github Pull Request: ${url}`);
|
|
|
|
} else {
|
|
|
|
// Github PR does not exist.
|
|
|
|
}
|
|
|
|
});
|
2016-12-31 05:49:12 +00:00
|
|
|
}
|
|
|
|
}
|