Skip to content

Commit

Permalink
Merge pull request nandub#106 from audaxion/ignore_users
Browse files Browse the repository at this point in the history
Add support for ignoring users
  • Loading branch information
jgable committed Feb 8, 2014
2 parents 0ff5cc5 + ee2aff8 commit eb71d35
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/irc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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}"
Expand All @@ -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}"
Expand All @@ -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

Expand Down

0 comments on commit eb71d35

Please sign in to comment.