Skip to content

Commit

Permalink
Update from bot
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaykul committed Sep 16, 2017
1 parent e9638f8 commit b36a7e4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
20 changes: 17 additions & 3 deletions lib/bot.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,10 @@ var Bot = function (config) {
Bot.prototype._handleErrors = function () {
var self = this;
this.client.addListener('error', function (message) {
self.logger.error(message);
var channel = message.args[1];
var error_message = mapPronouns(message.args[2]);
self.ircSpeak(channel, 'I don\'t feel so well because ' + error_message);
// var error_message = mapPronouns(message.args[2]);
self.ircSpeak(channel, 'I don\'t feel so well because ' + message);
});

// TODO: deal with slack-side errors
Expand Down Expand Up @@ -184,6 +185,9 @@ Bot.prototype.listen = function () {
if (message.user === self.config.username) {
return;
}
if(message.user === self.config.blacklist) {
return;
}
if(message.getChannelType() === 'DM') {
return;
}
Expand Down Expand Up @@ -217,6 +221,11 @@ Bot.prototype.listen = function () {
if(self.config.users){
from = self._usermap.nicks[from] || from
}
if(self.config.blacklist){
if(from === self.config.blacklist){
return;
}
}
to = self.channels.irc[to.toLowerCase()]
if(to){
self.slackSpeak(to, message, from)
Expand All @@ -232,6 +241,11 @@ Bot.prototype.listen = function () {
if(self.config.users){
from = self._usermap.nicks[from] || from
}
if(self.config.blacklist){
if(from === self.config.blacklist){
return;
}
}
to = self.channels.irc[to.toLowerCase()]
if(to){
self.slackSpeak(to, message, from)
Expand All @@ -249,7 +263,7 @@ Bot.prototype.ircSpeak = function (channel, message, username) {
var self = this

// insert a zero-width non-joiner character to prevent name-highlighting on IRC
if(!self.config.highlight) {
if(username && !self.config.highlight) {
username = username.replace(/^(.)/, '$1\u200C')
}
username = "<" + username + "> "
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"underscore": "^1.7.0",
"irc": "~0.3.6",
"irc": "~0.5",
"slack-client": "~1.3.1",
"log": "~1.4.0",
"html-entities": "~1.1.2"
Expand Down

0 comments on commit b36a7e4

Please sign in to comment.