summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/rbot/plugins/autoop.rb2
-rw-r--r--data/rbot/plugins/autorejoin.rb2
-rw-r--r--data/rbot/plugins/bash.rb2
-rw-r--r--data/rbot/plugins/chanserv.rb2
-rw-r--r--data/rbot/plugins/debugger.rb6
-rw-r--r--data/rbot/plugins/delicious.rb8
-rw-r--r--data/rbot/plugins/dice.rb2
-rw-r--r--data/rbot/plugins/dict.rb4
-rw-r--r--data/rbot/plugins/dictclient.rb14
-rw-r--r--data/rbot/plugins/figlet.rb2
-rw-r--r--data/rbot/plugins/fish.rb4
-rw-r--r--data/rbot/plugins/fortune.rb2
-rw-r--r--data/rbot/plugins/games/quiz.rb4
-rw-r--r--data/rbot/plugins/games/roulette.rb6
-rw-r--r--data/rbot/plugins/imdb.rb10
-rw-r--r--data/rbot/plugins/keywords.rb6
-rw-r--r--data/rbot/plugins/lastfm.rb4
-rw-r--r--data/rbot/plugins/linkbot.rb4
-rw-r--r--data/rbot/plugins/nickserv.rb14
-rw-r--r--data/rbot/plugins/ri.rb2
-rw-r--r--data/rbot/plugins/rss.rb8
-rw-r--r--data/rbot/plugins/salut.rb4
-rw-r--r--data/rbot/plugins/search.rb8
-rw-r--r--data/rbot/plugins/translator.rb4
-rw-r--r--data/rbot/plugins/unicode.rb4
-rw-r--r--data/rbot/plugins/url.rb12
-rwxr-xr-xlaunch_here.rb2
-rw-r--r--lib/rbot/botuser.rb32
-rw-r--r--lib/rbot/config.rb73
-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
-rw-r--r--lib/rbot/ircbot.rb64
-rw-r--r--lib/rbot/language.rb6
-rw-r--r--lib/rbot/load-gettext.rb2
-rw-r--r--lib/rbot/message.rb35
-rw-r--r--lib/rbot/messagemapper.rb2
-rw-r--r--lib/rbot/plugins.rb18
-rw-r--r--lib/rbot/rbotconfig.rb2
-rw-r--r--lib/rbot/registry.rb16
42 files changed, 239 insertions, 206 deletions
diff --git a/data/rbot/plugins/autoop.rb b/data/rbot/plugins/autoop.rb
index 212da27b..303e3d3f 100644
--- a/data/rbot/plugins/autoop.rb
+++ b/data/rbot/plugins/autoop.rb
@@ -1,5 +1,5 @@
class AutoOP < Plugin
- BotConfig.register BotConfigBooleanValue.new('autoop.on_nick',
+ Config.register Config::BooleanValue.new('autoop.on_nick',
:default => true,
:desc => "Determines if the bot should auto-op when someone changes nick and the new nick matches a listed netmask")
diff --git a/data/rbot/plugins/autorejoin.rb b/data/rbot/plugins/autorejoin.rb
index fde8827c..14a2f29c 100644
--- a/data/rbot/plugins/autorejoin.rb
+++ b/data/rbot/plugins/autorejoin.rb
@@ -1,5 +1,5 @@
class AutoRejoinPlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('rejoin.insult',
+ Config.register Config::BooleanValue.new('rejoin.insult',
:default => true,
:desc => "Determines if the bot will insult whoever kicked it, after rejoin")
diff --git a/data/rbot/plugins/bash.rb b/data/rbot/plugins/bash.rb
index cb33a4d4..0524204a 100644
--- a/data/rbot/plugins/bash.rb
+++ b/data/rbot/plugins/bash.rb
@@ -57,7 +57,7 @@ end
class BashPlugin < Plugin
- BotConfig.register BotConfigEnumValue.new('bash.access',
+ Config.register Config::EnumValue.new('bash.access',
:values => ['xml', 'html'], :default => 'html',
:desc => "Which method the bot should use to access bash.org quotes: xml files or standard webpages")
diff --git a/data/rbot/plugins/chanserv.rb b/data/rbot/plugins/chanserv.rb
index c3e99207..7dcd1f3f 100644
--- a/data/rbot/plugins/chanserv.rb
+++ b/data/rbot/plugins/chanserv.rb
@@ -15,7 +15,7 @@
class ChanServPlugin < Plugin
- BotConfig.register BotConfigStringValue.new('chanserv.name',
+ Config.register Config::StringValue.new('chanserv.name',
:default => "chanserv", :requires_restart => false,
:desc => "Name of the chan server (all lowercase)")
diff --git a/data/rbot/plugins/debugger.rb b/data/rbot/plugins/debugger.rb
index fe000324..c83aea4a 100644
--- a/data/rbot/plugins/debugger.rb
+++ b/data/rbot/plugins/debugger.rb
@@ -8,13 +8,13 @@
# License:: GPL v2
class DebugPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('debug.interval',
+ Config.register Config::IntegerValue.new('debug.interval',
:default => 10, :validate => Proc.new{|v| v > 0},
:desc => "Number of seconds between memory profile dumps")
- BotConfig.register BotConfigBooleanValue.new('debug.dump_strings',
+ Config.register Config::BooleanValue.new('debug.dump_strings',
:default => false,
:desc => "Set to true if you want the profiler to dump strings, false otherwise")
- BotConfig.register BotConfigStringValue.new('debug.logdir',
+ Config.register Config::StringValue.new('debug.logdir',
:default => "",
:desc => "Directory where profile/string dumps are to be stored")
diff --git a/data/rbot/plugins/delicious.rb b/data/rbot/plugins/delicious.rb
index bf678303..61ba0091 100644
--- a/data/rbot/plugins/delicious.rb
+++ b/data/rbot/plugins/delicious.rb
@@ -18,13 +18,13 @@ class DeliciousPlugin < Plugin
attr_accessor :last_error
- BotConfig.register BotConfigStringValue.new('delicious.user',
+ Config.register Config::StringValue.new('delicious.user',
:default => '', :desc => "Username on del.icio.us")
- BotConfig.register BotConfigStringValue.new('delicious.password',
+ Config.register Config::StringValue.new('delicious.password',
:default => '', :desc => "Password on del.icio.us")
- BotConfig.register BotConfigStringValue.new('delicious.user_fmt',
+ Config.register Config::StringValue.new('delicious.user_fmt',
:default => 'user:%s', :desc => "How to convert users to tags?")
- BotConfig.register BotConfigStringValue.new('delicious.channel_fmt',
+ Config.register Config::StringValue.new('delicious.channel_fmt',
:default => 'channel:%s', :desc => "How to convert channels to tags?")
def help(plugin, topic="")
diff --git a/data/rbot/plugins/dice.rb b/data/rbot/plugins/dice.rb
index ab40aa28..2cf49675 100644
--- a/data/rbot/plugins/dice.rb
+++ b/data/rbot/plugins/dice.rb
@@ -34,7 +34,7 @@ class DiceDisplay
end
class DicePlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('dice.max_dices',
+ Config.register Config::IntegerValue.new('dice.max_dices',
:default => 100, :validate => Proc.new{|v| v > 0},
:desc => "Maximum number of dices to throw.")
diff --git a/data/rbot/plugins/dict.rb b/data/rbot/plugins/dict.rb
index 95d9fe2e..dc52dbd9 100644
--- a/data/rbot/plugins/dict.rb
+++ b/data/rbot/plugins/dict.rb
@@ -22,10 +22,10 @@ DEMAURO_LEMMA = /<anchor>(.*?)(?: - (.*?))<go href="lemma.php\?ID=(\d+)"\/><\/an
CHAMBERS_LEMMA = /<p><span class="hwd">(.*?)<\/span> <span class="psa">(.*?)<\/span>(.*?)<\/p>/
class DictPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('dict.hits',
+ Config.register Config::IntegerValue.new('dict.hits',
:default => 3,
:desc => "Number of hits to return from a dictionary lookup")
- BotConfig.register BotConfigIntegerValue.new('dict.first_par',
+ Config.register Config::IntegerValue.new('dict.first_par',
:default => 0,
:desc => "When set to n > 0, the bot will return the first paragraph from the first n dictionary hits")
diff --git a/data/rbot/plugins/dictclient.rb b/data/rbot/plugins/dictclient.rb
index 910583ff..2fcdf05a 100644
--- a/data/rbot/plugins/dictclient.rb
+++ b/data/rbot/plugins/dictclient.rb
@@ -52,25 +52,25 @@ class ::Definition
end
class DictClientPlugin < Plugin
- BotConfig.register BotConfigStringValue.new('dictclient.server',
+ Config.register Config::StringValue.new('dictclient.server',
:default => 'dict.org',
:desc => _('Hostname or hostname:port of the DICT server used to lookup words'))
- BotConfig.register BotConfigIntegerValue.new('dictclient.max_defs_before_collapse',
+ Config.register Config::IntegerValue.new('dictclient.max_defs_before_collapse',
:default => 4,
:desc => _('When multiple databases reply a number of definitions that above this limit, only the database names will be listed. Otherwise, the full definitions from each database are replied'))
- BotConfig.register BotConfigIntegerValue.new('dictclient.max_length_per_def',
+ Config.register Config::IntegerValue.new('dictclient.max_length_per_def',
:default => 200,
:desc => _('Each definition is truncated to this length'))
- BotConfig.register BotConfigStringValue.new('dictclient.headword_format',
+ Config.register Config::StringValue.new('dictclient.headword_format',
:default => "#{Bold}<headword>#{Bold}",
:desc => _('Format of headwords; <word> will be replaced with the actual word'))
- BotConfig.register BotConfigStringValue.new('dictclient.database_format',
+ Config.register Config::StringValue.new('dictclient.database_format',
:default => "#{Underline}<database>#{Underline}",
:desc => _('Format of database names; <database> will be replaced with the database name'))
- BotConfig.register BotConfigStringValue.new('dictclient.definition_format',
+ Config.register Config::StringValue.new('dictclient.definition_format',
:default => '<headword>: <definition> -<database>',
:desc => _('Format of definitions. <word> will be replaced with the formatted headword, <def> will be replaced with the truncated definition, and <database> with the formatted database name'))
- BotConfig.register BotConfigStringValue.new('dictclient.match_format',
+ Config.register Config::StringValue.new('dictclient.match_format',
:default => '<matches>––<database>',
:desc => _('Format of match results. <matches> will be replaced with the formatted headwords, <database> with the formatted database name'))
diff --git a/data/rbot/plugins/figlet.rb b/data/rbot/plugins/figlet.rb
index b84a8521..eb218edf 100644
--- a/data/rbot/plugins/figlet.rb
+++ b/data/rbot/plugins/figlet.rb
@@ -2,7 +2,7 @@ class FigletPlugin < Plugin
DEFAULT_FONTS = ['rectangles', 'smslant']
MAX_WIDTH=68
- BotConfig.register BotConfigStringValue.new('figlet.path',
+ Config.register Config::StringValue.new('figlet.path',
:default => '/usr/bin/figlet',
:desc => _('Path to the figlet program'))
diff --git a/data/rbot/plugins/fish.rb b/data/rbot/plugins/fish.rb
index 7cefff8b..3bafd03e 100644
--- a/data/rbot/plugins/fish.rb
+++ b/data/rbot/plugins/fish.rb
@@ -1,10 +1,10 @@
class BabelPlugin < Plugin
LANGS = %w{en fr de it pt es nl ru zh zt el ja ko}
- BotConfig.register BotConfigEnumValue.new('translate.default_from',
+ Config.register Config::EnumValue.new('translate.default_from',
:values => LANGS, :default => 'en',
:desc => "Default language to translate from")
- BotConfig.register BotConfigEnumValue.new('translate.default_to',
+ Config.register Config::EnumValue.new('translate.default_to',
:values => LANGS, :default => 'en',
:desc => "Default language to translate to")
diff --git a/data/rbot/plugins/fortune.rb b/data/rbot/plugins/fortune.rb
index 2845a8c8..adb6a839 100644
--- a/data/rbot/plugins/fortune.rb
+++ b/data/rbot/plugins/fortune.rb
@@ -4,7 +4,7 @@
# :title: Fortune plugin
class FortunePlugin < Plugin
- BotConfig.register BotConfigStringValue.new('fortune.path',
+ Config.register Config::StringValue.new('fortune.path',
:default => '',
:desc => "Full path to the fortune executable")
diff --git a/data/rbot/plugins/games/quiz.rb b/data/rbot/plugins/games/quiz.rb
index 5f7392da..37602fba 100644
--- a/data/rbot/plugins/games/quiz.rb
+++ b/data/rbot/plugins/games/quiz.rb
@@ -156,11 +156,11 @@ end
# CLASS QuizPlugin
#######################################################################
class QuizPlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('quiz.dotted_nicks',
+ Config.register Config::BooleanValue.new('quiz.dotted_nicks',
:default => true,
:desc => "When true, nicks in the top X scores will be camouflaged to prevent IRC hilighting")
- BotConfig.register BotConfigArrayValue.new('quiz.sources',
+ Config.register Config::ArrayValue.new('quiz.sources',
:default => ['quiz.rbot'],
:desc => "List of files and URLs that will be used to retrieve quiz questions")
diff --git a/data/rbot/plugins/games/roulette.rb b/data/rbot/plugins/games/roulette.rb
index 7c25a6cc..adf755fd 100644
--- a/data/rbot/plugins/games/roulette.rb
+++ b/data/rbot/plugins/games/roulette.rb
@@ -1,13 +1,13 @@
define_structure :RouletteHistory, :games, :shots, :deaths, :misses, :wins
class RoulettePlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('roulette.autospin',
+ Config.register Config::BooleanValue.new('roulette.autospin',
:default => true,
:desc => "Automatically spins the roulette at the butlast shot")
- BotConfig.register BotConfigBooleanValue.new('roulette.kick',
+ Config.register Config::BooleanValue.new('roulette.kick',
:default => false,
:desc => "Kicks shot players from the channel")
- BotConfig.register BotConfigBooleanValue.new('roulette.twice_in_a_row',
+ Config.register Config::BooleanValue.new('roulette.twice_in_a_row',
:default => false,
:desc => "Allow players to go twice in a row")
diff --git a/data/rbot/plugins/imdb.rb b/data/rbot/plugins/imdb.rb
index 58684a72..84d0bb17 100644
--- a/data/rbot/plugins/imdb.rb
+++ b/data/rbot/plugins/imdb.rb
@@ -376,19 +376,19 @@ class Imdb
end
class ImdbPlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('imdb.aka',
+ Config.register Config::BooleanValue.new('imdb.aka',
:default => true,
:desc => "Look for IMDB matches also in translated titles and other 'also known as' information")
- BotConfig.register BotConfigBooleanValue.new('imdb.popular',
+ Config.register Config::BooleanValue.new('imdb.popular',
:default => true,
:desc => "Display info on popular IMDB entries matching the request closely")
- BotConfig.register BotConfigBooleanValue.new('imdb.exact',
+ Config.register Config::BooleanValue.new('imdb.exact',
:default => true,
:desc => "Display info on IMDB entries matching the request exactly")
- BotConfig.register BotConfigBooleanValue.new('imdb.fix_article',
+ Config.register Config::BooleanValue.new('imdb.fix_article',
:default => false,
:desc => "Try to detect an article placed at the end and move it in front of the title")
- BotConfig.register BotConfigBooleanValue.new('imdb.tv_series_in_movies',
+ Config.register Config::BooleanValue.new('imdb.tv_series_in_movies',
:default => false,
:desc => "Whether searching movies by person/year should also return TV series")
diff --git a/data/rbot/plugins/keywords.rb b/data/rbot/plugins/keywords.rb
index 6ace2016..c2054e3b 100644
--- a/data/rbot/plugins/keywords.rb
+++ b/data/rbot/plugins/keywords.rb
@@ -79,13 +79,13 @@ end
# handle it, checks for a keyword command or lookup, otherwise the message
# is delegated to plugins
class Keywords < Plugin
- BotConfig.register BotConfigBooleanValue.new('keyword.listen',
+ Config.register Config::BooleanValue.new('keyword.listen',
:default => false,
:desc => "Should the bot listen to all chat and attempt to automatically detect keywords? (e.g. by spotting someone say 'foo is bar')")
- BotConfig.register BotConfigBooleanValue.new('keyword.address',
+ Config.register Config::BooleanValue.new('keyword.address',
:default => true,
:desc => "Should the bot require that keyword lookups are addressed to it? If not, the bot will attempt to lookup foo if someone says 'foo?' in channel")
- BotConfig.register BotConfigIntegerValue.new('keyword.search_results',
+ Config.register Config::IntegerValue.new('keyword.search_results',
:default => 3,
:desc => "How many search results to display at a time")
diff --git a/data/rbot/plugins/lastfm.rb b/data/rbot/plugins/lastfm.rb
index 8c562055..8f25dd4f 100644
--- a/data/rbot/plugins/lastfm.rb
+++ b/data/rbot/plugins/lastfm.rb
@@ -36,10 +36,10 @@ class ::LastFmEvent
end
class LastFmPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('lastfm.max_events',
+ Config.register Config::IntegerValue.new('lastfm.max_events',
:default => 25, :validate => Proc.new{|v| v > 1},
:desc => "Maximum number of events to display.")
- BotConfig.register BotConfigIntegerValue.new('lastfm.default_events',
+ Config.register Config::IntegerValue.new('lastfm.default_events',
:default => 3, :validate => Proc.new{|v| v > 1},
:desc => "Default number of events to display.")
diff --git a/data/rbot/plugins/linkbot.rb b/data/rbot/plugins/linkbot.rb
index a922883f..3c2f42b7 100644
--- a/data/rbot/plugins/linkbot.rb
+++ b/data/rbot/plugins/linkbot.rb
@@ -22,11 +22,11 @@
# servers to make this even easier.
class LinkBot < Plugin
- BotConfig.register BotConfigArrayValue.new('linkbot.nicks',
+ Config.register Config::ArrayValue.new('linkbot.nicks',
:default => [],
:desc => "Nick(s) of the bots that act as channel links across networks")
- BotConfig.register BotConfigArrayValue.new('linkbot.message_patterns',
+ Config.register Config::ArrayValue.new('linkbot.message_patterns',
:default => ['^<(\S+?)@(\S+?)>\s+(.*)$', '^\((\S+?)@(\S+?)\)\s+(.*)$'],
:desc => "List of regexp which match linkbot messages; each regexp needs to have three captures, which in order are the nickname of the original speaker, network, and original message")
# TODO use template strings instead of regexp for user friendliness
diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb
index b89e61d9..87688952 100644
--- a/data/rbot/plugins/nickserv.rb
+++ b/data/rbot/plugins/nickserv.rb
@@ -21,30 +21,30 @@
class NickServPlugin < Plugin
- BotConfig.register BotConfigStringValue.new('nickserv.name',
+ Config.register Config::StringValue.new('nickserv.name',
:default => "nickserv", :requires_restart => false,
:desc => "Name of the nick server (all lowercase)")
- BotConfig.register BotConfigStringValue.new('nickserv.ident_request',
+ Config.register Config::StringValue.new('nickserv.ident_request',
:default => "IDENTIFY", :requires_restart => false,
:on_change => Proc.new { |bot, v| bot.plugins.delegate "set_ident_request", v },
:desc => "String to look for to see if the nick server is asking us to identify")
- BotConfig.register BotConfigStringValue.new('nickserv.nick_avail',
+ Config.register Config::StringValue.new('nickserv.nick_avail',
:default => "not (currently )?online|killed|recovered|disconnesso|libero",
:requires_restart => false,
:on_change => Proc.new { |bot, v| bot.plugins.delegate "set_nick_avail", v },
:desc => "String to look for to see if the nick server is informing us that our nick is now available")
- BotConfig.register BotConfigStringValue.new('nickserv.identified_string',
+ Config.register Config::StringValue.new('nickserv.identified_string',
:default => "(Password|Contrase|Mot de passe).+(acce[pt]t|r[ie]cog?n).+(identif|r[ie]cog?n)",
:requires_restart => false,
:on_change => Proc.new { |bot, v| bot.plugins.delegate "set_identified_string", v },
:desc => "String to look for to see if the nick server is informing us that we have identified successfully")
- BotConfig.register BotConfigBooleanValue.new('nickserv.wants_nick',
+ Config.register Config::BooleanValue.new('nickserv.wants_nick',
:default => false, :requires_restart => false,
:desc => "Set to false if the nick server doesn't expect the nick as a parameter in the identify command")
- BotConfig.register BotConfigIntegerValue.new('nickserv.wait',
+ Config.register Config::IntegerValue.new('nickserv.wait',
:default => 30, :validate => Proc.new { |v| v > 0 }, :requires_restart => false,
:desc => "Seconds to wait after sending a message to nickserv, e.g. after ghosting")
@@ -64,7 +64,7 @@ class NickServPlugin < Plugin
end
def genpasswd
- return Irc::Auth.random_password
+ return Irc::Bot::Auth.random_password
end
def set_ident_request(val)
diff --git a/data/rbot/plugins/ri.rb b/data/rbot/plugins/ri.rb
index 1c4cc84d..763dd658 100644
--- a/data/rbot/plugins/ri.rb
+++ b/data/rbot/plugins/ri.rb
@@ -16,7 +16,7 @@ class RiPlugin < Plugin
RI_COMMAND = %w{ri -f simple -T}
- BotConfig.register BotConfigIntegerValue.new('ri.max_length',
+ Config.register Config::IntegerValue.new('ri.max_length',
:default => 512,
:desc => "Maximum length of ri entry (in bytes) which is ok to be sent to channels or other users")
diff --git a/data/rbot/plugins/rss.rb b/data/rbot/plugins/rss.rb
index 6ee93404..5a87e789 100644
--- a/data/rbot/plugins/rss.rb
+++ b/data/rbot/plugins/rss.rb
@@ -242,19 +242,19 @@ class ::RssBlob
end
class RSSFeedsPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('rss.head_max',
+ Config.register Config::IntegerValue.new('rss.head_max',
:default => 100, :validate => Proc.new{|v| v > 0 && v < 200},
:desc => "How many characters to use of a RSS item header")
- BotConfig.register BotConfigIntegerValue.new('rss.text_max',
+ Config.register Config::IntegerValue.new('rss.text_max',
:default => 200, :validate => Proc.new{|v| v > 0 && v < 400},
:desc => "How many characters to use of a RSS item text")
- BotConfig.register BotConfigIntegerValue.new('rss.thread_sleep',
+ Config.register Config::IntegerValue.new('rss.thread_sleep',
:default => 300, :validate => Proc.new{|v| v > 30},
:desc => "How many seconds to sleep before checking RSS feeds again")
- BotConfig.register BotConfigBooleanValue.new('rss.show_updated',
+ Config.register Config::BooleanValue.new('rss.show_updated',
:default => true,
:desc => "Whether feed items for which the description was changed should be shown as new")
diff --git a/data/rbot/plugins/salut.rb b/data/rbot/plugins/salut.rb
index feff2dd6..2948b2f3 100644
--- a/data/rbot/plugins/salut.rb
+++ b/data/rbot/plugins/salut.rb
@@ -14,12 +14,12 @@
# TODO:: *REMEMBER* to set @changed to true after edit or changes won't be saved
class SalutPlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new('salut.all_languages',
+ Config.register Config::BooleanValue.new('salut.all_languages',
:default => true,
:desc => "Check for a salutation in all languages and not just in the one defined by core.language",
:on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}
)
- BotConfig.register BotConfigBooleanValue.new('salut.address_only',
+ Config.register Config::BooleanValue.new('salut.address_only',
:default => true,
:desc => "When set to true, the bot will only reply to salutations directed at him",
:on_change => Proc.new {|bot, v| bot.plugins['salut'].reload}
diff --git a/data/rbot/plugins/search.rb b/data/rbot/plugins/search.rb
index 493db936..46aa46fe 100644
--- a/data/rbot/plugins/search.rb
+++ b/data/rbot/plugins/search.rb
@@ -22,16 +22,16 @@ GOOGLE_CALC_RESULT = %r{<p><table><tr><td><img src=/images/calc_img\.gif(?: alt=
GOOGLE_DEF_RESULT = %r{<p> (Web definitions for .*?)<br/>(.*?)<br/>(.*?)\s-\s+<a href}
class SearchPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('google.hits',
+ Config.register Config::IntegerValue.new('google.hits',
:default => 3,
:desc => "Number of hits to return from Google searches")
- BotConfig.register BotConfigIntegerValue.new('google.first_par',
+ Config.register Config::IntegerValue.new('google.first_par',
:default => 0,
:desc => "When set to n > 0, the bot will return the first paragraph from the first n search hits")
- BotConfig.register BotConfigIntegerValue.new('wikipedia.hits',
+ Config.register Config::IntegerValue.new('wikipedia.hits',
:default => 3,
:desc => "Number of hits to return from Wikipedia searches")
- BotConfig.register BotConfigIntegerValue.new('wikipedia.first_par',
+ Config.register Config::IntegerValue.new('wikipedia.first_par',
:default => 1,
:desc => "When set to n > 0, the bot will return the first paragraph from the first n wikipedia search hits")
diff --git a/data/rbot/plugins/translator.rb b/data/rbot/plugins/translator.rb
index 299d6a0e..6a842754 100644
--- a/data/rbot/plugins/translator.rb
+++ b/data/rbot/plugins/translator.rb
@@ -252,7 +252,7 @@ class WorldlingoTranslator < Translator
end
class TranslatorPlugin < Plugin
- BotConfig.register BotConfigIntegerValue.new('translator.timeout',
+ Config.register Config::IntegerValue.new('translator.timeout',
:default => 30, :validate => Proc.new{|v| v > 0},
:desc => _("Number of seconds to wait for the translation service before timeout"))
@@ -279,7 +279,7 @@ class TranslatorPlugin < Plugin
end
end
- BotConfig.register BotConfigArrayValue.new('translator.default_list',
+ Config.register Config::ArrayValue.new('translator.default_list',
:default => TRANSLATORS.keys,
:validate => Proc.new {|l| l.all? {|t| TRANSLATORS.has_key?(t)}},
:desc => _("List of translators to try in order when translator name not specified"),
diff --git a/data/rbot/plugins/unicode.rb b/data/rbot/plugins/unicode.rb
index e05f87dd..957f5bff 100644
--- a/data/rbot/plugins/unicode.rb
+++ b/data/rbot/plugins/unicode.rb
@@ -18,12 +18,12 @@ require 'jcode'
require 'iconv'
class UnicodePlugin < Plugin
- BotConfig.register BotConfigBooleanValue.new(
+ Config.register Config::BooleanValue.new(
'encoding.enable', :default => true,
:desc => "Support for non-ascii charsets",
:on_change => Proc.new { |bot, v| reconfigure_filter(bot) })
- BotConfig.register BotConfigArrayValue.new(
+ Config.register Config::ArrayValue.new(
'encoding.charsets', :default => ['utf-8', 'cp1252', 'iso-8859-15'],
:desc => "Ordered list of iconv(3) charsets the bot should try",
:on_change => Proc.new { |bot, v| reconfigure_filter(bot) })
diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb
index 16b2e28e..e3cecb6b 100644
--- a/data/rbot/plugins/url.rb
+++ b/data/rbot/plugins/url.rb
@@ -13,22 +13,22 @@ class UrlPlugin < Plugin
LINK_INFO = "[Link Info]"
OUR_UNSAFE = Regexp.new("[^#{URI::PATTERN::UNRESERVED}#{URI::PATTERN::RESERVED}%# ]", false, 'N')
- BotConfig.register BotConfigIntegerValue.new('url.max_urls',
+ Config.register Config::IntegerValue.new('url.max_urls',
:default => 100, :validate => Proc.new{|v| v > 0},
:desc => "Maximum number of urls to store. New urls replace oldest ones.")
- BotConfig.register BotConfigIntegerValue.new('url.display_link_info',
+ Config.register Config::IntegerValue.new('url.display_link_info',
:default => 0,
:desc => "Get the title of links pasted to the channel and display it (also tells if the link is broken or the site is down). Do it for at most this many links per line (set to 0 to disable)")
- BotConfig.register BotConfigBooleanValue.new('url.titles_only',
+ Config.register Config::BooleanValue.new('url.titles_only',
:default => false,
:desc => "Only show info for links that have <title> tags (in other words, don't display info for jpegs, mpegs, etc.)")
- BotConfig.register BotConfigBooleanValue.new('url.first_par',
+ Config.register Config::BooleanValue.new('url.first_par',
:default => false,
:desc => "Also try to get the first paragraph of a web page")
- BotConfig.register BotConfigBooleanValue.new('url.info_on_list',
+ Config.register Config::BooleanValue.new('url.info_on_list',
:default => false,
:desc => "Show link info when listing/searching for urls")
- BotConfig.register BotConfigArrayValue.new('url.no_info_hosts',
+ Config.register Config::ArrayValue.new('url.no_info_hosts',
:default => ['localhost', '^192\.168\.', '^10\.', '^127\.', '^172\.(1[6-9]|2\d|31)\.'],
:on_change => Proc.new { |bot, v| bot.plugins['url'].reset_no_info_hosts },
:desc => "A list of regular expressions matching hosts for which no info should be provided")
diff --git a/launch_here.rb b/launch_here.rb
index ad149d68..033e075f 100755
--- a/launch_here.rb
+++ b/launch_here.rb
@@ -9,10 +9,12 @@ puts "Running from #{SVN_DIR}"
$:.unshift File.join(SVN_DIR, 'lib')
module Irc
+class Bot
module Config
@@datadir = File.join SVN_DIR, 'data/rbot'
@@coredir = File.join SVN_DIR, 'lib/rbot/core'
end
end
+end
load File.join(SVN_DIR, 'bin/rbot')
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb
index a77765b8..146912b4 100644
--- a/lib/rbot/botuser.rb
+++ b/lib/rbot/botuser.rb
@@ -19,7 +19,7 @@ require 'set'
# class_eval {
# define_method(m) { |*a|
# r = super(*a)
-# Irc::Auth.authmanager.set_changed
+# Irc::Bot::Auth.authmanager.set_changed
# r
# }
# }
@@ -28,26 +28,27 @@ require 'set'
#
module Irc
+class Bot
# This module contains the actual Authentication stuff
#
module Auth
- BotConfig.register BotConfigStringValue.new( 'auth.password',
+ Config.register Config::StringValue.new( 'auth.password',
:default => 'rbotauth', :wizard => true,
:on_change => Proc.new {|bot, v| bot.auth.botowner.password = v},
:desc => _('Password for the bot owner'))
- BotConfig.register BotConfigBooleanValue.new( 'auth.login_by_mask',
+ Config.register Config::BooleanValue.new( 'auth.login_by_mask',
:default => 'true',
:desc => _('Set false to prevent new botusers from logging in without a password when the user netmask is known'))
- BotConfig.register BotConfigBooleanValue.new( 'auth.autologin',
+ Config.register Config::BooleanValue.new( 'auth.autologin',
:default => 'true',
:desc => _('Set false to prevent new botusers from recognizing IRC users without a need to manually login'))
- BotConfig.register BotConfigBooleanValue.new( 'auth.autouser',
+ Config.register Config::BooleanValue.new( 'auth.autouser',
:default => 'false',
:desc => _('Set true to allow new botusers to be created automatically'))
- # BotConfig.register BotConfigIntegerValue.new( 'auth.default_level',
+ # Config.register Config::IntegerValue.new( 'auth.default_level',
# :default => 10, :wizard => true,
# :desc => 'The default level for new/unknown users' )
@@ -62,7 +63,7 @@ module Irc
end
- # An Irc::Auth::Command defines a command by its "path":
+ # An Irc::Bot::Auth::Command defines a command by its "path":
#
# base::command::subcommand::subsubcommand::subsubsubcommand
#
@@ -110,13 +111,14 @@ module Irc
end
end
+end
class String
- # Returns an Irc::Auth::Comand from the receiver
+ # Returns an Irc::Bot::Auth::Comand from the receiver
def to_irc_auth_command
- Irc::Auth::Command.new(self)
+ Irc::Bot::Auth::Command.new(self)
end
end
@@ -124,15 +126,16 @@ end
class Symbol
- # Returns an Irc::Auth::Comand from the receiver
+ # Returns an Irc::Bot::Auth::Comand from the receiver
def to_irc_auth_command
- Irc::Auth::Command.new(self)
+ Irc::Bot::Auth::Command.new(self)
end
end
module Irc
+class Bot
module Auth
@@ -830,6 +833,7 @@ module Irc
end
end
+end
class User
@@ -837,7 +841,7 @@ module Irc
# associated with the receiver
#
def botuser
- Irc::Auth.authmanager.irc_to_botuser(self)
+ Irc::Bot::Auth.authmanager.irc_to_botuser(self)
end
# Bot-specific data can be stored with Irc::Users. This is
@@ -863,7 +867,7 @@ module Irc
def set_bot_data(key,value=nil,&block)
if not block_given?
self.botuser.data[key]=value
- Irc::Auth.authmanager.set_changed
+ Irc::Bot::Auth.authmanager.set_changed
return value
end
if value and not bot_data.has_key?(key)
@@ -873,7 +877,7 @@ module Irc
begin
r = yield bot_data(key)
ensure
- Irc::Auth.authmanager.set_changed
+ Irc::Bot::Auth.authmanager.set_changed
end
return r
end
diff --git a/lib/rbot/config.rb b/lib/rbot/config.rb
index eb342f7c..7ed019fe 100644
--- a/lib/rbot/config.rb
+++ b/lib/rbot/config.rb
@@ -1,20 +1,23 @@
require 'singleton'
-module Irc
-
- require 'yaml'
+require 'yaml'
- unless YAML.respond_to?(:load_file)
- def YAML.load_file( filepath )
- File.open( filepath ) do |f|
- YAML::load( f )
- end
- end
+unless YAML.respond_to?(:load_file)
+ def YAML.load_file( filepath )
+ File.open( filepath ) do |f|
+ YAML::load( f )
+ end
end
+end
+
- class BotConfigValue
+module Irc
+
+class Bot
+module Config
+ class Value
# allow the definition order to be preserved so that sorting by
- # definition order is possible. The BotConfigWizard does this to allow
+ # definition order is possible. The Wizard does this to allow
# the :wizard questions to be in a sensible order.
@@order = 0
attr_reader :type
@@ -27,7 +30,7 @@ module Irc
attr_reader :manager
attr_reader :auth_path
def initialize(key, params)
- @manager = BotConfig::configmanager
+ @manager = Config.manager
# Keys must be in the form 'module.name'.
# They will be internally passed around as symbols,
# but we accept them both in string and symbol form.
@@ -107,10 +110,10 @@ module Irc
end
end
- class BotConfigStringValue < BotConfigValue
+ class StringValue < Value
end
- class BotConfigBooleanValue < BotConfigValue
+ class BooleanValue < Value
def parse(string)
return true if string == "true"
return false if string == "false"
@@ -129,7 +132,7 @@ module Irc
end
end
- class BotConfigIntegerValue < BotConfigValue
+ class IntegerValue < Value
def parse(string)
return 1 if string == "true"
return 0 if string == "false"
@@ -146,14 +149,14 @@ module Irc
end
end
- class BotConfigFloatValue < BotConfigValue
+ class FloatValue < Value
def parse(string)
raise ArgumentError, "not a float #{string}" unless string =~ /^-?[\d.]+$/
string.to_f
end
end
- class BotConfigArrayValue < BotConfigValue
+ class ArrayValue < Value
def parse(string)
string.split(/,\s+/)
end
@@ -171,7 +174,7 @@ module Irc
end
end
- class BotConfigEnumValue < BotConfigValue
+ class EnumValue < Value
def initialize(key, params)
super
@values = params[:values]
@@ -195,7 +198,7 @@ module Irc
end
# container for bot configuration
- class BotConfigManagerClass
+ class ManagerClass
include Singleton
@@ -232,15 +235,15 @@ module Irc
end
end
# if we got here, we need to run the first-run wizard
- BotConfigWizard.new(@bot).run
+ Wizard.new(@bot).run
# save newly created config
@changed = true
save
end
def register(item)
- unless item.kind_of?(BotConfigValue)
- raise ArgumentError,"item must be a BotConfigValue"
+ unless item.kind_of?(Value)
+ raise ArgumentError,"item must be an Irc::Bot::Config::Value"
end
@items[item.key] = item
end
@@ -265,7 +268,7 @@ module Irc
return false
end
- # TODO should I implement this via BotConfigValue or leave it direct?
+ # TODO should I implement this via Value or leave it direct?
# def []=(key, value)
# end
@@ -301,23 +304,21 @@ module Irc
end
end
- module BotConfig
- # Returns the only BotConfigManagerClass
- #
- def BotConfig.configmanager
- return BotConfigManagerClass.instance
- end
+ # Returns the only Irc::Bot::Config::ManagerClass
+ #
+ def Config.manager
+ return ManagerClass.instance
+ end
- # Register a config value
- def BotConfig.register(item)
- BotConfig.configmanager.register(item)
- end
+ # Register a config value
+ def Config.register(item)
+ Config.manager.register(item)
end
- class BotConfigWizard
+ class Wizard
def initialize(bot)
@bot = bot
- @manager = BotConfig::configmanager
+ @manager = Config.manager
@questions = @manager.items.values.find_all {|i| i.wizard }
end
@@ -350,3 +351,5 @@ module Irc
end
end
+end
+end
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
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 4debf1cb..e2f3f28e 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -127,7 +127,7 @@ class Bot
# the bot's Auth data
attr_reader :auth
- # the bot's BotConfig data
+ # the bot's Config data
attr_reader :config
# the botclass for this bot (determines configdir among other things)
@@ -179,58 +179,58 @@ class Bot
# create a new Bot with botclass +botclass+
def initialize(botclass, params = {})
- # BotConfig for the core bot
+ # Config for the core bot
# TODO should we split socket stuff into ircsocket, etc?
- BotConfig.register BotConfigArrayValue.new('server.list',
+ Config.register Config::ArrayValue.new('server.list',
:default => ['irc://localhost'], :wizard => true,
:requires_restart => true,
:desc => "List of irc servers rbot should try to connect to. Use comma to separate values. Servers are in format 'server.doma.in:port'. If port is not specified, default value (6667) is used.")
- BotConfig.register BotConfigBooleanValue.new('server.ssl',
+ Config.register Config::BooleanValue.new('server.ssl',
:default => false, :requires_restart => true, :wizard => true,
:desc => "Use SSL to connect to this server?")
- BotConfig.register BotConfigStringValue.new('server.password',
+ Config.register Config::StringValue.new('server.password',
:default => false, :requires_restart => true,
:desc => "Password for connecting to this server (if required)",
:wizard => true)
- BotConfig.register BotConfigStringValue.new('server.bindhost',
+ Config.register Config::StringValue.new('server.bindhost',
:default => false, :requires_restart => true,
:desc => "Specific local host or IP for the bot to bind to (if required)",
:wizard => true)
- BotConfig.register BotConfigIntegerValue.new('server.reconnect_wait',
+ Config.register Config::IntegerValue.new('server.reconnect_wait',
:default => 5, :validate => Proc.new{|v| v >= 0},
:desc => "Seconds to wait before attempting to reconnect, on disconnect")
- BotConfig.register BotConfigFloatValue.new('server.sendq_delay',
+ Config.register Config::FloatValue.new('server.sendq_delay',
:default => 2.0, :validate => Proc.new{|v| v >= 0},
:desc => "(flood prevention) the delay between sending messages to the server (in seconds)",
:on_change => Proc.new {|bot, v| bot.socket.sendq_delay = v })
- BotConfig.register BotConfigIntegerValue.new('server.sendq_burst',
+ Config.register Config::IntegerValue.new('server.sendq_burst',
:default => 4, :validate => Proc.new{|v| v >= 0},
:desc => "(flood prevention) max lines to burst to the server before throttling. Most ircd's allow bursts of up 5 lines",
:on_change => Proc.new {|bot, v| bot.socket.sendq_burst = v })
- BotConfig.register BotConfigIntegerValue.new('server.ping_timeout',
+ Config.register Config::IntegerValue.new('server.ping_timeout',
:default => 30, :validate => Proc.new{|v| v >= 0},
:desc => "reconnect if server doesn't respond to PING within this many seconds (set to 0 to disable)")
- BotConfig.register BotConfigStringValue.new('irc.nick', :default => "rbot",
+ Config.register Config::StringValue.new('irc.nick', :default => "rbot",
:desc => "IRC nickname the bot should attempt to use", :wizard => true,
:on_change => Proc.new{|bot, v| bot.sendq "NICK #{v}" })
- BotConfig.register BotConfigStringValue.new('irc.name',
+ Config.register Config::StringValue.new('irc.name',
:default => "Ruby bot", :requires_restart => true,
:desc => "IRC realname the bot should use")
- BotConfig.register BotConfigBooleanValue.new('irc.name_copyright',
+ Config.register Config::BooleanValue.new('irc.name_copyright',
:default => true, :requires_restart => true,
:desc => "Append copyright notice to bot realname? (please don't disable unless it's really necessary)")
- BotConfig.register BotConfigStringValue.new('irc.user', :default => "rbot",
+ Config.register Config::StringValue.new('irc.user', :default => "rbot",
:requires_restart => true,
:desc => "local user the bot should appear to be", :wizard => true)
- BotConfig.register BotConfigArrayValue.new('irc.join_channels',
+ Config.register Config::ArrayValue.new('irc.join_channels',
:default => [], :wizard => true,
:desc => "What channels the bot should always join at startup. List multiple channels using commas to separate. If a channel requires a password, use a space after the channel name. e.g: '#chan1, #chan2, #secretchan secritpass, #chan3'")
- BotConfig.register BotConfigArrayValue.new('irc.ignore_users',
+ Config.register Config::ArrayValue.new('irc.ignore_users',
:default => [],
:desc => "Which users to ignore input from. This is mainly to avoid bot-wars triggered by creative people")
- BotConfig.register BotConfigIntegerValue.new('core.save_every',
+ Config.register Config::IntegerValue.new('core.save_every',
:default => 60, :validate => Proc.new{|v| v >= 0},
:on_change => Proc.new { |bot, v|
if @save_timer
@@ -249,73 +249,73 @@ class Bot
},
:desc => "How often the bot should persist all configuration to disk (in case of a server crash, for example)")
- BotConfig.register BotConfigBooleanValue.new('core.run_as_daemon',
+ Config.register Config::BooleanValue.new('core.run_as_daemon',
:default => false, :requires_restart => true,
:desc => "Should the bot run as a daemon?")
- BotConfig.register BotConfigStringValue.new('log.file',
+ Config.register Config::StringValue.new('log.file',
:default => false, :requires_restart => true,
:desc => "Name of the logfile to which console messages will be redirected when the bot is run as a daemon")
- BotConfig.register BotConfigIntegerValue.new('log.level',
+ Config.register Config::IntegerValue.new('log.level',
:default => 1, :requires_restart => false,
:validate => Proc.new { |v| (0..5).include?(v) },
:on_change => Proc.new { |bot, v|
$logger.level = v
},
:desc => "The minimum logging level (0=DEBUG,1=INFO,2=WARN,3=ERROR,4=FATAL) for console messages")
- BotConfig.register BotConfigIntegerValue.new('log.keep',
+ Config.register Config::IntegerValue.new('log.keep',
:default => 1, :requires_restart => true,
:validate => Proc.new { |v| v >= 0 },
:desc => "How many old console messages logfiles to keep")
- BotConfig.register BotConfigIntegerValue.new('log.max_size',
+ Config.register Config::IntegerValue.new('log.max_size',
:default => 10, :requires_restart => true,
:validate => Proc.new { |v| v > 0 },
:desc => "Maximum console messages logfile size (in megabytes)")
- BotConfig.register BotConfigArrayValue.new('plugins.path',
+ Config.register Config::ArrayValue.new('plugins.path',
:wizard => true, :default => ['(default)', '(default)/games', '(default)/contrib'],
:requires_restart => false,
:on_change => Proc.new { |bot, v| bot.setup_plugins_path },
:desc => "Where the bot should look for plugins. List multiple directories using commas to separate. Use '(default)' for default prepackaged plugins collection, '(default)/contrib' for prepackaged unsupported plugins collection")
- BotConfig.register BotConfigEnumValue.new('send.newlines',
+ Config.register Config::EnumValue.new('send.newlines',
:values => ['split', 'join'], :default => 'split',
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :newlines => v.to_sym
},
:desc => "When set to split, messages with embedded newlines will be sent as separate lines. When set to join, newlines will be replaced by the value of join_with")
- BotConfig.register BotConfigStringValue.new('send.join_with',
+ Config.register Config::StringValue.new('send.join_with',
:default => ' ',
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :join_with => v.dup
},
:desc => "String used to replace newlines when send.newlines is set to join")
- BotConfig.register BotConfigIntegerValue.new('send.max_lines',
+ Config.register Config::IntegerValue.new('send.max_lines',
:default => 5,
:validate => Proc.new { |v| v >= 0 },
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :max_lines => v
},
:desc => "Maximum number of IRC lines to send for each message (set to 0 for no limit)")
- BotConfig.register BotConfigEnumValue.new('send.overlong',
+ Config.register Config::EnumValue.new('send.overlong',
:values => ['split', 'truncate'], :default => 'split',
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :overlong => v.to_sym
},
:desc => "When set to split, messages which are too long to fit in a single IRC line are split into multiple lines. When set to truncate, long messages are truncated to fit the IRC line length")
- BotConfig.register BotConfigStringValue.new('send.split_at',
+ Config.register Config::StringValue.new('send.split_at',
:default => '\s+',
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :split_at => Regexp.new(v)
},
:desc => "A regular expression that should match the split points for overlong messages (see send.overlong)")
- BotConfig.register BotConfigBooleanValue.new('send.purge_split',
+ Config.register Config::BooleanValue.new('send.purge_split',
:default => true,
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :purge_split => v
},
:desc => "Set to true if the splitting boundary (set in send.split_at) should be removed when splitting overlong messages (see send.overlong)")
- BotConfig.register BotConfigStringValue.new('send.truncate_text',
+ Config.register Config::StringValue.new('send.truncate_text',
:default => "#{Reverse}...#{Reverse}",
:on_change => Proc.new { |bot, v|
bot.set_default_send_options :truncate_text => v.dup
@@ -376,7 +376,7 @@ class Bot
@startup_time = Time.new
begin
- @config = BotConfig.configmanager
+ @config = Config.manager
@config.bot_associate(self)
rescue Exception => e
fatal e
@@ -443,7 +443,7 @@ class Bot
pf << "#{$$}\n"
end
- @registry = BotRegistry.new self
+ @registry = Registry.new self
@timer = Timer.new
@save_mutex = Mutex.new
diff --git a/lib/rbot/language.rb b/lib/rbot/language.rb
index 7cf1ceb9..3e4c77f0 100644
--- a/lib/rbot/language.rb
+++ b/lib/rbot/language.rb
@@ -8,6 +8,7 @@
# .lang file etc.
module Irc
+class Bot
class Language
# This constant hash holds the mapping
@@ -54,8 +55,8 @@ module Irc
return 'english'
end
- BotConfig.register BotConfigEnumValue.new('core.language',
- :default => Irc::Language.from_locale, :wizard => true,
+ Config.register Config::EnumValue.new('core.language',
+ :default => Irc::Bot::Language.from_locale, :wizard => true,
:values => Proc.new{|bot|
Dir.new(Config::datadir + "/languages").collect {|f|
f =~ /\.lang$/ ? f.gsub(/\.lang$/, "") : nil
@@ -141,3 +142,4 @@ module Irc
end
end
+end
diff --git a/lib/rbot/load-gettext.rb b/lib/rbot/load-gettext.rb
index e95d4068..dd9961f5 100644
--- a/lib/rbot/load-gettext.rb
+++ b/lib/rbot/load-gettext.rb
@@ -22,7 +22,7 @@ begin
include GetText
- add_default_locale_path(File.join(Irc::Config.datadir, "../locale/%{locale}/LC_MESSAGES/%{name}.mo"))
+ add_default_locale_path(File.join(Irc::Bot::Config.datadir, "../locale/%{locale}/LC_MESSAGES/%{name}.mo"))
bindtextdomain 'rbot'
diff --git a/lib/rbot/message.rb b/lib/rbot/message.rb
index 969dbc7d..acfd5da3 100644
--- a/lib/rbot/message.rb
+++ b/lib/rbot/message.rb
@@ -4,20 +4,27 @@
# :title: IRC message datastructures
module Irc
- BotConfig.register BotConfigArrayValue.new('core.address_prefix',
- :default => [], :wizard => true,
- :desc => "what non nick-matching prefixes should the bot respond to as if addressed (e.g !, so that '!foo' is treated like 'rbot: foo')"
- )
-
- BotConfig.register BotConfigBooleanValue.new('core.reply_with_nick',
- :default => false, :wizard => true,
- :desc => "if true, the bot will prepend the nick to what he has to say when replying (e.g. 'markey: you can't do that!')"
- )
-
- BotConfig.register BotConfigStringValue.new('core.nick_postfix',
- :default => ':', :wizard => true,
- :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
- )
+
+
+ class Bot
+ module Config
+ Config.register ArrayValue.new('core.address_prefix',
+ :default => [], :wizard => true,
+ :desc => "what non nick-matching prefixes should the bot respond to as if addressed (e.g !, so that '!foo' is treated like 'rbot: foo')"
+ )
+
+ Config.register BooleanValue.new('core.reply_with_nick',
+ :default => false, :wizard => true,
+ :desc => "if true, the bot will prepend the nick to what he has to say when replying (e.g. 'markey: you can't do that!')"
+ )
+
+ Config.register StringValue.new('core.nick_postfix',
+ :default => ':', :wizard => true,
+ :desc => "when replying with nick put this character after the nick of the user the bot is replying to"
+ )
+ end
+ end
+
# Define standard IRC attriubtes (not so standard actually,
# but the closest thing we have ...)
diff --git a/lib/rbot/messagemapper.rb b/lib/rbot/messagemapper.rb
index 7f13b7fb..8b52baa4 100644
--- a/lib/rbot/messagemapper.rb
+++ b/lib/rbot/messagemapper.rb
@@ -18,6 +18,7 @@ class Regexp
end
module Irc
+class Bot
# MessageMapper is a class designed to reduce the amount of regexps and
# string parsing plugins and bot modules need to do, in order to process
@@ -586,3 +587,4 @@ module Irc
end
end
end
+end
diff --git a/lib/rbot/plugins.rb b/lib/rbot/plugins.rb
index 96f61efc..5ad1ebb1 100644
--- a/lib/rbot/plugins.rb
+++ b/lib/rbot/plugins.rb
@@ -6,7 +6,8 @@
require 'singleton'
module Irc
- BotConfig.register BotConfigArrayValue.new('plugins.blacklist',
+class Bot
+ Config.register Config::ArrayValue.new('plugins.blacklist',
:default => [], :wizard => false, :requires_rescan => true,
:desc => "Plugins that should not be loaded")
module Plugins
@@ -17,7 +18,7 @@ module Plugins
functionality. Rather than subclassing BotModule, however, one should
subclass either CoreBotModule (reserved for system modules) or Plugin
(for user plugins).
-
+
A BotModule interacts with Irc events by defining one or more of the following
methods, which get called as appropriate when the corresponding Irc event
happens.
@@ -27,7 +28,7 @@ module Plugins
map is the new, cleaner way to respond to specific message formats without
littering your plugin code with regexps, and should be used instead of
#register() and #privmsg() (see below) when possible.
-
+
The difference between map and map! is that map! will not register the new
command as an alternative name for the plugin.
@@ -134,7 +135,7 @@ module Plugins
# the rbot instance
# @registry::
# the botmodule's registry, which can be used to store permanent data
- # (see BotRegistryAccessor for additional documentation)
+ # (see Registry::Accessor for additional documentation)
#
# Other instance variables which are defined and should not be overwritten
# byt the user, but aren't usually accessed directly, are:
@@ -153,7 +154,7 @@ module Plugins
@botmodule_triggers = Array.new
@handler = MessageMapper.new(self)
- @registry = BotRegistryAccessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
+ @registry = Registry::Accessor.new(@bot, self.class.to_s.gsub(/^.*::/, ""))
@manager.add_botmodule(self)
if self.respond_to?('set_language')
@@ -683,9 +684,9 @@ module Plugins
key = $1
params = $2
- # Let's see if we can match a plugin by the given name
+ # Let's see if we can match a plugin by the given name
(core_modules + plugins).each { |p|
- next unless p.name == key
+ next unless p.name == key
begin
return p.help(key, params)
rescue Exception => err
@@ -694,7 +695,7 @@ module Plugins
end
}
- # Nope, let's see if it's a command, and ask for help at the corresponding botmodule
+ # Nope, let's see if it's a command, and ask for help at the corresponding botmodule
k = key.to_sym
if commands.has_key?(k)
p = commands[k][:botmodule]
@@ -792,3 +793,4 @@ module Plugins
end
end
+end
diff --git a/lib/rbot/rbotconfig.rb b/lib/rbot/rbotconfig.rb
index a282d770..1c10e5af 100644
--- a/lib/rbot/rbotconfig.rb
+++ b/lib/rbot/rbotconfig.rb
@@ -1,4 +1,5 @@
module Irc
+class Bot
module Config
unless defined?(@@datadir)
@@datadir = nil
@@ -66,3 +67,4 @@ module Irc
end
end
end
+end
diff --git a/lib/rbot/registry.rb b/lib/rbot/registry.rb
index 98c5b3ea..44756a35 100644
--- a/lib/rbot/registry.rb
+++ b/lib/rbot/registry.rb
@@ -1,10 +1,11 @@
require 'rbot/dbhash'
module Irc
+class Bot
- # this class is now used purely for upgrading from prior versions of rbot
+ # This class is now used purely for upgrading from prior versions of rbot
# the new registry is split into multiple DBHash objects, one per plugin
- class BotRegistry
+ class Registry
def initialize(bot)
@bot = bot
upgrade_data
@@ -71,7 +72,6 @@ module Irc
env.close
end
end
- end
# This class provides persistent storage for plugins via a hash interface.
@@ -94,7 +94,7 @@ module Irc
# in object store mode, don't make the mistake of treating it like a live
# object, e.g. (using the example above)
# @registry[:blah][:foo] = "flump"
- # will NOT modify the object in the registry - remember that BotRegistry#[]
+ # will NOT modify the object in the registry - remember that Registry#[]
# returns a Marshal.restore'd object, the object you just modified in place
# will disappear. You would need to:
# blah = @registry[:blah]
@@ -117,11 +117,11 @@ module Irc
# Your plugins section of the registry is private, it has its own namespace
# (derived from the plugin's class name, so change it and lose your data).
# Calls to registry.each etc, will only iterate over your namespace.
- class BotRegistryAccessor
+ class Accessor
attr_accessor :recovery
- # plugins don't call this - a BotRegistryAccessor is created for them and
+ # plugins don't call this - a Registry::Accessor is created for them and
# is accessible via @registry.
def initialize(bot, name)
@bot = bot
@@ -315,7 +315,7 @@ module Irc
end
def sub_registry(prefix)
- return BotRegistryAccessor.new(@bot, @name + "/" + prefix.to_s)
+ return Accessor.new(@bot, @name + "/" + prefix.to_s)
end
# returns the number of keys in your registry namespace
@@ -326,4 +326,6 @@ module Irc
end
+ end
+end
end