Skip to content

Commit

Permalink
First pass at ignoring users by configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
audaxion committed Feb 8, 2014
1 parent 0ff5cc5 commit ad94ede
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 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(",")
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,10 @@ class IrcBot extends Adapter
# this is a private message, let the 'pm' listener handle it
return

if from in ignoreUsers
# 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 +220,11 @@ class IrcBot extends Adapter

bot.addListener 'action', (from, to, message) ->
console.log " * From #{from} to #{to}: #{message}"

if from in ignoreUsers
# 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 +242,10 @@ class IrcBot extends Adapter
if process.env.HUBOT_IRC_PRIVATE
return

if nick in ignoreUsers
# 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 Down

0 comments on commit ad94ede

Please sign in to comment.