Bot::Cobalt::Plugin::Info3 - Text-triggered responses for Bot::Cobalt
<JoeUser> cobaltbot: add hi Howdy N~! <Bob> hi <cobaltbot> Howdy Bob!
darkbot6 came with built-in info2 functionality; text responses (possibly with variables) could be triggered by simple glob matches.
This plugin follows largely the same pattern; users can add a topic:
<JoeUser> cobaltbot: add hello*everyone Howdy N~! Welcome to C~!
Whenever a user says something matching the glob, the response is triggered:
<Somebody> hello there, everyone <cobaltbot> Howdy Somebody! Welcome to #thischannel!
(Note that if multiple added globs match a given IRC string, the result is somewhat unpredictable and will largely depend on what your database gives up first. Managing your topics sanely is up to you.)
Back-end storage takes place via Bot::Cobalt::DB. The core distribution comes with a tool called cobalt2-import-info2 capable of converting darkbot and cobalt1 'info' databases.
By default, the same topic can be requested 4 times in a row before being blocked to prevent loops. This can be adjusted via Opts in your info3.conf:
Opts: MaxTriggered: 2
Add a new info3 topic:
bot: add my+new+topic This is my new topic. bot: add help You're beyond help, N~!
The most common wildcards are * (match any number of any character) and + (match a single space). See "glob_to_re_str" in Bot::Cobalt::Utils for details regarding glob syntax.
Note that ^$ start/end anchors are not valid when adding info3 globs; every glob is automatically anchored.
Variables are available for use in topic responses -- see "Response variables".
A topic response can also be an action ('/me').
In order to send a response as an action, prefix the response with + :
bot: add greetings +waves to N~
Variable replacement works as-normal.
A topic prefixed with
~action is a response to an action:
bot: add ~action+waves +waves back to N~
Deletes the specified topic.
bot: del my+new+topic
Same as doing a 'del' then 'add' for a preexisting topic:
bot: replace this+topic Some new string
Searches for the literal string specified within our stored topics.
bot: search some+topic
Only matches topics -- see "dsearch" to search within responses.
Does a 'deep search,' checking the contents of every topic for a possible match to the specified string.
bot: dsearch N~
Displays the raw (unparsed) topic response.
Useful for checking for variables or RDBs.
Returns metadata regarding when the topic was added and by whom.
You can instruct the bot to "talk" to someone else using tell:
bot: add how+good+is+perl Awesome! bot: tell Somebody about how good is perl
Responses to topics can include variables that are processed before the response string is sent.
These mostly follow legacy darkbot6 syntax.
The following variables are valid:
!~ == Bot's command character B~ == Bot's nick for this server C~ == The current channel H~ == Bot's current nick!user@host N~ == Nickname of the user bot is talking to P~ == Port we're connected to Q~ == Original string bot is responding to R~ == A random nickname from the channel S~ == Server we're connected to t~ == Unix epoch seconds (unixtime) T~ == Human-readable date and time V~ == Current bot version W~ == Cobalt website
Additionally, words in the original string that triggered the response can be pulled out individually by their relative position. The first word is 1~, the second word is 2~, and so forth.
The 'infovars' command will send you a notice briefly describing the available variables; useful for a quick refresher when adding topics.
Topics can also triggered randomized responses, as long as the Bot::Cobalt::Plugin::RDB plugin is loaded.
In order to pull a randomized response from a RDB, a topic should trigger a response starting with '~<rdbname>' -- for example:
bot: add hello ~hi bot: rdb dbadd hi bot: rdb add hi Hello N~! Welcome to C~! bot: rdb add hi How goes it, N~?
See Bot::Cobalt::Plugin::RDB for more details.
Feeds a given string to the response formatter and relays the result back to IRC.
$context, $channel, $nick, $string_to_format, $question_string
Expires MaxTriggered for a particular topic match after 90 seconds.
Broadcast when a topic's response triggers a RDB; see Bot::Cobalt::Plugin::RDB for details.
Jon Portnoy <email@example.com>