mirror of
https://github.com/yuzu-emu/Command-fix.git
synced 2024-11-22 16:05:36 +01:00
Implement some GitHub related improvements (#28)
This commit is contained in:
parent
fa3be4a7e7
commit
369d01bcb9
12
env.json
12
env.json
@ -31,6 +31,14 @@
|
|||||||
},
|
},
|
||||||
"DATA_CUSTOM_RESPONSES": {
|
"DATA_CUSTOM_RESPONSES": {
|
||||||
"required": false,
|
"required": false,
|
||||||
"description": "Whether or not to load responses.js from the data directory."
|
"description": "Whether or not to load responses.js from the data directory."
|
||||||
|
},
|
||||||
|
"GITHUB_REPOSITORY": {
|
||||||
|
"required": false,
|
||||||
|
"description": "The github repository that should be tracked (format is user/repository)"
|
||||||
|
},
|
||||||
|
"GITHUB_OLD_THRESHOLD": {
|
||||||
|
"required": false,
|
||||||
|
"description": "Issues below this treshold should be ignored"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
src/commands/status.js
Normal file
31
src/commands/status.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
const request = require('request');
|
||||||
|
const logger = require('../logging.js');
|
||||||
|
|
||||||
|
exports.roles = ['Admins', 'Moderators', 'Developers'];
|
||||||
|
exports.command = function (message) {
|
||||||
|
let pr = message.content.substr(message.content.indexOf(' ') + 1).replace(/\n/g, '');
|
||||||
|
|
||||||
|
let repo = process.env.GITHUB_REPOSITORY || "citra-emu/citra";
|
||||||
|
let url = `https://api.github.com/repos/${repo}/pulls/${pr}`;
|
||||||
|
|
||||||
|
request({ url: url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)'}}, function (error, response, body) {
|
||||||
|
if (!error) {
|
||||||
|
var pr = JSON.parse(body);
|
||||||
|
request({ url: pr.statuses_url, headers: { 'User-Agent': 'Citra-Emu/CitraBot (Node.js)'}}, function(error, response, body)
|
||||||
|
{
|
||||||
|
var statuses = JSON.parse(body);
|
||||||
|
|
||||||
|
if (statuses.length == 0) return;
|
||||||
|
|
||||||
|
// Travis CI will give you multiple, identical target URLs so we might as well just check the first one...
|
||||||
|
var status = statuses[0];
|
||||||
|
status.target_url = status.target_url.substr(0, status.target_url.indexOf('?'));
|
||||||
|
message.channel.sendMessage(`${status.context}: ${status.target_url}: **${status.state}**`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.channel.sendMessage('No such PR.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
@ -10,6 +10,8 @@ exports.execute = function (message) {
|
|||||||
let matcher = new RegExp(regex);
|
let matcher = new RegExp(regex);
|
||||||
let match = matcher.exec(message.content);
|
let match = matcher.exec(message.content);
|
||||||
let matched = [];
|
let matched = [];
|
||||||
|
let threshold = process.env.GITHUB_OLD_THRESHOLD || 2000;
|
||||||
|
let repo = process.env.GITHUB_REPOSITORY || "citra-emu/citra";
|
||||||
|
|
||||||
while (match != null) {
|
while (match != null) {
|
||||||
if (matched.indexOf(match[1]) === -1) {
|
if (matched.indexOf(match[1]) === -1) {
|
||||||
@ -23,12 +25,12 @@ exports.execute = function (message) {
|
|||||||
// This usually happens when someone messes up pinging another person or
|
// This usually happens when someone messes up pinging another person or
|
||||||
// in general conversation.
|
// in general conversation.
|
||||||
// ex: You're #1!
|
// ex: You're #1!
|
||||||
if (match[1] <= 2000) { return; }
|
if (match[1] < threshold) { return; }
|
||||||
|
|
||||||
// Map domain path to type
|
// Map domain path to type
|
||||||
let map = {'pull': 'Pull Request', 'issues': 'Issue'};
|
let map = {'pull': 'Pull Request', 'issues': 'Issue'};
|
||||||
|
|
||||||
let url = `https://github.com/citra-emu/citra/pull/${match[1]}`;
|
let url = `https://github.com/${repo}/pull/${match[1]}`;
|
||||||
request(url, function (error, response, body) {
|
request(url, function (error, response, body) {
|
||||||
if (!error && response.statusCode === 200) {
|
if (!error && response.statusCode === 200) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user