2016-12-31 17:10:20 -05:00
|
|
|
var request = require('request');
|
2016-12-31 00:49:12 -05:00
|
|
|
var app = require('../app.js');
|
|
|
|
var logger = require('../logging.js');
|
|
|
|
|
2017-03-25 21:46:08 -04:00
|
|
|
var regex = /[^\<\\]\#(\d+)/ig;
|
2016-12-31 00:49:12 -05:00
|
|
|
|
|
|
|
exports.trigger = function(message) {
|
2017-03-25 21:46:08 -04:00
|
|
|
return new RegExp(regex).test(message.content);
|
2016-12-31 00:49:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
exports.execute = function(message) {
|
2017-03-25 21:46:08 -04:00
|
|
|
let matcher = new RegExp(regex);
|
|
|
|
let match = matcher.exec(message.content);
|
|
|
|
let matched = [];
|
|
|
|
|
|
|
|
while(match != null) {
|
|
|
|
if(matched.indexOf(match[1]) == -1) {
|
|
|
|
matched.push(match[1]);
|
|
|
|
} else {
|
|
|
|
match = matcher.exec(message.content);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-08-02 19:23:07 -04:00
|
|
|
// We do not want to automatically match old issues / PRs.
|
|
|
|
// This usually happens when someone messes up pining another person or
|
|
|
|
// in general conversation.
|
|
|
|
// ex: You're #1!
|
|
|
|
if (match[1] <= 2000) { return; }
|
|
|
|
|
2017-03-25 21:46:08 -04:00
|
|
|
let url = `https://github.com/citra-emu/citra/pull/${match[1]}`;
|
2016-12-31 17:10:20 -05:00
|
|
|
request(url, function (error, response, body) {
|
|
|
|
if (!error && response.statusCode == 200) {
|
|
|
|
message.channel.sendMessage(`Github Pull Request: ${url}`);
|
|
|
|
}
|
|
|
|
});
|
2017-03-25 21:46:08 -04:00
|
|
|
|
|
|
|
match = matcher.exec(message.content);
|
2016-12-31 00:49:12 -05:00
|
|
|
}
|
|
|
|
}
|