Command-fix/triggers/github.js

24 lines
645 B
JavaScript
Raw Normal View History

var request = require('request');
2016-12-31 06:49:12 +01:00
var app = require('../app.js');
var logger = require('../logging.js');
var regex = /[^\<]\#\d+[^\>]/;
2016-12-31 06:49:12 +01:00
exports.trigger = function(message) {
return regex.test(message.content);
}
exports.execute = function(message) {
let match = regex.exec(message.content);
2016-12-31 06:49:12 +01:00
if (match) {
let url = `https://github.com/citra-emu/citra/pull/${match[0].substring(1).trim()}`
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 06:49:12 +01:00
}
}