X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fbans.rb;h=99b664dfd91b04c641a6c30ca0d6640dd5d79d16;hb=052217de30c59206d7025b582d4604557a747470;hp=b77146b81d5a59d3f45ceba55c1c7c5d85ed0819;hpb=ad193513e4c1ca759fe461496eb1032fe34106d8;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/bans.rb b/data/rbot/plugins/bans.rb index b77146b8..99b664df 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) @@ -457,7 +458,7 @@ class BansPlugin < Plugin when /^(\d+)m$/ timer = $1.to_i * 60 when /^(\d+)h$/ - timer = $1.to_i * 60 * 60 + timer = $1.to_i * 60 * 60 when /^(\d+)d$/ timer = $1.to_i * 60 * 60 * 24 else