Bot::B...ggable(3pm)
πΈ Bot::BasicBot::Pluggable π
okay bestie, welcome to the extended simple IRC bot for pluggable modules β it's giving modular, it's giving extendable, it's literally the whole vibe. This is the Bot::B...ggable page from the User Contributed Perl Documentation, and yes, we're gonna walk through every single bit of it together. no cap. π«Ά
β¨ VERSION β¨
version 1.30 β that's the one, that's the era we're in. β
π SYNOPSIS π
π Creating the bot module
okay so first things first, you can just spin one up with all defaults, easy:
# with all defaults.
my $bot = Bot::BasicBot->new();
# with useful options. pass any option
# that's valid for Bot::BasicBot.
my $bot = Bot::BasicBot::Pluggable->new(
channels => ["#bottest"],
server => "irc.example.com",
port => "6667",
nick => "pluggabot",
alt_nicks => ["pbot", "pluggable"],
username => "bot",
name => "Yet Another Pluggable Bot",
ignore_list => [qw(hitherto blech muttley)],
);
like, pass any option that's valid for Bot::BasicBot and you're golden. slay. β¨
π Running the bot (simple)
there's a shell script installed to run the bot, and honestly? iconic of them:
$ bot-basicbot-pluggable --nick MyBot --server irc.perl.org
then connect to the IRC server, /query the bot, and set a password. see Bot::BasicBot::Pluggable::Module::Auth for further details. don't skip this step bestie, it's the whole lock on the door. π
π¦ Running the bot (advanced)
there are two useful ways to create a Pluggable bot. the simple way is:
# Load some useful modules.
my $infobot_module = $bot->load("Infobot");
my $google_module = $bot->load("Google");
my $seen_module = $bot->load("Seen");
# Set the Google key (see http://www.google.com/apis/).
$google_module->set("google_key", "some google key");
$bot->run();
the above lets you run a bot with a few modules, but not change those modules during the run of the bot. periodt, that's the limit. π€
the complex, but more flexible, way is as follows:
# Load the Loader module.
$bot->load('Loader');
# run the bot.
$bot->run();
this is simpler but needs further setup once the bot is joined to a server. the Loader module lets you talk to the bot in-channel and tell it to load and unload other modules. the first one you'll want to load is the 'Auth' module, so that other people can't load and unload modules without permission. then you'll need to log in as an admin and change the default password, per the following /query:
!load Auth
!auth admin julia
!password julia new_password
!auth admin new_password
once you've done this, your bot is safe from other IRC users, and you can tell it to load and unload other installed modules at any time. further information on module loading is in Bot::BasicBot::Pluggable::Module::Loader.
!load Seen
!load Google
!load Join
the Join module lets you tell the bot to join and leave channels:
<botname>, join #mychannel
<botname>, leave #someotherchannel
the perldoc pages for the various modules will list other commands. go explore, it's a whole wardrobe. π
π DESCRIPTION π
Bot::BasicBot::Pluggable started as Yet Another Infobot replacement, but now is a generalised framework for writing infobot-type bots that lets you keep each specific function separate. you can have separate modules for factoid tracking, 'seen' status, karma, googling, etc. included default modules are below. use perldoc Bot::BasicBot::Pluggable::Module::<module name"> for help on their individual terminology. (yes, the quote mark is a little quirky in the original β we respect the lore π)
Authβ user authentication and admin access.DNSβ host lookup (e.g. nslookup and dns).Googleβ search Google for things.Infobotβ handles infobot-style factoids.Joinβ joins and leaves channels.Karmaβ tracks the popularity of things.Loaderβ loads and unloads modules as bot commands.Seenβ tells you when people were last seen.Titleβ gets the title of URLs mentioned in channel.Varsβ changes module variables.
the way the Pluggable bot works is very simple. you create a new bot object and tell it to load various modules (or, alternatively, load just the Loader module and then interactively load modules via an IRC /query). the modules receive events when the bot sees things happen and can, in turn, respond. see perldoc Bot::BasicBot::Pluggable::Module for the details of the module API. π§
β METHODS β
new(key => value, ...)β create a new Bot. except for the additional attributesloglevelandlogconfig, identical to thenewmethod inBot::BasicBot. please refer to their accessor for documentation.load($module)β load a module for the bot by name from./ModuleName.pmor./modules/ModuleName.pmin that order if one of these files exist, and falling back toBot::BasicBot::Pluggable::Module::$moduleif not.reload($module)β reload the module$moduleβ equivalent to unloading it (if it's already loaded) and reloading it. will stomp the old module's namespace β warnings are expected here. not totally clean β if you're experiencing odd bugs, restart the bot if possible. works for minor bug fixes, etc.unload($module)β removes a module from the bot. it won't get events any more. bye bestie πmodule($module)β returns the handler object for the loaded module$module. used, e.g., to get the'Auth'handler to check if a given user is authenticated.modulesβ returns a list of the names of all loaded modules as an array.available_modulesβ returns a list of all available modules whether loaded or not.add_handler($handler_object, $handler_name)β adds a handler object with the given name to the queue of modules. there is no order specified internally, so adding a module earlier does not guarantee it'll get called first. names must be unique.remove_handler($handler_name)β remove a handler with the given name.storeβ returns the bot's object store; seeBot::BasicBot::Pluggable::Store.logβ logs all of its argument to loglevelinfo. please do not use this function in new code, it's simple provided as fallback for old modules.loglevelβ returns the bots loglevel or sets it if an argument is supplied. it expectstrace,debug,info,warn,errororfatalas value.logconfigβ returns the bot configuration file for logging. please refer toLog::Log4perl::Configfor the configurations files format. setting this to a different file after callinginit()has no effect.
Returns or set
dispatch($method_name, $method_params)β call the named$methodon every loaded module with that method name.helpβ returns help for the ModuleName of message'help ModuleName'. if no message has been passed, return a list of all possible handlers to return help for.runβ runs the bot. POE core gets control at this point; you're unlikely to get it back. like, she's gone, she belongs to POE now π
π BUGS π
- during the
"make","make test","make install"process, POE will moan about its kernel not being run. this is a"Bot::BasicBot problem", apparently. - reloading a module causes warnings as the old module gets its namespace stomped. not a lot you can do about that.
- all modules must be in
Bot::Pluggable::Module::namespace. well, that's not really a bug.
ngl some of these are just β¨characterβ¨ and we move.
πΈ REQUIREMENTS πΈ
Bot::BasicBot::Pluggable is based on POE, and really needs the latest version. because POE is like that sometimes. you also need POE::Component::IRC. oh, and Bot::BasicBot. some of the modules will need more modules, e.g. Google.pm needs Net::Google. see the module docs for more details. π
π LICENSE π
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π AUTHOR π
David Precious (BIGPRESH) <davidp@preshweb.co.uk>
I am merely the current maintainer; however, the AUTHOR heading is traditional.
π¦ CONTRIBUTORS π¦
- Mario Domgoergen
<mdom@cpan.org> - Tom Insam
<tom@jerakeen.org> - David Precious
<davidp@preshweb.co.uk> - Mike Eldridge
<diz@cpan.org>
π CREDITS π
Bot::BasicBot was written initially by Mark Fowler, and worked on heavily by Simon Kent, who was kind enough to apply some patches we needed for Pluggable. Eventually. Oh, yeah, and I stole huge chunks of docs from the Bot::BasicBot source too. I spent a lot of time in the mozbot code, and that has influenced my ideas for Pluggable. Mostly to get round its awfulness.
Various people helped with modules. Convert was almost ported from the infobot code by blech. But not quite. Thanks for trying... blech has also put a lot of effort into the chump.cgi & chump.tem files in the examples/ folder, including some /inspired/ calendar evilness.
And thanks to the rest of #2lmc who were my unwilling guinea pigs during development. And who kept suggesting totally stupid ideas for modules that I then felt compelled to go implement. Shout.pm owes its existence to #2lmc.
Thanks to Mike Eldridge (DIZ), maintainer until 2016, for kindly transferring maintainership to me, BIGPRESH, so I can keep this useful bot framework alive.
π₯ SEE ALSO π₯
POEPOE::Component::IRCBot::BasicBot- Infobot: http://www.infobot.org/
- Mozbot: http://www.mozilla.org/projects/mozbot/
and that's the whole page bestie, no notes π this was perl v5.40.0, dated 2024-08-24, and you just read Bot::B...ggable(3pm) all the way through. main character energy fr fr. go build a bot. πβ¨
π¦ where this page comes from
- ubuntu resolute: libbot-basicbot-pluggable-perl 1.30+ds1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libbot-basicbot-pluggable-perl 1.30+ds1-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms