NAME

Bot::Cobalt::Plugin::RDB - Bot::Cobalt "random" DB plugin

DESCRIPTION

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.

Requires Bot::Cobalt::Plugin::Info3.

COMMANDS

Commands are prefixed with the bot's nickname, rather than CmdChar.

This is a holdover from darkbot legacy syntax.

<JoeUser> botnick: randq some*glob

randq

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.

randstuff

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

rdb get

rdb get <rdb> <itemID>

Retrieves the specified item from the specified RDB.

rdb info

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 add <rdb> <new item string>

Add a new item to the specified RDB. Also see "randstuff"

rdb del

rdb del <rdb> <itemID> [itemID ...]

Deletes items from the specified RDB.

rdb dbadd

rdb dbadd <rdb>

Creates a new, empty RDB.

rdb dbdel

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>

Search within a specific RDB. Returns a single random response from the result set. Also see "randq" and "glob_to_re_str" in Bot::Cobalt::Utils for more details on search syntax.

rdb searchidx

rdb searchidx <rdb> <glob>

Returns all RDB item IDs matching the specified glob.

rdb count

rdb count <rdb> <glob>

Returns just the total number of matches for the specified glob.

random

'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.

EVENTS

Received events

rdb_broadcast

Self-triggered event.

Called on a timer to broadcast randstuffs from RDB "main."

Takes no arguments.

rdb_triggered

Triggered (usually by Bot::Cobalt::Plugin::Info3) when a RDB is polled for a random response.

Arguments are:

$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.

Emitted events

info3_relay_string

Broadcast by "rdb_triggered" to be picked up by Bot::Cobalt::Plugin::Info3.

Arguments are:

$context, $channel, $nick, $string, $original

AUTHOR

Jon Portnoy <avenj@cobaltirc.org>