]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commit - lib/rbot/ircbot.rb
+ @bot.path and datafile methods
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 15 Feb 2009 00:30:51 +0000 (01:30 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Sun, 15 Feb 2009 01:06:27 +0000 (02:06 +0100)
commit91a9024e21ec8b429605a036b5c9193442a580e3
treef1524dd5595a80e32d0702c0d8939b1001c695fb
parent38be7f6511447d98780a069bccefecd933238e30
+ @bot.path and datafile methods

We provide two methods that make it more simple and elegant for
botmodules to define paths relative to the bot's own directory
(botclass) and to the BotModule's (assumed) non-registry directory.

The first method is Irc::Bot#path(), which joins its arguments with the
botclass. This method can be used to access datafiles in the bot
directory with a much cleaner syntax; and since it uses File.join, the
resulting paths are also properly formatted on each platform, which
doesn't hurt.

Each BotModule now also carries a dirname() method that should return the
directory under botclass that holds the BotModule's datafiles. dirname()
defaults to the BotModule's name(), but it can be overridden, e.g. for
backwards compatibility (see the patch for the quotes plugin), or
for BotModules that share their datafiles.

Datafiles can be accessed using the BotModule#datafile() method that
joins the botclass, the dirname() and whatever other argument is passed.
20 files changed:
data/rbot/plugins/alias.rb
data/rbot/plugins/debugger.rb
data/rbot/plugins/factoids.rb
data/rbot/plugins/games/azgame.rb
data/rbot/plugins/games/quiz.rb
data/rbot/plugins/games/shiritori.rb
data/rbot/plugins/karma.rb
data/rbot/plugins/keywords.rb
data/rbot/plugins/lart.rb
data/rbot/plugins/quotes.rb
data/rbot/plugins/salut.rb
lib/rbot/config.rb
lib/rbot/core/auth.rb
lib/rbot/core/irclog.rb
lib/rbot/core/utils/utils.rb
lib/rbot/core/utils/wordlist.rb
lib/rbot/dbhash.rb
lib/rbot/ircbot.rb
lib/rbot/plugins.rb
lib/rbot/registry.rb