summaryrefslogtreecommitdiff
path: root/lib/rbot/core
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-12 22:31:15 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-09-12 22:31:15 +0000
commit6f5528a63b44e610a3d25d7fe583399163d7d2da (patch)
tree0db7c1642d40bd68a85338f4cdbb87a03f5e7747 /lib/rbot/core
parent8efdfd2651a720e0dc1681e716d0a23b0429e4fd (diff)
namespaces: move rbot-specific classes and modules from Irc::* to Irc::Bot::*
Diffstat (limited to 'lib/rbot/core')
-rw-r--r--lib/rbot/core/auth.rb9
-rw-r--r--lib/rbot/core/config.rb8
-rw-r--r--lib/rbot/core/remote.rb12
-rw-r--r--lib/rbot/core/utils/httputil.rb22
-rw-r--r--lib/rbot/core/utils/utils.rb2
5 files changed, 30 insertions, 23 deletions
diff --git a/lib/rbot/core/auth.rb b/lib/rbot/core/auth.rb
index 97429041..c6c55aff 100644
--- a/lib/rbot/core/auth.rb
+++ b/lib/rbot/core/auth.rb
@@ -11,6 +11,15 @@ class AuthModule < CoreBotModule
def initialize
super
+
+ # The namespace migration causes each Irc::Auth::PermissionSet to be
+ # unrecoverable, and we have to rename their class name to
+ # Irc::Bot::Auth::PermissionSet
+ @registry.recovery = Proc.new { |val|
+ patched = val.sub("o:\035Irc::Auth::PermissionSet", "o:\042Irc::Bot::Auth::PermissionSet")
+ Marshal.restore(patched)
+ }
+
load_array(:default, true)
debug "initialized auth. Botusers: #{@bot.auth.save_array.pretty_inspect}"
end
diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb
index 717408a2..d929fb39 100644
--- a/lib/rbot/core/config.rb
+++ b/lib/rbot/core/config.rb
@@ -107,7 +107,7 @@ class ConfigModule < CoreBotModule
m.reply _("no such config key %{key}") % {:key => key}
return
end
- unless @bot.config.items[key].kind_of?(BotConfigArrayValue)
+ unless @bot.config.items[key].kind_of?(Config::ArrayValue)
m.reply _("config key %{key} is not an array") % {:key => key}
return
end
@@ -130,7 +130,7 @@ class ConfigModule < CoreBotModule
m.reply _("no such config key %{key}") % {:key => key}
return
end
- unless @bot.config.items[key].kind_of?(BotConfigArrayValue)
+ unless @bot.config.items[key].kind_of?(Config::ArrayValue)
m.reply _("config key %{key} is not an array") % {:key => key}
return
end
@@ -240,7 +240,7 @@ conf.map 'config list :module',
:auth_path => 'show'
# TODO this one is presently a security risk, since the bot
# stores the master password in the config. Do we need auth levels
-# on the BotConfig keys too?
+# on the Bot::Config keys too?
conf.map 'config get :key',
:action => 'handle_get',
:auth_path => 'show'
@@ -299,7 +299,7 @@ conf.map 'config help :topic',
conf.default_auth('*', false)
conf.default_auth('show::status', true)
# TODO these shouldn't be set here, we need a way to let the default
-# permission be specified together with the BotConfigValue
+# permission be specified together with the ConfigValue
conf.default_auth('key', true)
conf.default_auth('key::auth::password', false)
diff --git a/lib/rbot/core/remote.rb b/lib/rbot/core/remote.rb
index 7ced878f..52cfed4e 100644
--- a/lib/rbot/core/remote.rb
+++ b/lib/rbot/core/remote.rb
@@ -15,6 +15,7 @@
require 'drb/drb'
module ::Irc
+class Bot
module Auth
@@ -192,8 +193,6 @@ module ::Irc
end
- class Bot
-
# The Irc::Bot::RemoteObject class represents and object that will take care
# of interfacing with remote clients
#
@@ -260,8 +259,6 @@ module ::Irc
end
end
- end
-
module Plugins
# We create a new Ruby module that can be included by BotModules that want to
@@ -309,22 +306,23 @@ module ::Irc
end
end
+end
class RemoteModule < CoreBotModule
include RemoteCoreBotModule
- BotConfig.register BotConfigBooleanValue.new('remote.autostart',
+ Config.register Config::BooleanValue.new('remote.autostart',
:default => true,
:requires_rescan => true,
:desc => "Whether the remote service provider should be started automatically")
- BotConfig.register BotConfigIntegerValue.new('remote.port',
+ Config.register Config::IntegerValue.new('remote.port',
:default => 7268, # that's 'rbot'
:requires_rescan => true,
:desc => "Port on which the remote interface will be presented")
- BotConfig.register BotConfigStringValue.new('remote.host',
+ Config.register Config::StringValue.new('remote.host',
:default => '',
:requires_rescan => true,
:desc => "Port on which the remote interface will be presented")
diff --git a/lib/rbot/core/utils/httputil.rb b/lib/rbot/core/utils/httputil.rb
index 11f3cb41..a621a36b 100644
--- a/lib/rbot/core/utils/httputil.rb
+++ b/lib/rbot/core/utils/httputil.rb
@@ -137,35 +137,35 @@ module Utils
# this class can check the bot proxy configuration to determine if a proxy
# needs to be used, which includes support for per-url proxy configuration.
class HttpUtil
- BotConfig.register BotConfigBooleanValue.new('http.use_proxy',
+ Bot::Config.register Bot::Config::BooleanValue.new('http.use_proxy',
:default => false, :desc => "should a proxy be used for HTTP requests?")
- BotConfig.register BotConfigStringValue.new('http.proxy_uri', :default => false,
+ Bot::Config.register Bot::Config::StringValue.new('http.proxy_uri', :default => false,
:desc => "Proxy server to use for HTTP requests (URI, e.g http://proxy.host:port)")
- BotConfig.register BotConfigStringValue.new('http.proxy_user',
+ Bot::Config.register Bot::Config::StringValue.new('http.proxy_user',
:default => nil,
:desc => "User for authenticating with the http proxy (if required)")
- BotConfig.register BotConfigStringValue.new('http.proxy_pass',
+ Bot::Config.register Bot::Config::StringValue.new('http.proxy_pass',
:default => nil,
:desc => "Password for authenticating with the http proxy (if required)")
- BotConfig.register BotConfigArrayValue.new('http.proxy_include',
+ Bot::Config.register Bot::Config::ArrayValue.new('http.proxy_include',
:default => [],
:desc => "List of regexps to check against a URI's hostname/ip to see if we should use the proxy to access this URI. All URIs are proxied by default if the proxy is set, so this is only required to re-include URIs that might have been excluded by the exclude list. e.g. exclude /.*\.foo\.com/, include bar\.foo\.com")
- BotConfig.register BotConfigArrayValue.new('http.proxy_exclude',
+ Bot::Config.register Bot::Config::ArrayValue.new('http.proxy_exclude',
:default => [],
:desc => "List of regexps to check against a URI's hostname/ip to see if we should use avoid the proxy to access this URI and access it directly")
- BotConfig.register BotConfigIntegerValue.new('http.max_redir',
+ Bot::Config.register Bot::Config::IntegerValue.new('http.max_redir',
:default => 5,
:desc => "Maximum number of redirections to be used when getting a document")
- BotConfig.register BotConfigIntegerValue.new('http.expire_time',
+ Bot::Config.register Bot::Config::IntegerValue.new('http.expire_time',
:default => 60,
:desc => "After how many minutes since last use a cached document is considered to be expired")
- BotConfig.register BotConfigIntegerValue.new('http.max_cache_time',
+ Bot::Config.register Bot::Config::IntegerValue.new('http.max_cache_time',
:default => 60*24,
:desc => "After how many minutes since first use a cached document is considered to be expired")
- BotConfig.register BotConfigIntegerValue.new('http.no_expire_cache',
+ Bot::Config.register Bot::Config::IntegerValue.new('http.no_expire_cache',
:default => false,
:desc => "Set this to true if you want the bot to never expire the cached pages")
- BotConfig.register BotConfigIntegerValue.new('http.info_bytes',
+ Bot::Config.register Bot::Config::IntegerValue.new('http.info_bytes',
:default => 8192,
:desc => "How many bytes to download from a web page to find some information. Set to 0 to let the bot download the whole page.")
diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb
index 65ba6651..a33f072f 100644
--- a/lib/rbot/core/utils/utils.rb
+++ b/lib/rbot/core/utils/utils.rb
@@ -676,4 +676,4 @@ module ::Irc
end
end
-Irc::Utils.bot = Irc::Plugins.manager.bot
+Irc::Utils.bot = Irc::Bot::Plugins.manager.bot