Skip to content

Commit eb71d35

Browse files
committed
Merge pull request nandub#106 from audaxion/ignore_users
Add support for ignoring users
2 parents 0ff5cc5 + ee2aff8 commit eb71d35

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/irc.coffee

+22
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(",") or []
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,11 @@ class IrcBot extends Adapter
201202
# this is a private message, let the 'pm' listener handle it
202203
return
203204

205+
if from in options.ignoreUsers
206+
console.log('Ignoring user: %s', from)
207+
# we'll ignore this message if it's from someone we want to ignore
208+
return
209+
204210
console.log "From #{from} to #{to}: #{message}"
205211

206212
user = self.createUser to, from
@@ -215,6 +221,12 @@ class IrcBot extends Adapter
215221

216222
bot.addListener 'action', (from, to, message) ->
217223
console.log " * From #{from} to #{to}: #{message}"
224+
225+
if from in options.ignoreUsers
226+
console.log('Ignoring user: %s', from)
227+
# we'll ignore this message if it's from someone we want to ignore
228+
return
229+
218230
user = self.createUser to, from
219231
if user.room
220232
console.log "#{to} * #{from} #{message}"
@@ -232,6 +244,11 @@ class IrcBot extends Adapter
232244
if process.env.HUBOT_IRC_PRIVATE
233245
return
234246

247+
if nick in options.ignoreUsers
248+
console.log('Ignoring user: %s', nick)
249+
# we'll ignore this message if it's from someone we want to ignore
250+
return
251+
235252
nameLength = options.nick.length
236253
if message.slice(0, nameLength).toLowerCase() != options.nick.toLowerCase()
237254
message = "#{options.nick} #{message}"
@@ -254,6 +271,11 @@ class IrcBot extends Adapter
254271
bot.addListener 'invite', (channel, from) ->
255272
console.log('%s invited you to join %s', from, channel)
256273

274+
if from in options.ignoreUsers
275+
console.log('Ignoring user: %s', from)
276+
# we'll ignore this message if it's from someone we want to ignore
277+
return
278+
257279
if not process.env.HUBOT_IRC_PRIVATE or process.env.HUBOT_IRC_IGNOREINVITE
258280
bot.join channel
259281

0 commit comments

Comments
 (0)