- begin
- [core_commands, plugin_commands].each { |pl|
- # We do it this way to skip creating spurious keys
- # FIXME use fetch?
- k = m.plugin.to_sym
- if pl.has_key?(k)
- p = pl[k][:botmodule]
- a = pl[k][:auth]
- else
- p = nil
- a = nil
- end
- if p
- # TODO This should probably be checked elsewhere
- debug "Checking auth ..."
- if @bot.auth.allow?(a, m.source, m.replyto)
- debug "Checking response ..."
- if p.respond_to?("privmsg")
- begin
- debug "#{p.botmodule_class} #{p.name} responds"
- p.privmsg(m)
- rescue Exception => err
- error report_error("#{p.botmodule_class} #{p.name} privmsg() failed:", err)
- raise if err.class <= BDB::Fatal
- end
- debug "Successfully delegated privmsg with key #{m.plugin}"
- return true
- else
- debug "#{p.botmodule_class} #{p.name} is registered, but it doesn't respond to privmsgs"
- end
- else
- debug "#{p.botmodule_class} #{p.name} is registered, but #{m.source} isn't allowed to use #{m.plugin} on #{m.replyto}"
+ k = m.plugin.to_sym
+ if commands.has_key?(k)
+ p = commands[k][:botmodule]
+ a = commands[k][:auth]
+ # We check here for things that don't check themselves
+ # (e.g. mapped things)
+ # debug "Checking auth ..."
+ if a.nil? || @bot.auth.allow?(a, m.source, m.replyto)
+ # debug "Checking response ..."
+ if p.respond_to?("privmsg")
+ begin
+ # debug "#{p.botmodule_class} #{p.name} responds"
+ p.privmsg(m)
+ rescue Exception => err
+ raise if err.kind_of?(SystemExit)
+ error report_error("#{p.botmodule_class} #{p.name} privmsg() failed:", err)
+ raise if err.kind_of?(BDB::Fatal)