summaryrefslogtreecommitdiff
path: root/data/rbot
diff options
context:
space:
mode:
Diffstat (limited to 'data/rbot')
-rw-r--r--data/rbot/plugins/bans.rb35
1 files changed, 18 insertions, 17 deletions
diff --git a/data/rbot/plugins/bans.rb b/data/rbot/plugins/bans.rb
index b77146b8..f80dd70f 100644
--- a/data/rbot/plugins/bans.rb
+++ b/data/rbot/plugins/bans.rb
@@ -142,29 +142,14 @@ class BansPlugin < Plugin
def message(m)
return unless m.channel
- mm = m.plainmessage.irc_downcase(m.server.casemap).split(/[\s\.,:]/)
- nicks_said = (m.channel.users.map { |u| u.downcase} & mm).size
- return unless nicks_said > 0 # not really needed, but saves some cycles
- got_nicks = 0
- masshl_action = nil
- @registry[:masshl].each { |masshl|
- next unless masshl.channel == m.channel.downcase or masshl.channel == "all"
- needed = [masshl.num.to_i, (masshl.perc * m.channel.user_nicks.size / 100).to_i].max
- next if needed > nicks_said or needed < got_nicks
- masshl_action = masshl
- got_nicks = needed
- }
- return unless masshl_action
- do_cmd masshl_action.action.intern, m.sourcenick, m.channel, masshl_action.timer, masshl_action.reason
- end
- def listen(m)
- return unless m.respond_to?(:public?) and m.public?
+ # check the whitelist first
@registry[:whitelist].each { |white|
next unless ['all', m.target.downcase].include?(white.channel)
return if m.source.matches?(white.host)
}
+ # check the badwords next
@registry[:badwords].each { |badword|
next unless ['all', m.target.downcase].include?(badword.channel)
next unless badword.regexp.match(m.plainmessage)
@@ -173,6 +158,22 @@ class BansPlugin < Plugin
do_cmd(badword.action.to_sym, m.source.nick, m.target, badword.timer, badword.reason)
return
}
+
+ # and finally, see if the user triggered masshl
+ mm = m.plainmessage.irc_downcase(m.server.casemap).split(/[\s\.,:]/)
+ nicks_said = (m.channel.users.map { |u| u.downcase} & mm).size
+ return unless nicks_said > 0 # not really needed, but saves some cycles
+ got_nicks = 0
+ masshl_action = nil
+ @registry[:masshl].each { |masshl|
+ next unless masshl.channel == m.channel.downcase or masshl.channel == "all"
+ needed = [masshl.num.to_i, (masshl.perc * m.channel.user_nicks.size / 100).to_i].max
+ next if needed > nicks_said or needed < got_nicks
+ masshl_action = masshl
+ got_nicks = needed
+ }
+ return unless masshl_action
+ do_cmd masshl_action.action.intern, m.sourcenick, m.channel, masshl_action.timer, masshl_action.reason
end
def join(m)