diff --git a/src/irc.coffee b/src/irc.coffee index 4d6a0de..1fcd55b 100644 --- a/src/irc.coffee +++ b/src/irc.coffee @@ -136,6 +136,7 @@ class IrcBot extends Adapter realName: process.env.HUBOT_IRC_REALNAME port: process.env.HUBOT_IRC_PORT rooms: process.env.HUBOT_IRC_ROOMS.split(",") + ignoreUsers: process.env.HUBOT_IRC_IGNORE_USERS?.split(",") or [] server: process.env.HUBOT_IRC_SERVER password: process.env.HUBOT_IRC_PASSWORD nickpass: process.env.HUBOT_IRC_NICKSERV_PASSWORD @@ -201,6 +202,11 @@ class IrcBot extends Adapter # this is a private message, let the 'pm' listener handle it return + if from in options.ignoreUsers + console.log('Ignoring user: %s', from) + # we'll ignore this message if it's from someone we want to ignore + return + console.log "From #{from} to #{to}: #{message}" user = self.createUser to, from @@ -215,6 +221,12 @@ class IrcBot extends Adapter bot.addListener 'action', (from, to, message) -> console.log " * From #{from} to #{to}: #{message}" + + if from in options.ignoreUsers + console.log('Ignoring user: %s', from) + # we'll ignore this message if it's from someone we want to ignore + return + user = self.createUser to, from if user.room console.log "#{to} * #{from} #{message}" @@ -232,6 +244,11 @@ class IrcBot extends Adapter if process.env.HUBOT_IRC_PRIVATE return + if nick in options.ignoreUsers + console.log('Ignoring user: %s', nick) + # we'll ignore this message if it's from someone we want to ignore + return + nameLength = options.nick.length if message.slice(0, nameLength).toLowerCase() != options.nick.toLowerCase() message = "#{options.nick} #{message}" @@ -254,6 +271,11 @@ class IrcBot extends Adapter bot.addListener 'invite', (channel, from) -> console.log('%s invited you to join %s', from, channel) + if from in options.ignoreUsers + console.log('Ignoring user: %s', from) + # we'll ignore this message if it's from someone we want to ignore + return + if not process.env.HUBOT_IRC_PRIVATE or process.env.HUBOT_IRC_IGNOREINVITE bot.join channel