Add basic message spying on issue/mr ids;
This commit is contained in:
parent
33c6458c97
commit
7d5dd45e86
@ -8,6 +8,8 @@ module.exports = {
|
|||||||
'somebody': ['push', 'merge_request', 'issue', 'build']
|
'somebody': ['push', 'merge_request', 'issue', 'build']
|
||||||
},
|
},
|
||||||
|
|
||||||
|
projectUrl: "https://framagit.org/bnjbvr/kresus/",
|
||||||
|
|
||||||
// IRC nick/names for the bot
|
// IRC nick/names for the bot
|
||||||
nick: 'gitlab-bot',
|
nick: 'gitlab-bot',
|
||||||
userName: 'gitlab-bot',
|
userName: 'gitlab-bot',
|
||||||
|
25
index.js
25
index.js
@ -5,6 +5,7 @@ var request = require('request');
|
|||||||
|
|
||||||
var config = require('./config');
|
var config = require('./config');
|
||||||
|
|
||||||
|
// Bind recipients to notifications.
|
||||||
var channels = [];
|
var channels = [];
|
||||||
var hookToChannel = {};
|
var hookToChannel = {};
|
||||||
for (var who in config.reports) {
|
for (var who in config.reports) {
|
||||||
@ -18,6 +19,15 @@ for (var who in config.reports) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sanitize projectUrl
|
||||||
|
if (typeof config.projectUrl !== 'undefined') {
|
||||||
|
var url = '' + config.projectUrl;
|
||||||
|
if (url[url.length - 1] !== '/') {
|
||||||
|
url += '/';
|
||||||
|
}
|
||||||
|
config.projectUrl = url;
|
||||||
|
}
|
||||||
|
|
||||||
var client = new irc.Client(config.server, config.nick, {
|
var client = new irc.Client(config.server, config.nick, {
|
||||||
debug: config.debug || false,
|
debug: config.debug || false,
|
||||||
channels: channels,
|
channels: channels,
|
||||||
@ -204,4 +214,19 @@ app.post('/', function(req, res) {
|
|||||||
|
|
||||||
app.listen(config.port, config.hostname, function() {
|
app.listen(config.port, config.hostname, function() {
|
||||||
console.log('gitlab-to-irc running.');
|
console.log('gitlab-to-irc running.');
|
||||||
|
|
||||||
|
var issueRegexp = /#(\d+)/g;
|
||||||
|
var mergeRequestRegexp = /!(\d+)/g;
|
||||||
|
client.on('message', function(from, chan, message) {
|
||||||
|
var matches = null;
|
||||||
|
while ((matches = issueRegexp.exec(message)) !== null) {
|
||||||
|
var issueId = matches[1];
|
||||||
|
client.say(chan, "Issue #" + issueId + ": " + config.projectUrl + 'issues/' + issueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((matches = mergeRequestRegexp.exec(message)) !== null) {
|
||||||
|
var mrId = matches[1];
|
||||||
|
client.say(chan, "Merge request !" + mrId + ": " + config.projectUrl + 'merge_requests/' + mrId);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user