Rejigger message hooks;

This commit is contained in:
Benjamin Bouvier 2017-08-30 00:17:46 +02:00
parent daeb29868a
commit 7229764f18
1 changed files with 13 additions and 9 deletions

View File

@ -72,7 +72,7 @@ if (config.lstu) {
var handlers = {
push: function(body, say) {
var user = body.user_name;
var user = body.user_username;
var projectName = body.project.name;
var commits = body.commits;
@ -95,22 +95,26 @@ var handlers = {
var action = 'created';
if (body.after === '0000000000000000000000000000000000000000')
action = 'deleted';
msg = projectName + ': ' + user + ' ' + action + ' branch ' + branchName;
msg = user + ' ' + action + ' branch ' + branchName + ' on ' + projectName + '.';
say(msg);
} else {
var maybeS = numCommits === 1 ? '' : 's';
var lastCommit = commits[commits.length - 1];
var lastCommitMessage = lastCommit.message.trim().split('\n')[0].trim();
shortenURL(lastCommit.url, function(shortUrl) {
msg = 'push on ' + projectName + '@' + branchName + ' (by ' + user + '): ' +
commits.length + ' commit' + maybeS + ' (last: ' + lastCommitMessage + ') ' + shortUrl;
msg = user ' pushed on ' + projectName + '@' + branchName + ': ';
if (numCommits === 1) {
msg += lastCommitMessage + ' ' + shortUrl;
} else {
msg += commits.length + ' commits (last: ' + lastCommitMessage + ') ' + shortUrl;
}
say(msg);
});
}
},
issue: function(body, say) {
var user = body.user.name;
var user = body.user.username;
var projectName = body.project.name;
var issue = body.object_attributes;
@ -124,13 +128,13 @@ var handlers = {
return;
shortenURL(url, function(shortUrl) {
var msg = projectName + ': issue #' + issueNumber + ' ("' + issueTitle + '") changed state ("' + issueState + '") ' + shortUrl;
var msg = user + ' ' + issue.action + 'd issue #' + issueNumber + ' ("' + issueTitle + '") on ' + projectName + ' ' + shortUrl;
say(msg);
});
},
merge_request: function(body, say) {
var user = body.user.name;
var user = body.user.username;
var request = body.object_attributes;
@ -150,8 +154,8 @@ var handlers = {
}
shortenURL(url, function(shortUrl) {
var msg = projectName + ': MR# ' + id + ' (' + from + '->' + to + ': ' + title + ') ' +
' has been ' + state + '; ' + shortUrl;
var msg = user + ' ' + request.action + ' MR !' + id + ' (' + from + '->' + to + ': ' + title + ') ' +
' on ' + projectName + '; ' + shortUrl;
say(msg);
});
},