Skip to content

Commit

Permalink
Merge pull request thelounge#12 from thelounge/pms
Browse files Browse the repository at this point in the history
minor enhancements + support PMs
  • Loading branch information
Max Leiter committed Jul 28, 2017
2 parents 052d6af + 7302393 commit bb47f15
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -33,7 +33,7 @@ bot.on("close", function() {

bot.on("message", function(event) {
if (!event.from_server) {
util.log("<" + event.nick + ">" + ": " + event.message);
util.log(event.target + ": " + "<" + event.nick + ">" + ": " + event.message);
if (event.message.indexOf("whois") === 0) {
bot.whois(event.message.split(" ")[1]);
}
Expand Down
15 changes: 11 additions & 4 deletions modules/github.js
Expand Up @@ -3,9 +3,16 @@ const helper = require("./github_helpers");
var commands = function(bot, options, action) {
let message = action.message.split(" ");
let query;
let target = action.target;

if (message.length < 1) {
return;
}

if (action.target === bot.user.nick) {
target = action.nick;
}

if (action.message.startsWith(options.commandPrefix) || action.message.startsWith(options.botName)) {
if (message[0] === "!github" || message[0] === "!gh") {
message.shift(); // remove the command
Expand Down Expand Up @@ -40,13 +47,13 @@ var commands = function(bot, options, action) {
// if it's returned as a Promise
if (typeof query.then === "function") {
query.then(function(m) {
return bot.say(action.target, m);
return bot.say(target, m);
});
} else {
bot.say(action.target, query);
bot.say(target, query);
}
} else {
bot.say(action.target, "No result found for query");
bot.say(target, "No result found for query");
}
}
}
Expand All @@ -61,7 +68,7 @@ var commands = function(bot, options, action) {
issue: issueNumber
});
query.then(function(m) {
return bot.say(action.target, m);
return bot.say(target, m);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion modules/github_helpers.js
Expand Up @@ -3,7 +3,7 @@ const {format} = require("util");
const fetch = require("node-fetch");
fetch.Promise = require("bluebird");
const config = require("../config");
const c = require('irc-colors');
const c = require("irc-colors");

function stringIsPositiveInteger(string) {
var number = Number(string);
Expand Down

0 comments on commit bb47f15

Please sign in to comment.