Why not adopt me?This distribution is up for adoption! If you're interested then please contact the PAUSE module admins via email.
Bot::Cobalt::Plugin::RDB - Bot::Cobalt "random" DB plugin
Jason Hamilton's darkbot came with the concept of "randstuffs," randomized responses broadcast to channels via a timer.
Later versions included a search interface and "RDBs" -- discrete 'randstuff' databases that could be accessed via 'info' topic triggers to return a random response.
cobalt1 used essentially the same interface. This RDB plugin attempts to expand on that concept.
This functionality is often useful to simulate humanoid responses to conversation (by writing 'conversational' RDB replies triggered by Bot::Cobalt::Plugin::Info3 topics), to implement IRC quotebots, or just to fill your channel with random chatter.
The "randstuff" db is labelled "main" -- all other RDB names must be in the [a-z0-9] set.
Commands are prefixed with the bot's nickname, rather than CmdChar.
This is a holdover from darkbot legacy syntax.
<JoeUser> botnick: randq some*glob
Search for a specified glob in RDB 'main' (randstuffs):
<JoeUser> bot: randq some+string*
See "glob_to_re_str" in Bot::Cobalt::Utils for details regarding glob syntax.
Add a new "randstuff" to the 'main' RDB
<JoeUser> bot: randstuff new randstuff string
A randstuff can also be an action; simply prefix the string with + :
<JoeUser> bot: randstuff +dances around
Legacy darkbot-style syntax is supported; you can add items to RDBs by prefixing the RDB name with ~, like so:
randstuff ~myrdb some new string
The RDB must already exist; see "rdb dbadd"
rdb info <rdb> rdb info <rdb> <itemID>
Given just a RDB name, returns the number of items in the RDB.
Given a RDB name and a valid itemID, returns some metadata regarding the item, including the username that added it and the date it was added.
rdb add <rdb> <new item string>
Add a new item to the specified RDB. Also see "randstuff"
rdb del <rdb> <itemID> [itemID ...]
Deletes items from the specified RDB.
rdb dbadd <rdb>
Creates a new, empty RDB.
rdb dbdel <rdb>
Deletes the specified RDB entirely.
Deletion may be disabled in the plugin's configuration file via the Opts->AllowDelete directive.
rdb search <rdb> <glob>
rdb searchidx <rdb> <glob>
Returns all RDB item IDs matching the specified glob.
rdb count <rdb> <glob>
Returns just the total number of matches for the specified glob.
'random' is not actually a built-in command; however, since you must have Bot::Cobalt::Plugin::Info3, a handy trick is to add a topic named 'random' that triggers RDB 'main':
<JoeUser> bot: add random ~main
That will allow use of 'random' to pull a randomly-selected entry from the 'randstuffs' database.
Called on a timer to broadcast randstuffs from RDB "main."
Takes no arguments.
Triggered (usually by Bot::Cobalt::Plugin::Info3) when a RDB is polled for a random response.
$context, $channel, $nick, $rdb, $topic_value, $original_str
Broadcasts an "info3_relay_string" in response, which is picked up by Info3 to perform variable replacement before relaying back to the calling channel.
$context, $channel, $nick, $string, $original
Jon Portnoy <firstname.lastname@example.org>