Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@ function Bot(options) {
this.attachListeners();
}

Bot.prototype.sendRawToSlack = function(obj){
var slackChannelName = this.invertedMapping[obj.args[0]];
if (slackChannelName) {
var slackChannel = this.slack.getChannelGroupOrDMByName(slackChannelName);

if (!slackChannel) {
logger.info(
'Tried to send a message to a channel the bot isn\'t in: ' + slackChannelName
);
return;
}

var msg = obj.args[1];
if (! msg) {
return;
}

var message = {
text: obj.args[1].replace(/ACTION/, obj.nick),
username: obj.nick,
parse: 'full',
icon_url: 'http://api.adorable.io/avatars/48/' + obj.nick + '.png'
};

logger.debug('Sending message to Slack', message);
console.log(message);
slackChannel.postMessage(message);
}
}

Bot.prototype.sendToSlack = function(author, channel, text) {
var slackChannelName = this.invertedMapping[channel];
if (slackChannelName) {
Expand Down Expand Up @@ -89,6 +119,8 @@ Bot.prototype.attachListeners = function() {
}.bind(this));

this.ircClient.on('message', this.sendToSlack.bind(this));

this.ircClient.on('raw', this.sendRawToSlack.bind(this));

this.ircClient.on('invite', function(channel, from, message) {
logger.debug('Received invite:', channel, from, message);
Expand Down