Skip to content

Commit ad94ede

Browse files
committed
First pass at ignoring users by configuration
1 parent 0ff5cc5 commit ad94ede

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/irc.coffee

+14
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class IrcBot extends Adapter
136136
realName: process.env.HUBOT_IRC_REALNAME
137137
port: process.env.HUBOT_IRC_PORT
138138
rooms: process.env.HUBOT_IRC_ROOMS.split(",")
139+
ignoreUsers: process.env.HUBOT_IRC_IGNORE_USERS?.split(",")
139140
server: process.env.HUBOT_IRC_SERVER
140141
password: process.env.HUBOT_IRC_PASSWORD
141142
nickpass: process.env.HUBOT_IRC_NICKSERV_PASSWORD
@@ -201,6 +202,10 @@ class IrcBot extends Adapter
201202
# this is a private message, let the 'pm' listener handle it
202203
return
203204

205+
if from in ignoreUsers
206+
# we'll ignore this message if it's from someone we want to ignore
207+
return
208+
204209
console.log "From #{from} to #{to}: #{message}"
205210

206211
user = self.createUser to, from
@@ -215,6 +220,11 @@ class IrcBot extends Adapter
215220

216221
bot.addListener 'action', (from, to, message) ->
217222
console.log " * From #{from} to #{to}: #{message}"
223+
224+
if from in ignoreUsers
225+
# we'll ignore this message if it's from someone we want to ignore
226+
return
227+
218228
user = self.createUser to, from
219229
if user.room
220230
console.log "#{to} * #{from} #{message}"
@@ -232,6 +242,10 @@ class IrcBot extends Adapter
232242
if process.env.HUBOT_IRC_PRIVATE
233243
return
234244

245+
if nick in ignoreUsers
246+
# we'll ignore this message if it's from someone we want to ignore
247+
return
248+
235249
nameLength = options.nick.length
236250
if message.slice(0, nameLength).toLowerCase() != options.nick.toLowerCase()
237251
message = "#{options.nick} #{message}"

0 commit comments

Comments
 (0)