X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Fcore%2Fremote.rb;h=d8d43533da3e5ab01e784b91e93b46485b2b5f45;hb=375098fcba7a60abcc871e28f66e98c403435b43;hp=8d6b0e0891e0d5e50ce7d8ab4de96d2d7e7a47fe;hpb=b45f28ad735df01d46a30d4cf711c8ec874e9b4e;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/core/remote.rb b/lib/rbot/core/remote.rb index 8d6b0e08..d8d43533 100644 --- a/lib/rbot/core/remote.rb +++ b/lib/rbot/core/remote.rb @@ -4,8 +4,6 @@ # :title: Remote service provider for rbot # # Author:: Giuseppe Bilotta (giuseppe.bilotta@gmail.com) -# Copyright:: Copyright (c) 2006 Giuseppe Bilotta -# License:: GPLv2 # # From an idea by halorgium . # @@ -138,7 +136,7 @@ class Bot raise "Botmodule #{botmodule.name} tried to unmap #{tmpl.inspect} that was handled by #{tmpl.botmodule}" unless tmpl.botmodule == botmodule.name debug "Unmapping #{tmpl.inspect}" @templates[handle] = nil - @templates.clear unless @templates.nitems > 0 + @templates.clear unless @templates.compact.size > 0 end # We redefine the handle() method from MessageMapper, taking into account @@ -149,7 +147,7 @@ class Bot # # Presently, the hash returned on success has only one key, :return, whose # value is the actual return value of the successfull dispatch. - # + # # TODO this same kind of mechanism could actually be used in MessageMapper # itself to be able to handle the case of multiple plugins having the same # 'first word' ... @@ -162,19 +160,19 @@ class Bot # Skip this element if it was unmapped next unless tmpl botmodule = @parent.plugins[tmpl.botmodule] - options, failure = tmpl.recognize(m) - if options.nil? - failures << [tmpl, failure] + options = tmpl.recognize(m) + if options.kind_of? Failure + failures << options else action = tmpl.options[:action] unless botmodule.respond_to?(action) - failures << [tmpl, "#{botmodule} does not respond to action #{action}"] + failures << NoActionFailure.new(tmpl, m) next end auth = tmpl.options[:full_auth_path] debug "checking auth for #{auth}" # We check for private permission - if m.bot.auth.allow?(auth, m.source, '?') + if m.bot.auth.permit?(m.source, auth, '?') debug "template match found and auth'd: #{action.inspect} #{options.inspect}" return :return => botmodule.send(action, m, options) end @@ -184,8 +182,8 @@ class Bot return false end end - failures.each {|f, r| - debug "#{f.inspect} => #{r}" + failures.each {|r| + debug "#{r.template.inspect} => #{r}" } debug "no handler found" return false @@ -313,7 +311,7 @@ class RemoteModule < CoreBotModule include RemoteCoreBotModule Config.register Config::BooleanValue.new('remote.autostart', - :default => true, + :default => false, :requires_rescan => true, :desc => "Whether the remote service provider should be started automatically")