From 3aea9c009be1f360a1f9269eb90027bef3533d47 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 22 Dec 2019 20:33:50 -0800 Subject: [PATCH] PBot.md: convert from MediaWiki markdown to common markdown --- doc/PBot.md | 2226 ++++++++++++++++++++++++++------------------------- 1 file changed, 1146 insertions(+), 1080 deletions(-) diff --git a/doc/PBot.md b/doc/PBot.md index c5458036..bc456bd2 100644 --- a/doc/PBot.md +++ b/doc/PBot.md @@ -1,1568 +1,1634 @@ -==PBot== -===About PBot=== -PBot is an IRC bot written in Perl in pragma_'s spare time. +PBot +==== -====Source==== +About PBot +---------- +PBot is an IRC bot written in Perl in pragma-'s spare time. + +### Source PBot's source may be found at these repositories: - * https://github.com/pragma-/pbot - * https://bitbucket.org/pragmasoft/pbot/src + * [https://github.com/pragma-/pbot](https://github.com/pragma-/pbot) + * [https://bitbucket.org/pragmasoft/pbot/src](https://bitbucket.org/pragmasoft/pbot/src) -The URL for the source of any loaded modules may be found by using the [[#factinfo|factinfo]] command: +The URL for the source of any loaded modules may be found by using the [factinfo](#factinfo) command: - factinfo ##c faq - faq: Module loaded by pragma_ on Fri Dec 31 02:34:04 2004 -> - https://github.com/pragma-/pbot/blob/master/modules/cfaq.pl, used 512 times (last by ecrane) -G -====Bot Channel==== -You may test/play with the bot in the #pbot2 channel on irc.freenode.net. + factinfo ##c faq + faq: Module loaded by pragma- on Fri Dec 31 02:34:04 2004 -> https://github.com/pragma-/pbot/blob/master/modules/cfaq.pl, used 512 times (last by ecrane) -===Trigger=== -All of '''PBot''''s commands may begin with its name or its trigger, or be followed by its name. +### Bot Channel +You may test/play with PBot in the `#pbot2` channel on `irc.freenode.net`. -The trigger character defaults to exclaimation mark [!]. +Trigger +------- +All of PBot's commands may begin with its name or its trigger, or be followed by its name. -Note that commands need not be submitted to the channel; you can /msg it instead. If you /msg '''PBot''', it will respond with a private message in return. In private message, you do not need to specify its name or one of the trigger symbols. +The trigger character defaults to exclaimation mark `!`. - Examples: - !hi - hi, PBot - PBot: hi +Note that commands need not be submitted to the channel; you can /msg it instead. If you /msg PBot, it will respond with a private message in return. In private message, you do not need to specify its name or one of the trigger symbols. -====Embedded trigger==== + !hi + hi, PBot + PBot: hi +### Embedded trigger Many commands may be triggered from within a sentence by adding curly braces or backticks around the command after the trigger. You can embed up to three commands in one message. If the sentence begins with a nick that is currently in the channel, the command's response will be prefixed with that nick. - Example: - Alice: Check out !{K&R} for a good book on C. !`H&S` is also a great reference manual. - Alice: K&R is The C Programming Language, 2nd edition, by Kernighan and Ritchie - - http://wayback.archive-it.org/5263/20150203070038/http://cm.bell-labs.com/cm/cs/cbook/ - - errata: http://www.iso-9899.info/2ediffs.html - Alice: H&S is "C - A Reference Manual" by Harbison & Steele; a reference for C on par with K&R - - http://www.amazon.com/Reference-Manual-Samuel-P-Harbison/dp/013089592X + Alice: Check out !{K&R} for a good book on C. !`H&S` is also a great reference manual. + Alice: K&R is The C Programming Language, 2nd edition, by Kernighan and Ritchie - http://wayback.archive-it.org/5263/20150203070038/http://cm.bell-labs.com/cm/cs/cbook/ - errata: http://www.iso-9899.info/2ediffs.html + Alice: H&S is "C - A Reference Manual" by Harbison & Steele; a reference for C on par with K&R - http://www.amazon.com/Reference-Manual-Samuel-P-Harbison/dp/013089592X -====Directing output to a user==== +### Directing output to a user There are several ways to direct PBot to prepend the nickname of a specific person to a command in a channel. You may state the nickname after the command (if the command doesn't take arguments): - PBot: version defrost - defrost: PBot revision 387 2012-10-07 + PBot: version defrost + defrost: PBot revision 387 2012-10-07 You may prefix a command with the nickname: - randomjoe: !help cjeopardy - randomjoe: To learn all about cjeopardy, see http://www.iso-9899.info/wiki/PBot#cjeopardy + randomjoe: !help cjeopardy + randomjoe: To learn all about cjeopardy, see http://www.iso-9899.info/wiki/PBot#cjeopardy -You may use [[#Embedded_trigger|embedded command triggering]] in a message addressed at a nickname: +You may use [embedded command triggering](#Embedded_trigger) in a message addressed at a nickname: - randomjoe: PBot is at !{version}, to learn more check out its !{help} page - randomjoe: PBot revision 387 2012-10-07 - randomjoe: To learn all about me, see http://www.iso-9899.info/wiki/PBot + randomjoe: PBot is at !{version}, to learn more check out its !{help} page + randomjoe: PBot revision 387 2012-10-07 + randomjoe: To learn all about me, see http://www.iso-9899.info/wiki/PBot -=====tell===== +#### tell You may use the `tell about ` syntax: - PBot: tell defrost about help cc - defrost: To learn all about cc, see http://www.iso-9899.info/wiki/PBot#cc + PBot: tell defrost about help cc + defrost: To learn all about cc, see http://www.iso-9899.info/wiki/PBot#cc -==Registry== +Registry +======== PBot's behavior can be customized via a central registry of key/value pairs segregated by sections. There are two types of registry values: literals and arrays. Literals can be strings, floats or integers. Arrays are comma-separated lists of literals. -===Overriding registry values per-channel=== +Overriding registry values per-channel +-------------------------------------- Some key/value pairs belonging to a specific section may be overridden on a per-channel basis by setting the key/value in a channel-specific section. -For example, the bot's trigger is defined in general->trigger. You may add a trigger key in #channel to override the trigger value for that channel: #channel->trigger. +For example, the bot's trigger is defined in `general.trigger`. You may add a trigger key in `#channel` to override the trigger value for that channel: `#channel.trigger`. -For another example, the anti-flood max lines is defined in antiflood->chat_flood_threshold. To override this setting in #coolchannel, you can set #coolchannel->chat_flood_threshold. +For another example, the anti-flood max lines is defined in `antiflood.chat_flood_threshold`. To override this setting in `#neatchannel`, you can set `#neatchannel.chat_flood_threshold`. -===regadd=== -regadd adds a new registry value to a specific section/channel. +regadd +------ +`regadd` adds a new registry value to a specific section/channel. - Usage: regadd
+Usage: `regadd
` - Example: - regadd #mychannel trigger [,!%] - [#mychannel] trigger set to [,!%] +For example, to override the trigger for #mychannel to be any of `,`, `!` or `%`: -Some registry values can be regular expressions, like the above trigger example. Setting general->trigger to the character class [,!%] means that it will respond to , ! and % as trigger characters on a general basis. You can set #somechannel->trigger to something else to override this for that specific channel. + regadd #mychannel trigger [,!%] + [#mychannel] trigger set to [,!%] -===regrem=== -regrem removes a registry key from a specific section/channel. +Some registry values can be *regular expressions*, like the above trigger example. Setting `general.trigger` to the character class `[,!%]` means that it will respond to `,` `!` and `%` as trigger characters on a general basis. - Usage: regrem
+regrem +------ +`regrem` removes a registry key from a specific section/channel. -===regshow=== -regshow displays the type and value of a specific key. +Usage: `regrem
` - Usage: regshow
+regshow +------- +`regshow` displays the type and value of a specific key. - Example: - regshow antiflood chat_flood_punishment - [antiflood] chat_flood_punishment: 60,300,3600,86400,604800,2419200 [array] +Usage: `regshow
` -===regset=== -regset sets the meta-data values for a specific registry key. See [[#Registry_metadata_list|registry meta-data list]]. + regshow antiflood chat_flood_punishment + [antiflood] chat_flood_punishment: 60,300,3600,86400,604800,2419200 [array] -If you omit the argument, it will list all the defined keys and values for the registry item. If you specify but omit , it will show the value for that specific key. +regset +------ +`regset` sets the meta-data values for a specific registry key. See [registry meta-data list](#Registry_metadata_list). - Usage: regset
[key [value]] +If you omit the `` argument, it will list all the defined keys and values for the registry item. If you specify `` but omit ``, it will show the value for that specific key. - Example: - regset irc botnick value pangloss - * PBot changed nick to pangloss - [irc] botnick: 'value' set to 'pangloss' +Usage: `regset
[key [value]]` -====Registry metadata list==== + regset irc botnick value pangloss + * PBot changed nick to pangloss + [irc] botnick: 'value' set to 'pangloss' + +### Registry metadata list This is a list of recognized registry meta-data keys. -* ''type'': sets the type of this registry key; ''text'' (literal) or ''array''. -* ''value'': the value of this registry key. -* ''private'': whether the value of the registry key is displayed in regset, regshow or regfind. If set to a true value, the value of the registry key will be shown as "". +* `type`: sets the type of this registry key; values can be `text` (literal) or `array`. +* `value`: the value of this registry key. +* `private`: whether the value of the registry key is displayed in regset, regshow or regfind. If set to a true value, the value of the registry key will be shown as "**\**". -===regunset=== -regunset deletes a meta-data key from a registry key. +regunset +-------- +`regunset` deletes a meta-data key from a registry key. - Usage: regunset
+Usage: `regunset
` -===regchange=== -regchange changes the value of a registry item using a regular substitution expression. +regchange +--------- +`regchange` changes the value of a registry item using a *regular substitution expression*. - Usage: regchange
s/// +Usage: `regchange
s///` - Example: - regadd foo bar Hello, world! - [foo] bar set to Hello, world! - regchange foo bar s/world/universe/ - [foo] bar set to Hello, universe! + regadd foo bar Hello, world! + [foo] bar set to Hello, world! + regchange foo bar s/world/universe/ + [foo] bar set to Hello, universe! -===regfind=== -regfind searches for registry items, and may optionally show the values of all matching items. +regfind +------- +`regfind` searches for registry items, and may optionally show the values of all matching items. - Usage: regfind [-showvalues] [-section
] +Usage: `regfind [-showvalues] [-section
] ` -To limit the search to a specific section, use -section
. To dump the entire registry, use `regfind -showvalues .*` +To limit the search to a specific section, use `-section
`. To dump the entire registry, use `regfind -showvalues .*` -===Creating array values=== -Use the [[#regset|regset]] command to change the ''type'' meta-data value to "array", and set the registry value to a comma-separated list of values. +Creating array values +--------------------- +Use the [regset](#regset) command to change the `type` meta-data value to "array", and set the registry value to a comma-separated list of values. - Example: - regadd foo animals aardvark, badger, cat, dingo - [foo] animals set to aardvark, badger, cat, dingo - regset foo animals type array - [foo] animals: 'type' set to 'array' + regadd foo animals aardvark, badger, cat, dingo + [foo] animals set to aardvark, badger, cat, dingo + regset foo animals type array + [foo] animals: 'type' set to 'array' -===List of recognized registry items=== +List of recognized registry items +--------------------------------- -* antiaway->bad_actions -* antiaway->bad_nicks -* antiaway->kick_msg -* antiflood->chat_flood_punishment -* antiflood->chat_flood_threshold -* antiflood->chat_flood_time_threshold -* antiflood->debug_checkban -* antiflood->dont_enforce_admins -* antiflood->enforce -* antiflood->enter_abuse_max_offenses -* antiflood->enter_abuse_punishment -* antiflood->enter_abuse_threshold -* antiflood->enter_abuse_time_threshold -* antiflood->join_flood_punishment -* antiflood->join_flood_threshold -* antiflood->join_flood_time_threshold -* antiflood->nick_flood_punishment -* antiflood->nick_flood_threshold -* antiflood->nick_flood_time_threshold -* antikickautorejoin->punishment -* antikickautorejoin->threshold -* bantracker->chanserv_ban_timeout -* bantracker->debug -* bantracker->mute_timeout -* factoids->default_rate_limit -* general->compile_blocks_channels -* general->compile_blocks -* general->compile_blocks_ignore_channels -* general->config_dir -* general->data_dir -* general->deop_timeout -* general->module_dir -* general->module_repo -* general->paste_ratelimit -* general->show_url_titles_channels -* general->show_url_titles -* general->show_url_titles_ignore_channels -* general->trigger -* interpreter->max_recursion -* irc->botnick -* irc->debug -* irc->identify_password -* irc->ircname -* irc->ircserver -* irc->log_default_handler -* irc->max_msg_len -* irc->port -* irc->show_motd -* irc->SSL_ca_file -* irc->SSL_ca_path -* irc->SSL -* irc->username -* lagchecker->lag_history_interval -* lagchecker->lag_history_max -* lagchecker->lag_threshold -* messagehistory->debug_aka -* messagehistory->debug_link -* messagehistory->max_messages -* messagehistory->sqlite_commit_interval -* messagehistory->sqlite_debug -* nicklist->debug -* [channel]->dont_enforce_antiflood -* [channel]->max_newlines -* [channel]->no_url_titles -* [channel]->no_compile_blocks -* [channel]->preserve_newlines +* antiaway.bad_actions +* antiaway.bad_nicks +* antiaway.kick_msg +* antiflood.chat_flood_punishment +* antiflood.chat_flood_threshold +* antiflood.chat_flood_time_threshold +* antiflood.debug_checkban +* antiflood.dont_enforce_admins +* antiflood.enforce +* antiflood.enter_abuse_max_offenses +* antiflood.enter_abuse_punishment +* antiflood.enter_abuse_threshold +* antiflood.enter_abuse_time_threshold +* antiflood.join_flood_punishment +* antiflood.join_flood_threshold +* antiflood.join_flood_time_threshold +* antiflood.nick_flood_punishment +* antiflood.nick_flood_threshold +* antiflood.nick_flood_time_threshold +* antikickautorejoin.punishment +* antikickautorejoin.threshold +* bantracker.chanserv_ban_timeout +* bantracker.debug +* bantracker.mute_timeout +* factoids.default_rate_limit +* general.compile_blocks_channels +* general.compile_blocks +* general.compile_blocks_ignore_channels +* general.config_dir +* general.data_dir +* general.deop_timeout +* general.module_dir +* general.module_repo +* general.paste_ratelimit +* general.show_url_titles_channels +* general.show_url_titles +* general.show_url_titles_ignore_channels +* general.trigger +* interpreter.max_recursion +* irc.botnick +* irc.debug +* irc.identify_password +* irc.ircname +* irc.ircserver +* irc.log_default_handler +* irc.max_msg_len +* irc.port +* irc.show_motd +* irc.SSL_ca_file +* irc.SSL_ca_path +* irc.SSL +* irc.username +* lagchecker.lag_history_interval +* lagchecker.lag_history_max +* lagchecker.lag_threshold +* messagehistory.debug_aka +* messagehistory.debug_link +* messagehistory.max_messages +* messagehistory.sqlite_commit_interval +* messagehistory.sqlite_debug +* nicklist.debug +* [channel].dont_enforce_antiflood +* [channel].max_newlines +* [channel].no_url_titles +* [channel].no_compile_blocks +* [channel].preserve_newlines -==Factoids== +Factoids +======== -===List of factoids=== -The most recent exported list of factoids can be found here: -[http://www.iso-9899.info/PBot/factoids.html http://www.iso-9899.info/PBot/factoids.html]. +### Channel namespaces +Factoids added in one channel may be called/triggered in another channel or in private message, providing that the other channel doesn't already have a factoid of the same name (in which case that channel's factoid will be triggered). -====Channel namespaces==== +Factoids may also be added to a special channel named `global` or `.*`. Factoids that are set in this channel will be accessible to any channel, including private messages. However, factoids that are set in a specific channel will override factoids of the same name that are set in the global channel or other channels. -Factoids added in one channel may be called/triggered in another channel or in private message, providing that the other channel doesn't already have a factoid of the same name. +For example, a factoid named `malloc` set in `##c` will be called instead of `malloc` set in `global`, if the factoid were triggered in `##c`; otherwise, the latter 'malloc' will be triggered if the factoid were triggered in another channel. -Factoids may also be added to a special channel named global. Factoids that are set in this channel will be accessible to any channel, including private messages. However, factoids that are set in a specific channel will override factoids of the same name that are set in the global channel or other channels. +Similiarily, if there were no `malloc` factoid in the `global` namespace, but only in `##c` and you attempted to use this factoid in a channel other than `##c`, that channel will invoke `##c`'s version of `malloc`, providing that channel doesn't have its own `malloc` factoid. -For example, a factoid named 'malloc' set in ##c will be called instead of 'malloc' set in global, -if the factoid were triggered in ##c; otherwise, the latter 'malloc' will be triggered if the factoid were triggered in another channel. +Likewise, if there is a `malloc` factoid set in `##c++` and the factoid is triggered in the `##c++` channel, then this version of `malloc` will be called instead of the `##c` or the `global` factoid. -Similiarily, if there were no 'malloc' factoid in the global namespace, but only in ##c and you attempted to use this factoid in a channel other than ##c, that channel will invoke ##c's version of 'malloc', providing that channel doesn't have its own 'malloc' factoid. +However, if you are in a channel that doesn't have a `malloc` factoid and there is no `malloc` factoid in the global channel, and you attempt to call `malloc` then the bot will display a message notifying you that `malloc` is ambiguous and which channels it belongs to so that you may use the [fact](#fact) command to call the correct factoid. -Likewise, if there is a 'malloc' factoid set in ##c++ and the factoid is triggered in the ##c++ channel, -then this version of 'malloc' will be called instead of the ##c or the global factoid. +Adding a factoid +---------------- +### factadd +Usage: `factadd [channel] ` -However, if you are in a channel that doesn't have a 'malloc' factoid and there is no 'malloc' factoid in the global channel, and you attempt to call 'malloc' then the bot will display a message notifying you that 'malloc' is ambiguous and which channels it belongs to so that you may use the [[#fact|fact]] command to call the correct factoid. +To add a factoid to the global channel, use `global` or `.*` as the channel. `.*` is regex-speak for "everything". -===Adding a factoid=== -====factadd==== - Usage: - factadd [channel] + factadd ##c c /say C rocks! -To add a factoid to the global channel, use global as the channel. +### Special commands +#### /say +If a factoid begins with `/say ` then PBot will not use the ` is ` format when displaying the factoid. - Example: - factadd ##c c /say C rocks! + factadd global hi /say Well, hello there, $nick. + 'hi' added to the global channel + PBot, hi + Well, hello there, prec. -====Special commands==== -=====/say===== -If a factoid begins with "/say " then PBot will not use -the " is " format when displaying the -factoid. - Example: - factadd global hi /say Well, hello there, $nick. - 'hi' added to the global channel - PBot, hi - Well, hello there, prec. +#### /me +If a factoid begins with `/me ` then PBot will ACTION the factoid. -=====/me===== -If a factoid begins with "/me " then PBot will ACTION the factoid. - Example: - factadd global bounce /me bounces around. - 'bounce' added to the global channel - bounce - *PBot bounces around. + factadd global bounce /me bounces around. + 'bounce' added to the global channel + bounce + * PBot bounces around. -=====/call===== -If a factoid begins with "/call " then PBot will call an existing command. - Example: - factadd global boing /call bounce - 'boing' added to the global channel - boing - *PBot bounces around. +#### /call +If a factoid begins with `/call ` then PBot will call an existing command. -=====/msg===== -If a factoid begins with "/msg " then PBot will /MSG the factoid -text to + factadd global boing /call bounce + 'boing' added to the global channel + boing + * PBot bounces around. -====Special variables==== +#### /msg +If a factoid begins with `msg ` then PBot will /MSG the factoid text to + +### Special variables You can use the following variables in a factoid or as an argument to one. -=====$nick===== -$nick expands to the nick of the caller. -=====$args===== -$args expands to any text following the keyword. If there is no text then it expands to the nick of the caller. -=====$arg[n]===== -$arg[n] expands to the nth argument. Indexing begins from 0 (the first argument is $arg[0]). You may use a negative number to count from the end; e.g., $arg[-2] means the 2nd argument from the end. Multiple words can be double-quoted to constitute one argument. If the argument does not exist, the variable and the leading space before it will be silently removed. +#### $nick +`$nick` expands to the nick of the caller. -=====$arg[n:m]===== -$arg[n:m] expands to a slice of arguments between n and m. Indexing begins from 0 (the first argument is $arg[0]). Not specifying the m value means the rest of the arguments; e.g., $arg[2:] means the remaining arguments after the first two. Multiple words can be double-quoted to constitute one argument. If the argument does not exist, the variable and the leading space before it will be silently removed. -=====$arglen===== -$arglen expands to the number of arguments provided to a factoid. +#### $args +`$args` expands to any text following the keyword. If there is no text then it expands to the nick of the caller. -=====$channel===== -$channel expands to the name of the channel in which the factoid is used. -=====$randomnick===== -$randomnick expands to a random nick from the channel in which the factoid is used. -=====$0===== -$0 expands to the original keyword used to invoke a factoid. +#### $arg[n] +`$arg[n]` expands to the nth argument. Indexing begins from 0 (the first argument is `$arg[0]`). You may use a negative number to count from the end; e.g., `$arg[-2]` means the 2nd argument from the end. Multiple words can be double-quoted to constitute one argument. If the argument does not exist, the variable and the leading space before it will be silently removed. -====adlib list variables==== -You may create a list of adlib words by using the normal factoid creation method. -Multiple words can be surrounded with double quotes to constitute one element. - Example: - factadd global colors is red green blue "bright yellow" pink "dark purple" orange - 'colors' added to the global channel +#### $arg[n:m] +`$arg[n:m]` expands to a slice of arguments between `n` and `m`. Indexing begins from 0 (the first argument is `$arg[0]`). Not specifying the `m` value means the rest of the arguments; e.g., `$arg[2:]` means the remaining arguments after the first two. Multiple words can be double-quoted to constitute one argument. If the argument does not exist, the variable and the leading space before it will be silently removed. -Then you can instruct PBot to pick a random word from this list to use in another factoid by -inserting the list as a variable. - Example: - factadd global sky is /say The sky is $colors. - 'sky' added to the global channel - sky - The sky is dark purple. - sky - The sky is green. +#### $arglen +`$arglen` expands to the number of arguments provided to a factoid. + +#### $channel +`$channel` expands to the name of the channel in which the factoid is used. + +#### $randomnick +`$randomnick` expands to a random nick from the channel in which the factoid is used. + +#### $0 +`$0` expands to the original keyword used to invoke a factoid. See also [Overriding $0](#Overriding_$0). + +### adlib list variables +You may create a list of adlib words by using the normal factoid creation method. Multiple words can be surrounded with quotes to constitute one element. + + factadd global colors is red green blue "bright yellow" pink "dark purple" orange + colors added to the global channel + +Then you can instruct PBot to pick a random word from this list to use in another factoid by inserting the list as a variable. + + factadd global sky is /say The sky is $colors. + sky added to the global channel + sky + The sky is dark purple. + sky + The sky is green. A practical example, creating the RTFM trigger: - factadd global sizes is big large tiny small huge gigantic teeny - 'sizes' added to the global channel - factadd global attacks is whaps thwacks bashes smacks punts whacks - 'attacks' added to the global channel - factadd global rtfm is /me $attacks $args with a $sizes $colors manual. - 'rtfm' added to the global channel - rtfm mauke - * PBot thwacks mauke with a big red manual. -=====modifiers===== + factadd global sizes is big large tiny small huge gigantic teeny + 'sizes' added to the global channel + factadd global attacks is whaps thwacks bashes smacks punts whacks + 'attacks' added to the global channel + factadd global rtfm is /me $attacks $args with a $sizes $colors manual. + 'rtfm' added to the global channel + rtfm mauke + * PBot thwacks mauke with a big red manual. + +#### modifiers Adlib list variables can accept trailing modifier keywords prefixed with a colon. These can be chained together to combine their effects. -* :uc - uppercases the expansion -* :lc - lowercases the expansion -* :ucfirst - uppercases the first letter in the expansion -* :title - lowercases the expansion and then uppercases the first letter (effectively an alias for :lc:ucfirst) -* : - looks for variable in first; use "global" to refer to the global channel +* `:uc` - uppercases the expansion +* `:lc` - lowercases the expansion +* `:ucfirst` - uppercases the first letter in the expansion +* `:title` - lowercases the expansion and then uppercases the initial letter of each word +* `:` - looks for variable in `` first; use `global` to refer to the global channel - Example: - echo $colors:uc - RED - echo $colors:ucfirst - Blue -====code-factoids==== + echo $colors:uc + RED + echo $colors:ucfirst + Blue + +### code-factoids Code-factoids are a special type of factoid whose text is executed as Perl instructions. The return value from these instructions is the final text of the factoid. This final text is then parsed and treated like any other factoid text. By default, the variables created within code-factoids do not persist between factoid invocations. This behavior can be overridden by factsetting a persist-key with a unique value. To create a code-factoid, simply wrap the factoid text with curly braces. - factadd keyword { code here } + factadd keyword { code here } -=====Special variables===== +#### Special variables There are some special variables available to code-factoids. -* @args - any arguments passed to the factoid (note that invoker's nick is passed if no arguments are specified) -* $nick - nick of the person invoking the factoid -* $channel - channel in which the factoid is being invoked +* `@args` - any arguments passed to the factoid (note that invoker's nick is passed if no arguments are specified) +* `$nick` - nick of the person invoking the factoid +* `$channel` - channel in which the factoid is being invoked -=====testargs example===== +#### testargs example - factadd global testargs { return "/say No arguments!" if not @args; - if (@args == 1) { return "/say One argument: $args[0]!" } elsif - (@args == 2) { return "/say Two arguments: $args[0] and $args[1]!"; } - my $results = join ', ', @args; return "/say $results"; } - testargs added to the global channel. - testargs - One argument: pragma-! - testargs "abc 123" xyz - Two arguments: abc 123 and xyz! + factadd global testargs { return "/say No arguments!" if not @args; + if (@args == 1) { return "/say One argument: $args[0]!" } elsif + (@args == 2) { return "/say Two arguments: $args[0] and $args[1]!"; } + my $results = join ', ', @args; return "/say $results"; } + testargs added to the global channel. + testargs + One argument: pragma-! + testargs "abc 123" xyz + Two arguments: abc 123 and xyz! -=====rtfm example===== +#### rtfm example Remember that `rtfm` factoid from earlier? Let's modify it so that it doesn't attack Zhivago. - forget rtfm - rtfm removed from the global channel. - factadd global rtfm { return "/say Nonsense! Zhivago is a gentleman and - a scholar." if $nick eq "Zhivago" or "@args" =~ /zhivago/i; return "/me - $attacks $args[0] with a $sizes $colors manual." } - rtfm added to the global channel. - rtfm luser - * PBot smacks luser with a huge blue manual. - rtfm Zhivago - Nonsense! Zhivago is a gentleman and a scholar. + forget rtfm + rtfm removed from the global channel. + factadd global rtfm { return "/say Nonsense! Zhivago is a gentleman and + a scholar." if $nick eq "Zhivago" or "@args" =~ /zhivago/i; return "/me + $attacks $args[0] with a $sizes $colors manual." } + rtfm added to the global channel. + rtfm luser + * PBot smacks luser with a huge blue manual. + rtfm Zhivago + Nonsense! Zhivago is a gentleman and a scholar. -=====poll example===== +#### poll example An extremely basic aye/nay poll system. All code-factoids sharing the same persist-key will share the same persisted variables. First we add the factoids: - factadd global startpoll { %aye = (); %nay = (); $question = "@args"; - "/say Starting poll: $question" } - startpoll added to the global channel. - factadd global aye { $aye{$nick} = 1; delete $nay{$nick}; "" } - aye added to the global channel. - factadd global nay { $nay{$nick} = 1; delete $aye{$nick}; "" } - nay added to the global channel. - factadd global pollresults { $ayes = keys %aye; $nays = keys %nay; - "/say Results for poll \"$question\": ayes: $ayes, nays: $nays" } - pollresults added to the global channel. + factadd global startpoll { %aye = (); %nay = (); $question = "@args"; + "/say Starting poll: $question" } + startpoll added to the global channel. + factadd global aye { $aye{$nick} = 1; delete $nay{$nick}; "" } + aye added to the global channel. + factadd global nay { $nay{$nick} = 1; delete $aye{$nick}; "" } + nay added to the global channel. + factadd global pollresults { $ayes = keys %aye; $nays = keys %nay; + "/say Results for poll \"$question\": ayes: $ayes, nays: $nays" } + pollresults added to the global channel. Then we set their persist-key to the same value: - factset global startpoll persist-key pragma-poll - [global] startpoll: 'persist-key' set to 'pragma-poll' - factset global aye persist-key pragma-poll - [global] aye: 'persist-key' set to 'pragma-poll' - factset global nay persist-key pragma-poll - [global] nay: 'persist-key' set to 'pragma-poll' - factset global pollresults persist-key pragma-poll - [global] pollresults: 'persist-key' set to 'pragma-poll' + factset global startpoll persist-key pragma-poll + [global] startpoll: 'persist-key' set to 'pragma-poll' + factset global aye persist-key pragma-poll + [global] aye: 'persist-key' set to 'pragma-poll' + factset global nay persist-key pragma-poll + [global] nay: 'persist-key' set to 'pragma-poll' + factset global pollresults persist-key pragma-poll + [global] pollresults: 'persist-key' set to 'pragma-poll' And action: - startpoll Isn't this cool? - Starting poll: Isn't this cool? - aye - nay - aye - pollresults - Results for poll "Isn't this cool?": ayes: 2, nays: 1 + startpoll Isn't this cool? + Starting poll: Isn't this cool? + aye + nay + aye + pollresults + Results for poll "Isn't this cool?": ayes: 2, nays: 1 -* Exercise for the reader: extend this poll system to be per-channel using $channel. +* Exercise for the reader: extend this poll system to be per-channel using `$channel`. * Experts: extend this to use a `vote ` factoid, and adjust `pollresults` to show a tally for each keyword. -====action_with_args==== +### action_with_args -You can use the [[#factset|factset]] command to set a special factoid meta-data key named "action_with_args" to trigger an alternate message if an argument has been supplied. +You can use the [factset](#factset) command to set a special factoid meta-data key named `action_with_args` to trigger an alternate message if an argument has been supplied. - Example: - factadd global snack is /me eats a cookie. - 'snack' added to the global channel - factset global snack action_with_args /me gives $args a cookie. - [Factoids] (global) snack: 'action_with_args' set to '/me gives $args a cookie.' - snack - * PBot eats a cookie. - snack orbitz - * PBot gives orbitz a cookie. + factadd global snack is /me eats a cookie. + 'snack' added to the global channel + factset global snack action_with_args /me gives $args a cookie. + [Factoids] (global) snack: 'action_with_args' set to '/me gives $args a cookie.' + snack + * PBot eats a cookie. + snack orbitz + * PBot gives orbitz a cookie. -====add_nick==== +### add_nick -You can use the [[#factset|factset]] command to set a special factoid meta-data key named "add_nick" to prepend the nick of the caller to the output. This is mostly useful for modules. +You can use the [factset](#factset) command to set a special factoid meta-data key named `add_nick` to prepend the nick of the caller to the output. This is mostly useful for modules. -===Deleting a factoid=== -====factrem==== -====forget==== +Deleting a factoid +------------------ +### factrem +### forget -To remove a factoid, use the factrem or forget command. The syntax is: +To remove a factoid, use the `factrem` or `forget` command. - factrem - forget +Usage: `factrem ` `forget ` -===Viewing/triggering a factoid=== +Viewing/triggering a factoid +---------------------------- To view or trigger a factoid, one merely issues its keyword as a command. - PBot, c? - C rocks! -===Viewing/triggering another channel's factoid=== -====fact==== -To view or trigger a factoid belonging to a specific channel, use the fact command: + PBot, c? + C rocks! - fact [arguments] +Viewing/triggering another channel's factoid +-------------------------------------------- +### fact +To view or trigger a factoid belonging to a specific channel, use the `fact` command. -===Aliasing a factoid=== -====factalias==== -To create an factoid that acts as an alias for a command, use the 'factalias' command or ' is /call '. +Usage: `fact [arguments]` - is /call +Aliasing a factoid +------------------ +### factalias +To create an factoid that acts as an alias for a command, use the `factalias` command or set the factoid's `action` to `/call `. -The syntax for 'factalias' is: +Usage: `factalias ` - factalias + factadd ##c offtopic is /say In this channel, $args is off-topic. + offtopic C++ + In this channel, C++ is off-topic. + factalias ##c C++ offtopic C++ + C++ + In this channel, C++ is off-topic. - Example: - factadd ##c book is /me points accusingly at $args, "Where is your book?!" - 'book' added to ##c - book newbie - *PBot points accusingly at newbie, "Where is your book?!" - factadd ##c rafb is /call book - 'rafb' added to ##c - rafb runtime - *PBot points accusingly at runtime, "Where is your book?!" + - Another example: - factadd ##c offtopic is /say In this channel, '$args' is off-topic. - offtopic C++ - In this channel, 'C++' is off-topic. - factalias ##c C++ offtopic C++ ''(alternatively: factadd ##c C++ is /call offtopic C++)'' - C++ - In this channel, 'C++' is off-topic. + factadd ##c book is /me points accusingly at $args, "Where is your book?!" + 'book' added to ##c + book newbie + * PBot points accusingly at newbie, "Where is your book?!" + factadd ##c rafb /call book + 'rafb' added to ##c + rafb runtime + * PBot points accusingly at runtime, "Where is your book?!" -===Moving/renaming a factoid=== -====factmove==== -To rename a factoid or move a factoid to a different channel, use the 'factmove' command: +Moving/renaming a factoid +------------------------- +### factmove +To rename a factoid or move a factoid to a different channel, use the `factmove` command: - Usage: factmove [target factoid] +Usage: `factmove [target factoid]` If three arguments are given, the factoid is renamed in the source channel. If four arguments are given, the factoid is moved to the target channel with the target name. -===Changing a factoid=== -====factchange==== -To change a factoid, use the 'factchange' command: - Usage: factchange s///
- c - C rocks! - factchange ##c c s/rocks/rules/ - c changed. - c - C rules! +Changing a factoid +------------------ +### factchange +To change a factoid, use the `factchange` command: -Note that the final argument is a Perl-style substitution regex. See 'man perlre'. +Usage: `factchange s///[gi]` - For instance, it is possible to append to a factoid by using: - 'factchange channel factoid s/$/text to append/' + c + C rocks! + factchange ##c c s/rocks/rules/ + c changed. + c + C rules! - Likewise, you can prepend to a factoid by using: - 'factchange channel factoid s/^/text to prepend/' +Note that the final argument is a Perl-style substitution regex. See `man perlre` on your system. -Alternatively, you may append to a factoid by using 'is also': - PBot, c is also See FAQ at http://www.eskimo.com/~scs/C-faq/top.html - Changed: c is /say C rules! ; See FAQ at http://www.eskimo.com/~scs/C-faq/top.html +For instance, it is possible to append to a factoid by using: `factchange channel factoid s/$/text to append/` -====factundo==== -To revert to an older revision, use the 'factundo' command. You can repeatedly factundo a factoid until it has no more remaining undos. - Usage: factundo [channel] +Likewise, you can prepend to a factoid by using: `factchange channel factoid s/^/text to prepend/` -====factredo==== -To revert to a newer revision, use the 'factredo' command. You can repeatedly factredo a factoid until it has no more remaining redos. - Usage: factredo [channel] +Alternatively, you may append to a factoid by using `is also`: -====factset==== -To view or set factoid meta-data, such as owner, rate-limit, etc, use the 'factset' command. See also: [[#Factoid_Metadata_List|factoid metadata list]]. + PBot, c is also See FAQ at http://www.eskimo.com/~scs/C-faq/top.html + Changed: c is /say C rules! ; See FAQ at http://www.eskimo.com/~scs/C-faq/top.html - Usage: factset [ [value]] +### factundo +To revert to an older revision, use the `factundo` command. You can repeatedly factundo a factoid until it has no more remaining undos. -Omit and to list all the keys and values for a factoid. Specify , but omit to see the value for a specific key. +Usage: `factundo [channel] ` -=====Factoid Metadata List===== +### factredo +To revert to a newer revision, use the `factredo` command. You can repeatedly factredo a factoid until it has no more remaining redos. + +Usage: `factredo [channel] ` + +### factset +To view or set factoid meta-data, such as owner, rate-limit, etc, use the `factset` command. See also: [factoid metadata list](#Factoid_Metadata_List). + +Usage: `factset [ [value]]` + +Omit `` and `` to list all the keys and values for a factoid. Specify ``, but omit `` to see the value for a specific key. + +#### Factoid Metadata List This is a list of recognized factoid meta-data fields. The number in parentheses next to the field is the minimum admin level necessary to modify it; if there is no such number then anybody may modify it. -* created_on (90): The timestamp of when the factoid was created. -* enabled (10): Whether the factoid can be invoked or not. -* last_referenced_in (90): The channel or private-message in which the factoid was last used. -* last_referenced_on (90): The timestamp of when the factoid was last used. -* modulelauncher_subpattern (90): A substitution expression used to modify the arguments into a command-line. -* owner (90): The creator of the factoid. -* rate_limit (10): How often the factoid may be invoked, in seconds. Zero for unlimited. -* ref_count (90): How many times the factoid has been invoked. -* ref_user (90): The hostmask of the last person to invoke the factoid. -* type (90): The type of the factoid. "text" for regular factoid; "module" for module. -* edited_by (90): The hostmask of the person to last edit the factoid. -* edited_on (90): The timestamp of when the factoid was last edited. -* locked (10): If enabled, prevents the factoid from being changed or removed. -* add_nick (10): Prepends the nick of the person invoking the factoid to the output of the factoid. -* nooverride (10): Prevents the creation of a factoid with an identical name in a different channel. -* effective-level (20): the effective admin level at which this factoid executes (i.e., for /kick, etc) -* persist-key (20): the storage key for allowing code-factoids to persist variables -* action_with_args: Alternate action to perform if an argument has been supplied when invoking the factoid. -* noembed: Factoid will not be triggered if embedded within a sentence. -* interpolate: when set to a false value, $variables will not be expanded. -* use_output_queue: when set to a true value, the output will be delayed by a random number of seconds to simulate reading/typing. +* `created_on` (90): The timestamp of when the factoid was created. +* `enabled` (10): Whether the factoid can be invoked or not. +* `last_referenced_in` (90): The channel or private-message in which the factoid was last used. +* `last_referenced_on` (90): The timestamp of when the factoid was last used. +* `modulelauncher_subpattern` (90): A substitution expression used to modify the arguments into a command-line. +* `owner` (90): The creator of the factoid. +* `rate_limit` (10): How often the factoid may be invoked, in seconds. Zero for unlimited. +* `ref_count` (90): How many times the factoid has been invoked. +* `ref_user` (90): The hostmask of the last person to invoke the factoid. +* `type` (90): The type of the factoid. "text" for regular factoid; "module" for module. +* `edited_by` (90): The hostmask of the person to last edit the factoid. +* `edited_on` (90): The timestamp of when the factoid was last edited. +* `locked` (10): If enabled, prevents the factoid from being changed or removed. +* `add_nick` (10): Prepends the nick of the person invoking the factoid to the output of the factoid. +* `nooverride` (10): Prevents the creation of a factoid with an identical name in a different channel. +* `effective-level` (20): the effective admin level at which this factoid executes (i.e., for /kick, etc) +* `persist-key` (20): the storage key for allowing code-factoids to persist variables +* `action_with_args`: Alternate action to perform if an argument has been supplied when invoking the factoid. +* `noembed`: Factoid will not be triggered if embedded within a sentence. +* `interpolate`: when set to a false value, $variables will not be expanded. +* `use_output_queue`: when set to a true value, the output will be delayed by a random number of seconds to simulate reading/typing. -====factunset==== +### factunset -To unset factoid meta-data, use the 'factunset' command. +To unset factoid meta-data, use the `factunset` command. - Usage: factunset +Usage: `factunset ` -===Finding a factoid=== -====factfind==== -To search the database for a factoid, you may use the 'factfind' command. You may optionally -specify whether to narrow by channel and/or include factoid owner and/or last referenced by in the search. +Finding a factoid +----------------- +### factfind +To search the database for a factoid, use the 'factfind` command. You may optionally specify whether to narrow by channel and/or include factoid owner and/or last referenced by in the search. If there is only one match for the query, it will display that factoid and its text, otherwise it will list all matching keywords. - Usage: factfind [-channel channel] [-owner nick] [-by nick] [text] - Example: - PBot, factfind cast - 3 factoids match: [##c] NULL casting dontcastmalloc +Usage: `factfind [-channel channel] [-owner nick] [-by nick] [-regex] [text]` -===Information about a factoid=== -====factinfo==== -To get information about a factoid, such as who submitted it and when, use the 'factinfo' command: +If you specify the `-regex` flag, the `text` argument will be treated as a regex. - factinfo [channel] + factfind cast + 3 factoids match: [##c] NULL casting dontcastmalloc - PBot, factinfo ##c NULL - NULL: Factoid submitted by Major-Willard for all channels on Sat Jan 1 16:17:42 2005 - [5 years and 178 days ago], referenced 39 times (last by pragma_ on Sun Jun 27 04:40:32 2010 [5 seconds ago]) +Information about a factoid +--------------------------- +### factinfo +To get information about a factoid, such as who submitted it and when, use the `factinfo` command. -If the factoid has been submitted for the special global channel, then it will be shown as 'submitted for all channels'. Otherwise, -it will be shown as 'submitted for #channel'. +Usage: `factinfo [channel] ` -====factshow==== -To see the factoid string literal, use the 'factshow' command: + factinfo ##c NULL + NULL: Factoid submitted by Major-Willard for all channels on Sat Jan 1 16:17:42 2005 [5 years and 178 days ago], referenced 39 times (last by pragma- on Sun Jun 27 04:40:32 2010 [5 seconds ago]) - factshow [channel] +### factshow +To see the factoid `action` literal, use the `factshow` command. - factshow ##c hi - hi: /say $greetings, $nick. +Usage: `factshow [channel] ` -====factset==== + factshow ##c hi + hi: /say $greetings, $nick. -To view factoid meta-data, such as owner, rate-limit, etc, use the 'factset' command. +### factset +To view factoid meta-data, such as owner, rate-limit, etc, use the `factset` command. - Usage: factset [ [value]] +Usage: `factset [ [value]]` -Omit and to list all the keys and values for a factoid. Specif , but omit to see the value for a specific key. +Omit `` and `` to list all the keys and values for a factoid. Specify ``, but omit `` to see the value for a specific key. -====factlog==== +### factlog +To see a factoid's changelog history, use the `factlog` command. -To see a factoid's changelog history, use the 'factlog' command. +Usage: `factlog [-h] [-t] [channel] ` - Usage: factlog [channel] +`-h` shows full hostmasks instead of just the nick. `-t` shows the actual timestamp instead of relative. -====count==== -To see how many factoids and what percentage of the database has submitted, use the 'count' command: - count prec - prec has submitted 28 factoids out of 233 (12%) - count twkm - twkm has submitted 74 factoids out of 233 (31%) - count pragma - pragma has submitted 27 factoids out of 233 (11%) + factadd hi /say Hello there! + hi added to global channel. + factchange hi s/!$/, $nick!/ + Changed: hi is /say Hello there, $nick! + forget hi + hi removed from the global channel. + factadd hi /say Hi! -====histogram==== -To see a histogram of the top 10 factoid submitters, use the 'histogram' command: - histogram - 268 factoids, top 10 submitters: twkm: 74 (27%) Major-Willard: - 64 (23%) pragma_: 40 (14%) prec: 39 (14%) defrost: 14 (5%) - PoppaVic: 10 (3%) infobahn: 7 (2%) orbitz: 3 (1%) mauke: 3 - (1%) Tom^: 2 (1%) + -====top20==== + factlog hi + [3m ago] pragma- created: /say Hi! [5m ago] pragma- deleted [8m ago] pragma- changed to /say Hello there, $nick! [10m ago] pragma- created: /say Hello there! + +### count +To see how many factoids and what percentage of the database `` has submitted, use the `count` command. + +Usage: `count ` + + count prec + prec has submitted 28 factoids out of 233 (12%) + count twkm + twkm has submitted 74 factoids out of 233 (31%) + count pragma + pragma has submitted 27 factoids out of 233 (11%) + +### histogram +To see a histogram of the top factoid submitters, use the `histogram` command. + + histogram + 268 factoids, top 10 submitters: twkm: 74 (27%) Major-Willard: 64 (23%) pragma-: 40 (14%) prec: 39 (14%) defrost: 14 (5%) PoppaVic: 10 (3%) infobahn: 7 (2%) orbitz: 3 (1%) mauke: 3 (1%) Tom^: 2 (1%) + +### top20 To see the top 20 most popular factoids, use the 'top20' command. -==Commands== - -To see all the currently available commands, use the '''list commands''' command. +Commands +======== +To see all the currently available commands, use the `list commands` command. Some commands are: -===Quotegrabs=== -====Table of quotegrabs==== -A table of grabbed quotes can be found here: [http://www.iso-9899.info/PBot/quotegrabs.html http://www.iso-9899.info/PBot/quotegrabs.html] - -====grab==== +Quotegrabs +---------- +### grab Grabs a message someone says, and adds it to the quotegrabs database. You may grab multiple nicks/messages in one quotegrab by separating the arguments with a plus sign (the nicks need not be different -- you can grab multiple messages by the same nick by specifying a different history for each grab). -You can use the [[#recall|recall]] command to test the arguments before grabbing (please use a private message). +You can use the [recall](#recall) command to test the arguments before grabbing (please use a private message). - Usage: grab [history [channel]] [+ ...] +Usage: `grab [history [channel]] [+ ...]` where [history] is an optional argument regular expression used to search message contents; e.g., to grab a message containing the text "pizza", use: grab nick pizza - Examples: - - Clowns are scary. + Clowns are scary. grab bob clowns - Quote grabbed: 1: Clowns are scary. + Quote grabbed: 1: Clowns are scary. - Please put that in the right place. - That's what she said! + + + Please put that in the right place. + That's what she said! grab alice place + bob said - Quote grabbed 2: Please put that in the right place. That's what she said! + Quote grabbed 2: Please put that in the right place. That's what she said! + + I know a funny programming knock-knock joke. Knock knock! Race condition. Who's there? grab charlie knock + charlie race + charlie there - Quote grabbed 3: Knock knock! Race condition. Who's there? + Quote grabbed 3: Knock knock! Race condition. Who's there? -====getq==== +### getq Retrieves and displays a specific grabbed quote from the quotegrabs database. - Usage: getq -====rq==== +Usage: `getq ` + +### rq Retrieves and displays a random grabbed quote from the quotegrabs database. You may filter by nick, channel and/or quote text. - Usage: rq [nick [channel [text]]] [-c,--channel ] [-t,--text ] -====delq==== +Usage: `rq [nick [channel [text]]] [-c,--channel ] [-t,--text ]` + +### delq Deletes a specific grabbed quote from the quotegrabs database. You can only delete quotes you have grabbed unless you are logged in as an admin. - Usage: delq -====recall==== +Usage: `delq ` + +### recall Recalls messages from the chat history and displays them with a relative time-stamp. - Usage: recall <[nick [history [channel]]] [-c,channel ] [-t,text,h,history ] [-b,before ] [-a,after ] [-x,context ] [-n,count ] [+ ...]> +Usage: `recall <[nick [history [channel]]] [-c,channel ] [-t,text,h,history ] [-b,before ] [-a,after ] [-x,context ] [-n,count ] [+ ...]>` -You can use -b/-before and -a/-after to display the messages before and after the result me For example, `recall ##c -b 99` would show the last 100 messages in the ##c channel. `recall bob 50 -b 5 -a 5` would show the 50th most recent message from bob, including 5 messages before and 5 messages after that message. If you also specify -x , then the before and after messages will be limited to messages from the argument; for example, `recall -x bob -b 10` would show bob's 10 most recent messages. +You can use `-b/-before` and `-a/-after` to display the messages before and after the result me For example, `recall ##c -b 99` would show the last 100 messages in the ##c channel. `recall bob 50 -b 5 -a 5` would show the 50th most recent message from bob, including 5 messages before and 5 messages after that message. If you also specify `-x `, then the before and after messages will be limited to messages from the `` argument; for example, `recall -x bob -b 10` would show bob's 10 most recent messages. -Alternatively, you can use -n/-count to display that many matches resulting from a -h/-history search; for example, `recall -h http -n 5` would show the last 5 messages containing "http". You can specify -x/-context to limit the search to a specific nick; for example, `recall -h http -x bob -n 5` would show bob's last 5 messages containing "http". +Alternatively, you can use `-n/-count` to display that many matches resulting from a `-h/-history` search; for example, `recall -h http -n 5` would show the last 5 messages containing "http". You can specify `-x/-context` to limit the search to a specific nick; for example, `recall -h http -x bob -n 5` would show bob's last 5 messages containing "http". - Example: - recall alice + bob - [20 seconds ago] Please put that in the right place. [8 seconds ago] That's what she said! + recall alice + bob + [20 seconds ago] Please put that in the right place. [8 seconds ago] That's what she said! -===Modules=== +Modules +------- - -====cc==== +### cc Code compiler (and executor). This command will compile and execute user-provided code in a number of languages, and then display the compiler and/or program output. -The program is executed within a gdb debugger instance, which may be interacted with via the [[#Using_the_GDB_debugger|gdb macros described below]] or with the gdb("command") function. +The program is executed within a gdb debugger instance, which may be interacted with via the [gdb macros described below](#Using_the_GDB_debugger) or with the `gdb("command")` function. The compiler and program are executed inside a virtual machine. After each run, the virtual machine is restored to a previous state. No system calls have been disallowed. You can write to and read from the filesystem, provided you do it in the same program. The network cable has been unplugged. You are free to write and test any code you like. Have fun. -=====Usage===== +#### Usage - Usage: cc [-lang=] [-info] [-paste] [-args "command-line arguments"] [-stdin "stdin input"] [compiler/language options] - cc - cc - [nick] { } +- `cc [-lang=] [-info] [-paste] [-args "command-line arguments"] [-stdin "stdin input"] [compiler/language options] ` +- `cc ` +- `cc ` +- `[nick] { }` -* You can pass any gcc compiler options. By default, -Wall -Wextra -std=c11 -pedantic are passed unless an option is specified. -* The -paste option will pretty-format and paste the code/output to a paste site and display the URL (useful to preserve newlines in output, and to refer to line-numbers). -* The -nomain flag will prevent the code from being wrapped with a main() function. This is not necessary if you're explicitly defining a main function; it's only necessary if you don't want a main function at all. -* The -noheaders flag will prevent any of the default headers from being added to the code. This is not necessary if you explicitly include any headers since doing so will override the default headers. This flag is only necessary if you want absolutely no headers whatsoever. -* The -stdin <stdin input> option provides STDIN input (i.e., scanf(), getc(stdin), etc.). -* The -args <command-line arguments> option provides command-line arguments (i.e., argv). -* The run, undo, show, replace, etc commands are part of [[#Interactive_Editing|interactive-editing]]. -* The diff command can be used to display the differences between the two most recent snippets. +You can pass any gcc compiler options. By default, `-Wall -Wextra -std=c11 -pedantic` are passed unless an option is specified. -=====Supported Languages===== +The `-paste` option will pretty-format and paste the code/output to a paste site and display the URL (useful to preserve newlines in output, and to refer to line-numbers). -The -lang option can be used to specify an alternate compiler or language. Use -lang=? to list available languages. +The `-nomain` flag will prevent the code from being wrapped with a `main()` function. This is not necessary if you're explicitly defining a `main` function; it's only necessary if you don't want a `main` function at all. - cc -lang=? - Language '?' is not supported. Supported languages are: bash, bc, bf, c11, c89, c99, clang, clang11, - clang89, clang99, clang++, clisp, c++, freebasic, go, haskell, java, javascript, ksh, lua, perl, python python3, qbasic, scheme, sh, tendra +The `-noheaders` flag will prevent any of the default headers from being added to the code. This is not necessary if you explicitly include any headers since doing so will override the default headers. This flag is only necessary if you want absolutely no headers whatsoever. -Most of these languages have an direct alias to invoke them. +The `-stdin ` option provides STDIN input (i.e., `scanf()`, `getc(stdin)`, etc.). - perl print 'hi' - hi +The `-args ` option provides command-line arguments (i.e., `argv`). -=====Default Language===== -The default language (e.g., without an explicit -lang or -std option) is C11 pedantic; which is gcc -Wall -Wextra -std=c11 -pedantic. +The `run`, `undo`, `show`, `replace`, etc commands are part of [interactive-editing](#Interactive_Editing). -=====Disallowed system calls===== +The `diff` command can be used to display the differences between the two most recent snippets. + +#### Supported Languages +The `-lang` option can be used to specify an alternate compiler or language. Use `-lang=?` to list available languages. + + cc -lang=? + Language '?' is not supported. Supported languages are: bash, bc, bf, c11, c89, c99, clang, clang11, clang89, clang99, clang++, clisp, c++, freebasic, go, haskell, java, javascript, ksh, lua, perl, php, python, python3, qbasic, ruby, scheme, sh, tcl, tendra, zsh + +Most, if not all, of these languages have an direct alias to invoke them. + + factshow perl + [global] perl: /call cc -lang=perl $args + perl print 'hi' + hi + +#### Default Language +The default language (e.g., without an explicit `-lang` or `-std` option) is C11 pedantic; which is `gcc -Wall -Wextra -std=c11 -pedantic`. + +#### Disallowed system calls None. The network cable has been unplugged. Other than that, anything goes. Have fun. -=====Program termination with no output===== +#### Program termination with no output If there is no output, information about the local variables and/or the last statement will be displayed. - cc int x = 5, y = 16; x ^= y, y ^= x, x ^= y; - pragma_: no output: x = 16; y = 5 + cc int x = 5, y = 16; x ^= y, y ^= x, x ^= y; + pragma-: no output: x = 16; y = 5 - cc #include struct utsname u; uname(&u); - pragma_: no output: u = {sysname = "Linux", nodename = "compiler", release = "3.2.0-8-generic", version = "#15-Ubuntu SMP Wed Jan 11 13:57:44 UTC 2012", machine = "x86_64", __domainname = "(none)"} + - cc int a = 2, b = 3; ++a + b; - pragma_: no output: ++a + b = 6; a = 3; b = 3 + cc #include struct utsname u; uname(&u); + pragma-: no output: u = {sysname = "Linux", nodename = "compiler", release = "3.2.0-8-generic", version = "#15-Ubuntu SMP Wed Jan 11 13:57:44 UTC 2012", machine = "x86_64", __domainname = "(none)"} - cc sizeof (char) - pragma_: no output: sizeof (char) = 1 + - cc 2 + 2 - pragma_: no output: 2 + 2 = 4 + cc int a = 2, b = 3; ++a + b; + pragma-: no output: ++a + b = 6; a = 3; b = 3 -=====Abnormal program termination===== + + + cc sizeof (char) + pragma-: no output: sizeof (char) = 1 + + + + cc 2 + 2 + pragma-: no output: 2 + 2 = 4 + +#### Abnormal program termination If a signal is detected, the bot will display useful information. -Example session: + < pragma-> cc char *p = 0; *p = 1; + pragma-: Program received signal 11 (SIGSEGV) at statement: *p = 1; - < pragma_> ,cc char *p = 0; *p = 1; - < PBot> pragma_: Program received signal 11 (SIGSEGV) at statement: *p = 1; + - < pragma_> ,cc void bang() { char *p = 0, s[] = "lol"; strcpy(p, s); } bang(); - < PBot> pragma_: Program received signal 11 (SIGSEGV) in bang () at statement: strcpy(p, s); + cc void bang() { char *p = 0, s[] = "lol"; strcpy(p, s); } bang(); + pragma-: Program received signal 11 (SIGSEGV) in bang () at statement: strcpy(p, s); - < pragma_> ,cc int a = 2 / 0; - < PBot> pragma_: [In function 'main': warning: division by zero] Program received signal 8 (SIGFPE) at statement: int a = 2 / 0; + -=====C and C++ Functionality===== -=====Using the preprocessor===== + cc int a = 2 / 0; + pragma-: [In function 'main': warning: division by zero] Program received signal 8 (SIGFPE) at statement: int a = 2 / 0; -======Default #includes====== +#### C and C++ Functionality +#### Using the preprocessor + +##### Default #includes These are the default includes for C11. To get the most up-to-date list of #includes, use the `cc paste` command. -
-#define _XOPEN_SOURCE 9001
-#define __USE_XOPEN
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
+ #define _XOPEN_SOURCE 9001 + #define __USE_XOPEN + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include -======Using #include====== -In C and C++, you may #include one after another on the same line. The bot will automatically put them on separate lines. If you do use #include, the files you specify will replace the default includes. You do not need to append a \n after the #include. +##### Using #include +In C and C++, you may `#include ` one after another on the same line. The bot will automatically put them on separate lines. If you do use `#include`, the files you specify will replace the default includes. You do not need to append a `\n` after the `#include`. - cc #include struct utsname u; uname(&u); - pragma_: + cc #include struct utsname u; uname(&u); + pragma-: - cc #include #include void func(void) { puts("Hello, world"); } func(); - pragma_: Hello, World + -In the previous examples, only the specified includes (e.g., in the first example, and in the second, will be included instead of the default includes. + cc #include #include void func(void) { puts("Hello, world"); } func(); + pragma-: Hello, World -======Using #define====== -You can also #define macros; however, #defines require an explicit "\n" sequence to terminate, oe the remainder of the line will be part of the macro. +In the previous examples, only the specified includes (e.g., `` in the first example, `` and `` in the second, will be included instead of the default includes. - cc #define GREETING "Hello, World"\n puts(GREETING); - pragma_: Hello, World +##### Using #define +You can also `#define` macros; however, `#defines` require an explicit `\n` sequence to terminate, oe the remainder of the line will be part of the macro. -=====main() Function Unnecessary===== -In C and C++, if there is no main function, then a main function will created and wrapped around the appropriate bits of your code (unless the -nomain flag was specified); anything outside of any functions, excluding preprocessor stuff, will be put into this new main function. Here's an example: + cc #define GREETING "Hello, World"\n puts(GREETING); + pragma-: Hello, World - cc -paste int add(int a, int b) { return a + b; } printf("4 + 6 = %d -- ", add(4, 6)); int add3(int a, int b, int c) +#### main() Function Unnecessary +In C and C++, if there is no `main` function, then a `main` function will created and wrapped around the appropriate bits of your code (unless the `-nomain` flag was specified); anything outside of any functions, excluding preprocessor stuff, will be put into this new `main` function. + + cc -paste int add(int a, int b) { return a + b; } printf("4 + 6 = %d -- ", add(4, 6)); int add3(int a, int b, int c) { return add(a, b) + c; } printf("7 + 8 + 9 = %d", add3(7, 8, 9)); - http://sprunge.us/ehRA?c + http://sprunge.us/ehRA?c -The -paste flag causes the code to be pretty-formatted and pasted with output in comments to a paste site, which displays the following: +The `-paste` flag causes the code to be pretty-formatted and pasted with output in comments to a paste site, which displays the following: -
-#define _XOPEN_SOURCE 9001
-#define __USE_XOPEN
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+    #define _XOPEN_SOURCE 9001
+    #define __USE_XOPEN
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
+    #include 
 
 
-int add(int a, int b) {
-    return a + b;
-}
+    int add(int a, int b) {
+        return a + b;
+    }
 
-int add3(int a, int b, int c) {
-    return add(a, b) + c;
-}
+    int add3(int a, int b, int c) {
+        return add(a, b) + c;
+    }
 
-int main(void) {
-    printf("4 + 6 = %d -- ", add(4, 6));
+    int main(void) {
+        printf("4 + 6 = %d -- ", add(4, 6));
 
-    printf("7 + 8 + 9 = %d", add3(7, 8, 9));
-    return 0;
-}
+        printf("7 + 8 + 9 = %d", add3(7, 8, 9));
+        return 0;
+    }
 
-/************* OUTPUT *************
-4 + 6 = 10 -- 7 + 8 + 9 = 24
-************** OUTPUT *************/
-
+ /************* OUTPUT ************* + 4 + 6 = 10 -- 7 + 8 + 9 = 24 + ************** OUTPUT *************/ -=====Embedding Newlines===== +#### Embedding Newlines +Any `\n` character sequence appearing outside of a character literal or a string literal will be replaced with a literal newline. -Any \n character sequence appearing outside of a character literal or a string literal will be replaced with a literal newline. +#### Printing in binary/base2 +A freenode ##c regular, Wulf, has provided a printf format specifier `b` which can be used to print values in base2. -=====Printing in binary/base2===== + cc printf("%b", 1234567); + 000100101101011010000111 -A freenode ##c regular, Wulf, has provided a printf format specifier 'b' which can be used to print values in base2. + - cc printf("%b", 1234567); - 000100101101011010000111 + cc printf("%#'b", 1234567); + 0001.0010.1101.0110.1000.0111 - cc printf("%#'b", 1234567); - 0001.0010.1101.0110.1000.0111 - -=====Using the GDB debugger===== +#### Using the GDB debugger The program is executed within a gdb debugger instance, which may be interacted with via the following gdb macros. -======print====== -The print() macro prints the values of expressions. Useful for printing out structures and arrays. +##### print +The `print()` macro prints the values of expressions. Useful for printing out structures and arrays. - cc int a[] = { 1, 2, 3 }; print(a); - pragma_: a = {1, 2, 3} + cc int a[] = { 1, 2, 3 }; print(a); + pragma-: a = {1, 2, 3} - cc #include struct utsname u; uname(&u); print(u); - pragma_: u = {sysname = "Linux", nodename = "compiler", release = "3.2.0-8-generic", version = "#15-Ubuntu SMP Wed Jan 11 13:57:44 UTC 2012", machine = "x86_64", __domainname = "(none)"} + - cc print(sizeof(int)); - pragma_: sizeof(int) = 4 + cc #include struct utsname u; uname(&u); print(u); + pragma-: u = {sysname = "Linux", nodename = "compiler", release = "3.2.0-8-generic", version = "#15-Ubuntu SMP Wed Jan 11 13:57:44 UTC 2012", machine = "x86_64", __domainname = "(none)"} - cc print(2+2); - pragma_: 2 + 2 = 4 + -======ptype====== -The ptype() macro prints the types of expressions. + cc print(sizeof(int)); + pragma-: sizeof(int) = 4 - cc int *a[] = {0}; ptype(a); ptype(a[0]); ptype(*a[0]); - pragma_: a = int *[1] a[0] = int * *a[0] = int + -======watch====== -The watch() macro watches a variable and displays its value when it changes. + cc print(2+2); + pragma-: 2 + 2 = 4 - cc int n = 0, last = 1; watch(n); while(n <= 144) { n += last; last = n - last; } /* fibonacci */ - pragma_: n = 1 n = 2 n = 3 n = 5 n = 8 n = 13 n = 21 n = 34 n = 55 n = 89 n = 144 +##### ptype +The `ptype()` macro prints the types of expressions. -======trace====== -The trace() macro traces a function's calls, displaying passed and returned values. - ,cc trace(foo); char *foo(int n) { puo, world"); return "Good-bye, world"; } foo(42); - pragma_: entered [1] foo (n=42) Hello, world leaving [1] foo (n=42), returned 0x401006 "Good-bye, world" + cc int *a[] = {0}; ptype(a); ptype(a[0]); ptype(*a[0]); + pragma-: a = int *[1] a[0] = int * *a[0] = int -======gdb====== -The gdb() function takes a string argument which it passes to the gdb debugger and then displays the output if any. +##### watch +The `watch()` macro watches a variable and displays its value when it changes. - ,cc gdb("info macro NULL"); - pragma_: Defined at /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h:402 #define NULL ((void *)0) + cc int n = 0, last = 1; watch(n); while(n <= 144) { n += last; last = n - last; } /* fibonacci */ + pragma-: n = 1 n = 2 n = 3 n = 5 n = 8 n = 13 n = 21 n = 34 n = 55 n = 89 n = 144 - ,cc void foo() { gdb("info frame"); } foo(); - pragma_: Stack level 1, frame at 0x7fffffffe660: rip = 0x400e28 in foo (); saved rip 0x400e43 called by frame at 0x7fffffffe680, caller of frame at 0x7fffffffe650 source language c. Arglist at 0x7fffffffe650, args: Locals at 0x7fffffffe650, Previous frame's sp is 0x7fffffffe660 Saved registers: rbp at 0x7fffffffe650, rip at 0x7fffffffe658 +##### trace +The `trace()` macro traces a function's calls, displaying passed and returned values. -=====Interactive Editing===== + ,cc trace(foo); char *foo(int n) { puo, world"); return "Good-bye, world"; } foo(42); + pragma-: entered [1] foo (n=42) Hello, world leaving [1] foo (n=42), returned 0x401006 "Good-bye, world" -The [[#cc|cc]] command supports interactive-editing. The general syntax is: cc [command]. +##### gdb +The `gdb()` function takes a string argument which it passes to the gdb debugger and then displays the output if any. -Each cc snippet is saved in a buffer which is named after the channel or nick it was used in. You can use [[#show|show]] or [[#diff|diff]] with a buffer argument to view that buffer; otherwise you can use the [[#copy|copy]] command to copy the most recent snippet of another buffer into the current buffer and optionally chain it with another command -- for example, to copy the ##c buffer (e.g., from a private message or a different channel) and paste it: ''cc copy ##c and paste''. + ,cc gdb("info macro NULL"); + pragma-: Defined at /usr/lib/gcc/x86_64-linux-gnu/4.7/include/stddef.h:402 #define NULL ((void *)0) -The commands are: [[#copy|copy]], [[#show|show]], [[#diff|diff]], [[#paste|paste]], [[#run|run]], [[#undo|undo]], [[#s.2F.2F|s//]], [[#replace|replace]], [[#prepend|prepend]], [[#append|append]], and [[#remove|remove]]. Most of the commands may be chained together by separating them with whitespace or "and". + + + ,cc void foo() { gdb("info frame"); } foo(); + pragma-: Stack level 1, frame at 0x7fffffffe660: rip = 0x400e28 in foo (); saved rip 0x400e43 called by frame at 0x7fffffffe680, caller of frame at 0x7fffffffe650 source language c. Arglist at 0x7fffffffe650, args: Locals at 0x7fffffffe650, Previous frame's sp is 0x7fffffffe660 Saved registers: rbp at 0x7fffffffe650, rip at 0x7fffffffe658 + +#### Interactive Editing +The [cc](#cc) command supports interactive-editing. The general syntax is: `cc [command]`. + +Each cc snippet is saved in a buffer which is named after the channel or nick it was used in. You can use [show](#show) or [diff](#diff) with a buffer argument to view that buffer; otherwise you can use the [copy](#copy) command to copy the most recent snippet of another buffer into the current buffer and optionally chain it with another command -- for example, to copy the `##c` buffer (e.g., from a private message or a different channel) and paste it: `cc copy ##c and paste`. + +The commands are: [copy](#copy), [show](#show), [diff](#diff), [paste](#paste), [run](#run), [undo](#undo), [s//](#s.2F.2F), [replace](#replace), [prepend](#prepend), [append](#append), and [remove](#remove). Most of the commands may be chained together by separating them with whitespace or "and". The commands are described in more detail below: -======copy====== +##### copy +To copy the most recent snippet from another buffer (e.g., to copy another channel's or private message's buffer to your own private message or channel), use the `copy` command. Other commands can optionally be chained after this command. -To copy the most recent snippet from another buffer (e.g., to copy another channel's or private message's buffer to your own private message or channel), use the '''copy''' command. Other commands can optionally be chained after this command. +Usage: `cc copy [and ...]` - Usage: cc copy [and ...] +##### show +To show the latest code in the buffer, use the `show` command. This command can take an optional buffer argument. -======show====== - -To show the latest code in the buffer, use the '''show''' command. This command can take an optional buffer argument. - - cc show - pragma_: printf("Hello, world!"); + cc show + pragma-: printf("Hello, world!"); This command is stand-alone and cannot be chained with other interactive-editing commands. -======diff====== +##### diff +To see the differences between the two most recent snippets, use the `diff` command. This command can take an optional buffer argument. -To see the differences between the two most recent snippets, use the '''diff''' command. This command can take an optional buffer argument. - - cc diff - pragma: printf(", "); + cc diff + pragma: printf(", "); This command is stand-alone and cannot be chained with other interactive-editing commands. -======paste====== +##### paste +To paste the full source of the latest code in the buffer as the compiler sees it, use the `paste` command: -To paste the full source of the latest code in the buffer as the compiler sees it, use the '''paste''' command: - - cc paste - pragma_: http://some.random.paste-site.com/paste/results + cc paste + pragma-: http://some.random.paste-site.com/paste/results This command is stand-alone and cannot be chained with other interactive-editing commands. -======run====== +##### run +To attempt to compile and execute the latest code in the buffer, use the `run` command: -To attempt to compile and execute the latest code in the buffer, use the '''run''' command: - - cc run - pragma_: Hello, world! + cc run + pragma-: Hello, world! This command is stand-alone and cannot be chained with other interactive-editing commands. -======undo====== +##### undo +To undo any changes, use `undo`. The `undo` command must be the first command before any subsequent commands. -To undo any changes, use '''undo'''. The '''undo''' command must be the first command before any subsequent commands. +##### s// +To change the latest code in the buffer, use the `s/regex/substitution/[gi]` pattern. -======s//====== + cc s/Hello/Good-bye/ and s/world/void/ + pragma-: Good-bye, void! + cc show + pragma-: printf("Good-bye, void!"); -To change the latest code in the buffer, use thegex/substitution/[gi]''' pattern. +##### replace +Alternatively, you may use the `replace` command. The usage is (note the required single-quotes): - cc s/Hello/Good-bye/ and s/world/void/ - pragma_: Good-bye, void! - cc show - pragma_: printf("Good-bye, void!"); +`cc replace [all, first, second, ..., tenth, last] 'from' with 'to'` -======replace====== +##### prepend +Text may be prepended with the `prepend` command: -Alternatively, you may use the '''replace''' command. The usage is (note the required single-quotes): +`cc prepend 'text'` - cc replace [all, first, second, ..., tenth, last] 'from' with 'to' +##### append +Text may be appended with the `append` command: -======prepend====== +`cc append 'text'` -Text may be prepended with the '''prepend''' command: +##### remove +Text may be deleted with the `remove` command: - cc prepend 'text' +`cc remove [all, first, second, ..., tenth, last] 'text'` -======append====== +#### Some Examples -Text may be appended with the '''append''' command: - - cc append 'text' - -======remove====== - -Text may be deleted with the '''remove''' command: - - cc remove [all, first, second, ..., tenth, last] 'text' - -=====Some Examples===== - Examples: - - < pragma_> cc int fib2(int n, int p0, int p1) { return n == 1 ? p1 : fib2(n - 1, p1, p0 + p1); } + cc int fib2(int n, int p0, int p1) { return n == 1 ? p1 : fib2(n - 1, p1, p0 + p1); } int fib(int n) { return n == 0 ? 0 : fib2(n, 0, 1); } for(int i = 0; i < 21; i++) printf("%d ", fib(i)); - < PBot> pragma_: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 + pragma-: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 - < pragma_> cc int i = 0, last = 1; while(i <= 7000) { printf("%d ", i); i += last; last = i - last; } - pragma_: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 + + + cc int i = 0, last = 1; while(i <= 7000) { printf("%d ", i); i += last; last = i - last; } + pragma-: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 + + cc int n=0, f[2]={0,1}; while(n<20) printf("%d ",f[++n&1]=f[0]+f[1]); // based on cehteh - Icewing: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 + Icewing: 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 - <3monkeys> cc @p=(0,1); until($#p>20) { print"$p[-2]\n"; push @p, $p[-2] + $p[-1] } -lang=Perl - 3monkeys: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 + + + <3monkeys> cc @p=(0,1); until($#p>20) { print"$p[-2]\n"; push @p, $p[-2] + $p[-1] } -lang=Perl + 3monkeys: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 + + cc -lang=Ruby p,c=0,1; 20.times{p p; c=p+p=c} - spiewak: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 + spiewak: 0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 - cc main = print $ take 20 $ let fibs = 0 : scanl (+) 1 fibs in fibs; -lang=Haskell - Jafet: [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181] + -====english==== + cc main = print $ take 20 $ let fibs = 0 : scanl (+) 1 fibs in fibs; -lang=Haskell + Jafet: [0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181] + +### english Converts C11 code into English sentences. - Usage: english - Examples: - english char (*a)[10]; char *b[10]; - Let a be a pointer to an array of length 10 of type char. Let b be an array of length 10 of type pointer to char. - english for(;;); - Repeatedly compute nothing. - english typedef char Batman; char Bruce_Wayne; char superhero = (Batman) Bruce_Wayne; - Let Batman be another name for a character. Let Bruce_Wayne be a character. Let superhero be a character, with value being Bruce_Wayne cast to a Batman. +Usage: english `` -====expand==== -Expands macros in C code and displays the resulting code. Macros must be terminated by a \n sequence. You may #include headers to expand macros defined within. - Usage: expand + english char (*a)[10]; char *b[10]; + Let a be a pointer to an array of length 10 of type char. Let b be an array of length 10 of type pointer to char. - Example: - expand #define WHILE while ( \n #define DO ) { \n #define WEND } \n int i = 5; WHILE --i DO puts("hi"); WEND - pragma_: int i = 5; while ( --i ) { puts("hi"); } - expand #include NULL - pragma_: ((void *)0) + -====prec==== -====paren==== + english for(;;); + Repeatedly do nothing. + + + + english typedef char Batman; char Bruce_Wayne; char superhero = (Batman) Bruce_Wayne; + Let Batman be another name for a character. Let Bruce_Wayne be a character. Let superhero be a character, with value being Bruce_Wayne cast to a Batman. + +### expand +Expands macros in C code and displays the resulting code. Macros must be terminated by a `\n` sequence. You may `#include` headers to expand macros defined within. + +Usage: `expand ` + + expand #define WHILE while ( \n #define DO ) { \n #define WEND } \n int i = 5; WHILE --i DO puts("hi"); WEND + pragma-: int i = 5; while ( --i ) { puts("hi"); } + expand #include NULL + pragma-: ((void *)0) + +### prec +### paren Shows operator precedence in C99 expressions by adding parentheses. - Usage: prec - paren +Usage: `prec ` `paren ` - Examples: - prec *a++ - pragma_: *(a++) - prec a = b & c - pragma_: a = (b & c) - prec token = strtok(s, d) != NULL - pragma_: token = (strtok(s, d) != NULL) + prec *a++ + pragma-: *(a++) -====faq==== -Displays questions from the [http://http://www.eskimo.com/~scs/C-faq/top.html comp.lan]. Some queries may return more than one result; if this happens, you may use the 'match #' optional argument to specify the match you'd like to view. - Usage: faq [match #] - Examples: - faq cast malloc - 2 results, displaying #1: 7. Memory Allocation, 7.6 Why am - I getting ``warning: assignment of pointer from integer - lacks a cast'' for calls to malloc? : - http://www.eskimo.com/~scs/C-faq/q7.6.html - faq 2 cast malloc - 2 results, displaying #2: 7. Memory Allocation, 7.7 Why - does some code carefully cast the values returned by - malloc to the pointer type being allocated? : - http://www.eskimo.com/~scs/C-faq/q7.7.html - faq ^6.4 - 6. Arrays and Pointers, 6.4 Why are array and pointer - declarations interchangeable as function formal - parameters? : http://www.eskimo.com/~scs/C-faq/q6.4.html + -====cfact==== -Displays a random C fact. You can specify a search text to limit the random set to those containing that text. - Usage: cfact [search text] + prec a = b & c + pragma-: a = (b & c) -====cjeopardy==== -Displays a random C Jeopardy question. You can specify a search text to limit the random set to those containing that text. Answer the questions with `what is ...?` -Can be used to skip the current question. - Usage: cjeopardy [search text] + + prec token = strtok(s, d) != NULL + pragma-: token = (strtok(s, d) != NULL) + +### faq +Displays questions from the [http://http://www.eskimo.com/~scs/C-faq/top.html](comp.lang.c FAQ). Some queries may return more than one result; if this happens, you may use the `match #` optional argument to specify the match you'd like to view. + +Usage: `faq [match #] ` + + faq cast malloc + 2 results, displaying #1: 7. Memory Allocation, 7.6 Why am I getting ``warning: assignment of pointer from integer lacks a cast** for calls to malloc? : http://www.eskimo.com/~scs/C-faq/q7.6.html + faq 2 cast malloc + 2 results, displaying #2: 7. Memory Allocation, 7.7 Why does some code carefully cast the values returned by malloc to the pointer type being allocated? : http://www.eskimo.com/~scs/C-faq/q7.7.html + faq ^6.4 + 6. Arrays and Pointers, 6.4 Why are array and pointer declarations interchangeable as function formal parameters? : http://www.eskimo.com/~scs/C-faq/q6.4.html + +### cfact +Displays a random C fact. You may specify a search text to limit the random set to those containing that text. + +`Usage: cfact [search text]` + + cfact + pragma-: [6.7.2.1 Structure and union specifiers] A structure or union may have a member declared to consist of a specified number of bits. Such a member is called a bit-field. + +### cjeopardy C Jeopardy is loosely based on the Jeopardy! game show. The questions are phrased in the form of an answer and are answered in the form of a question. - Example: - 1009) This macro expands to a integer constant expressions that can be used as the - argument to the exit function to return successful termination status to the host environment. - PBot, what is EXIT_SUCCESS? - pragma-: 'EXIT_SUCCESS' is correct! It took 1 minutes and 15 seconds to answer that question. +The `cjeopardy` command isplays a random C Jeopardy question. You can specify a search text to limit the random set to those containing that text. Answer the questions with `what is ...?` +Can be used to skip the current question. -=====hint===== +Usage: `cjeopardy [search text]` + + 1009) This macro expands to a integer constant expressions that can be used as the argument to the exit function to return successful termination status to the host environment. + what is EXIT_SUCCESS? + pragma-: 'EXIT_SUCCESS' is correct! (1m15s) + +#### hint Displays a hint for the current C Jeopardy question. Each subsequent hint request reveals more of the answer. -=====what===== -=====w===== +#### what +#### w Answers a C Jeopardy question. `w` may be used as an alternative short-hand. - Usage: what is ? - Usage: w -=====filter===== -Added due to popular demand, `filter` can skip questions containing undesirable words such as wide-character or floating-point. You may only filter up to 3 words. - Usage: filter or `filter clear` to clear the filter +Usage: `what is ?` -=====score===== +Usage: `w ` + +#### filter +`filter` can skip questions containing undesirable words such as wide-character or floating-point. + +Usage: `filter ` or `filter clear` to clear the filter + +#### score Shows the personal C Jeopardy statistics for a player. If used without any arguments, it shows your own statistics. - Usage: score [player name] -=====rank===== +Usage: `score [player name]` + +#### rank Shows ranking for various C Jeopardy statistics, or your personal rankings in each of the statistics. If used without any arguments, it shows the available keywords for which statistics to rank. - Usage: rank [keyword or player name] -=====reset===== +Usage: `rank [keyword or player name]` + +#### reset Resets your personal C Jeopardy statistics for the current session. Your life-time records will still be retained. -=====qstats===== +#### qstats Shows statistics specific to a C Jeopardy question. Can also rank questions by a specific statistic. - Usage: qstats [question id] - Usage: qstats rank [keyword or question id] -=====qshow===== -Displays a specific C Jeopardy question without making it the current question. Useful for seeing which question belongs to a question id; .e.g. with qstats. - Usage: qshow +Usage: `qstats [question id]` -====c99std==== -Searches ISO/IEC 9899:TC3 (WG14/N1256), also known as the C99 draft standard. http://www.open-std.org/jtc1/sc22/WG14/www/dopdf +Usage: `qstats rank [keyword or question id]` - Usage: c99std [-list] [-n#] [section] [search regex] - If specified, 'section' must be in the form of X.YpZ where X and Y are section/chapter and, optionally, pZ is paragraph. - To display a specific section and all its paragraphs, specify just the 'section' without pZ. - To display just a specific paragraph, specify the full 'section' identifier (X.YpZ). - You may use -n # to skip to the #th match. - To list only the section numbers containing 'search text', add -list. - If both 'section' and 'search regex' are specified, then the search space will be within the specified section identifier. +#### qshow +Displays a specific C Jeopardy question without making it the current question. Useful for seeing which question belongs to a question id; .e.g. with `qstats`. - Examples: +Usage: `qshow ` - < pragma_> c99std pointer value - < PBot> Displaying #1 of 64 matches: 5.1.2.2.1p1: [Program startup] If they are declared, the parameters to the - main function shall obey the following constraints: -- The value of argc shall be nonnegative. -- argv[argc] - shall be a null pointer. -- If the value of argc is greater than zero, the array members argv[0] through - argv[argc-1] inclusive shall contain pointers to st... truncated; see http://codepad.org/f2DULaGQ for full text. +### c99std +Searches ISO/IEC 9899:TC3 (WG14/N1256), also known as the C99 draft standard. http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf - < pragma_> c99std pointer value -list - < PBot> Sections containing 'pointer value': 5.1.2.2.1p2, 5.1.2.3p9, 6.2.5p20, 6.2.5p27, 6.3.2.1p3, 6.3.2.1p4, - 6.3.2.3p2, 6.3.2.3p6, 6.5.2.1p3, 6.5.2.2p5, 6.5.2.2p6, 6.5.2.4p1, 6.5.2.4p2, 6.5.3.1p1, 6.5.3.2p3, 6.5.3.2p4, - 6.5.3.3p5, 6.5.3.4p5, 6.5.6p8, 6.5.6p9, 6.5.8p5, 6.5.15p6, 6.6p7, 6.6p9, 6.7.2.2p5, 6.7.2.3p7, 6.7.2.3p3, - 6.7.5.1p3, 6.7.5.2p7, 7.1.1p1, 7.1.1p4, 7.1.4p1, 7... truncated; see http://codepad.org/qQlnJYJk for full text. +Usage: `c99std [-list] [-n#] [section] [search regex]` - < pragma_> Hmm, how about just section 6.3? +If specified, `section` must be in the form of `X.YpZ` where `X` and `Y` are section/chapter and, optionally, `pZ` is paragraph. - < pragma_> c99std pointer value 6.3 - < PBot> Displaying #1 of 4 matches: 6.3.2.1p1: [Lvalues, arrays, and function designators] Except when it is the operand - of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression - that has type ``array of type is converted to an expression with type ``pointer to type that points to the - initial element of the array ob... truncated; see http://codepad.org/mf1RNnr2 for full text. +To display a specific section and all its paragraphs, specify just the `section` without `pZ`. - < pragma_> c99std pointer value 6.3 -list - < PBot> Sections containing 'pointer value': 6.3.2.1p3, 6.3.2.1p4, 6.3.2.3p2, 6.3.2.3p6 +To display just a specific paragraph, specify the full `section` identifier (`X.YpZ`). - < pragma_> c99std pointer value 6.3 -n3 - < PBot> Displaying #3 of 4 matches: 6.3.2.3p1: [Pointers] For any qualifier q, a pointer to a non-q-qualified type may be - converted to a pointer to the q-qualified version of the type; the values stored in the original and converted - pointers shall compare equal. +You may use `-n #` to skip to the nth match. -====c11std==== +To list only the section numbers containing 'search text', add `-list`. + +If both `section` and `search regex` are specified, then the search space will be within the specified section identifier. + + c99std pointer value + Displaying #1 of 64 matches: 5.1.2.2.1p1: [Program startup] If they are declared, the parameters to the main function shall obey the following constraints: -- The value of argc shall be nonnegative. -- argv[argc] shall be a null pointer. -- If the value of argc is greater than zero, the array members argv[0] through argv[argc-1] inclusive shall contain pointers to st... truncated; see http://codepad.org/f2DULaGQ for full text. + + + + c99std pointer value -list + Sections containing 'pointer value': 5.1.2.2.1p2, 5.1.2.3p9, 6.2.5p20, 6.2.5p27, 6.3.2.1p3, 6.3.2.1p4, 6.3.2.3p2, 6.3.2.3p6, 6.5.2.1p3, 6.5.2.2p5, 6.5.2.2p6, 6.5.2.4p1, 6.5.2.4p2, 6.5.3.1p1, 6.5.3.2p3, 6.5.3.2p4, 6.5.3.3p5, 6.5.3.4p5, 6.5.6p8, 6.5.6p9, 6.5.8p5, 6.5.15p6, 6.6p7, 6.6p9, 6.7.2.2p5, 6.7.2.3p7, 6.7.2.3p3, 6.7.5.1p3, 6.7.5.2p7, 7.1.1p1, 7.1.1p4, 7.1.4p1, 7... truncated; see http://codepad.org/qQlnJYJk for full text. + + + + Hmm, how about just section 6.3? + c99std pointer value 6.3 + Displaying #1 of 4 matches: 6.3.2.1p1: [Lvalues, arrays, and function designators] Except when it is the operand of the sizeof operator or the unary & operator, or is a string literal used to initialize an array, an expression that has type ``array of type is converted to an expression with type ``pointer to type that points to the initial element of the array ob... truncated; see http://codepad.org/mf1RNnr2 for full text. + + + + c99std pointer value 6.3 -list + Sections containing 'pointer value': 6.3.2.1p3, 6.3.2.1p4, 6.3.2.3p2, 6.3.2.3p6 + + + + c99std pointer value 6.3 -n3 + Displaying #3 of 4 matches: 6.3.2.3p1: [Pointers] For any qualifier q, a pointer to a non-q-qualified type may be converted to a pointer to the q-qualified version of the type; the values stored in the original and converted pointers shall compare equal. + +### c11std Searches ISO/IEC 9811:201X (WG14/N1256), also known as the C11 draft standard. http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf -Usage is identical to c99std. +Usage is identical to `c99std`. -====man==== +### man Displays manpage summaries and/or C related tidbits (headers, prototypes, specifications), as well as a link to the FreeBSD manpage. - Usage: man [section] query - Samples: - man fork - Includes: sys/types.h, unistd.h - pid_t fork(void); - SVr4, - SVID, POSIX, X/OPEN, BSD - fork creates a child process that - differs from the parent process only in its PID and PPID, and - in the fact that resource utilizations are set to 0 - - http://www.iso-9899.info/man?fork - man atexit - Includes: stdlib.h - int aid (*function)(void)); - - SVID 3, BSD 4.3, ISO 9899 - atexit () function registers the - given function to be called at normal program termination, - whether via exit(3) or via return from the program's main - - http://www.iso-9899.info/man?atexit - man getcwd - Includes: unistd.h - char *getcwd(char *buf, size_t size); - - POSIX.1 - getcwd () function copies an absolute pathname of - the current working directory to the array pointed to by buf, - which is of length size - http://www.iso-9899.info/man?getcwd -====google==== +Usage: `man [section] query` + + man fork + Includes: sys/types.h, unistd.h - pid_t fork(void); - SVr4, SVID, POSIX, X/OPEN, BSD - fork creates a child process that differs from the parent process only in its PID and PPID, and in the fact that resource utilizations are set to 0 - http://www.iso-9899.info/man?fork + + man atexit + Includes: stdlib.h - int aid (*function)(void)); - SVID 3, BSD 4.3, ISO 9899 - atexit () function registers the given function to be called at normal program termination, whether via exit(3) or via return from the program's main - http://www.iso-9899.info/man?atexit + + man getcwd + Includes: unistd.h - char *getcwd(char *buf, size_t size); - POSIX.1 - getcwd () function copies an absolute pathname of the current working directory to the array pointed to by buf, which is of length size - http://www.iso-9899.info/man?getcwd + +### google Displays google results for a query. - Usage: google [number of results] query - Samples: - google brian kernighan - brian kernighan (115,000): Brian Kernighan's Home Page: - (http://www.cs.princeton.edu/~bwk/) - google 3 brian kernighan - brian kernighan (115,000): Brian Kernighan's Home Page: - (http://www.cs.princeton.edu/~bwk/), An Interview with Brian - Kernighan: (http://www-2.cs.cmu.edu/~mihaib/kernighan-interview/), - Interview with Brian Kernighan | Linux Journal: - (http://www.linuxjournal.com/article.php?sid=7035), Brian W. - Kernighan: (http://www.lysator.liu.se/c/bwk/) ,Brian W. - Kernighan: Programming in C: A Tutorial: - (http://www.lysator.liu.se/c/bwk-tutor.html) -====define==== -====dict==== -Displays dictionary defintions from http://dict.org using DICT protocol. +Usage: `google [number of results] ` -Databases for the -d option are listed here: http://www.iso-9899.info/PBot/dict_databases.txt -- Note that there may be several commands aliased to one of these databases; for example, the `foldoc` command is an alias to `dict -d foldoc`. + google brian kernighan + brian kernighan (115,000): Brian Kernighan's Home Page: (http://www.cs.princeton.edu/~bwk/) - Usage: dict [-d database] [-n start from definition number] [-t abbreviation of word class type (n]oun, v]erb, adv]erb, adj]ective, etc)] - [-search for definitions matching ] + - Examples: + google 3 brian kernighan + brian kernighan (115,000): Brian Kernighan's Home Page: (http://www.cs.princeton.edu/~bwk/), An Interview with Brian Kernighan: (http://www-2.cs.cmu.edu/~mihaib/kernighan-interview/), Interview with Brian Kernighan | Linux Journal: (http://www.linuxjournal.com/article.php?sid=7035), Brian W. Kernighan: (http://www.lysator.liu.se/c/bwk/) ,Brian W. Kernighan: Programming in C: A Tutorial: (http://www.lysator.liu.se/c/bwk-tutor.html) - dict hit - hit: n: 1) (baseball) a successful stroke in an athletic contest (especially in baseball); - "he came all the way around on Williams' hit", 2) the act of contacting one thing with another; - "repeated hitting raised a large bruise"; "after three misses she finally got a hit" [syn: hitting, - striking], 3) a conspicuous success; "that song was his first hit and marked the beginning of his - career"; "that new Broadway show is a real smasher" +### define +### dict +Displays dictionary definitions from http://dict.org using DICT protocol. - dict -n 4 hit - hit: n: 4) (physics) an brief event in which two or more bodies come together; "the collision of the - particles resulted in an exchange of energy and a change of direction" [syn: collision], 5) a dose - of a narcotic drug, 6) a murder carried out by an underworld syndicate; "it has all the earmarks of - a Mafia hit", 7) a connection made via the internet to another website; "WordNet gets many hits from - users worldwide" +Databases for the `-d` option are listed here: http://www.iso-9899.info/PBot/dict_databases.txt -- Note that there may be several commands aliased to one of these databases; for example, the `foldoc` command is an alias to `dict -d foldoc`. - dict -t v hit - hit: v: 1) cause to move by striking; "hit a ball", 2) hit against; come into sudden contact with; - "The car hit a tree"; "He struck the table with his elbow" [syn: strike, impinge on, run into, - collide with] [ant: miss], 3) affect or afflict suddenly, usually adversely; "We were hit by really - bad weather"; "He was stricken with cancer when he was still a teenager"; "The earstruck at - midnight" [syn: strike], 4) deal a blow to +Usage: `dict [-d database] [-n start from definition number] [-t abbreviation of word class type (n]oun, v]erb, adv]erb, adj]ective, etc)] [-search for definitions matching ] ` - dict -search ball hit - hit: n: 1) (baseball) a successful stroke in an athletic contest (especially in baseball); "he came all - the way around on Williams' hit", v: 1) cause to move by striking; "hit a ball" + dict hit + hit: n: 1) (baseball) a successful stroke in an athletic contest (especially in baseball); "he came all the way around on Williams' hit", 2) the act of contacting one thing with another; "repeated hitting raised a large bruise"; "after three misses she finally got a hit" [syn: hitting, striking], 3) a conspicuous success; "that song was his first hit and marked the beginning of his career"; "that new Broadway show is a real smasher" - dict -d eng-fra hit - hit: 1) [hit] battre, frapper, heurter frapper, heurter atteindre, frapper, parvenir, saisir + -====foldoc==== -This is just an alias for `dict -d foldoc`. -====vera==== -This is just an alias for `dict -d vera`. + dict -n 4 hit + hit: n: 4) (physics) an brief event in which two or more bodies come together; "the collision of the particles resulted in an exchange of energy and a change of direction" [syn: collision], 5) a dose of a narcotic drug, 6) a murder carried out by an underworld syndicate; "it has all the earmarks of a Mafia hit", 7) a connection made via the internet to another website; "WordNet gets many hits from users worldwide" + + dict -t v hit + hit: v: 1) cause to move by striking; "hit a ball", 2) hit against; come into sudden contact with; "The car hit a tree"; "He struck the table with his elbow" [syn: strike, impinge on, run into, collide with] [ant: miss], 3) affect or afflict suddenly, usually adversely; "We were hit by really bad weather"; "He was stricken with cancer when he was still a teenager"; "The earstruck at midnight" [syn: strike], 4) deal a blow to -====udict==== + + + dict -search ball hit + hit: n: 1) (baseball) a successful stroke in an athletic contest (especially in baseball); "he came all the way around on Williams' hit", v: 1) cause to move by striking; "hit a ball" + + + + dict -d eng-fra hit + hit: 1) [hit] battre, frapper, heurter frapper, heurter atteindre, frapper, parvenir, saisir + +### foldoc +This is an alias for `dict -d foldoc`. + +### vera +This is an alias for `dict -d vera`. + +### udict Displays dictionary definitions from http://urbandictionary.com. - Usage: udict query -====wdict==== +Usage: `udict ` + +### wdict Displays Wikipedia article abstracts (first paragraph). Note: case-sensitive and very picky. - Usage: wdict query -====acronym==== +Usage: `wdict ` + +### acronym Displays expanded acronyms. - Usage: acronym query - Samples: - acronym posix - posix (3 entries): Portable Operating System for - Information Exchange, Portable Operating System Interface - Extensions (IBM), Portable Operating System Interface for - Unix - acronym linux - linux (1 entries): Linux Is Not UniX -====math==== -Evaluate calculations. - Usage: math - Example: - math 5 + 5 - 5 + 5 = 10 +Usage: `acronym ` -====compliment==== + acronym posix + posix (3 entries): Portable Operating System for Information Exchange, Portable Operating System Interface Extensions (IBM), Portable Operating System Interface for Unix + acronym linux + linux (1 entries): Linux Is Not UniX + +### math +### calc +Evaluate calculations. Can also perform various unit conversions. + +Usage: `math ` `calc ` + + calc 5 + 5 + 5 + 5 = 10 + + + + calc 80F to C + pragma-: 80F to C = 26.6666666666667 C + +### qalc +Evaluate calculations using the `QCalculate!` program. + +Usage: `qalc ` + +### compliment Displays a random Markov-chain compliment/insult. - Usage: compliment [nick] -====insult==== +Usage: `compliment [nick]` + +### insult Displays a random insult. - Usage: insult [nick] -====excuse==== +Usage: `insult [nick]` + +### excuse Displays a random excuse. - Usage: excuse [nick] -====horoscope==== +Usage: `excuse [nick]` + +### horoscope Displays a horoscope for a Zodiac sign (google this if you don't know your sign). - Usage: horoscope -====horrorscope==== +Usage: `horoscope ` + +### horrorscope Displays a horrorscope for a Zodiac sign. - Usage: horrorscope -====quote==== +Usage: `horrorscope ` + +### quote Displays quotes from a popular quotation database. If you use `quote` without arguments, it returns a random quote; if you use it -with an argument, it searches for quotes containing that text; if you add --author at the end, it searches for a quote by -that author; if you specify text and --author, it searches for quotes by that author, containing that text. - Usage: quote [search text] [--author ] - Samples: - quote - "Each success only buys an admission ticket to a more difficult problem." -- Henry Kissinger (1923 - ). - quote --author lao tzu - 41 matching quotes found. "A journey of a thousand miles begins with a single step." -- Lao-tzu (604 BC - 531 BC). - quote butterfly - 11 matching quotes found. "A chinese philosopher once had a dream that he was a butterfly. From that day on, he - was never quite certain that he was not a butterfly, dreaming that he was a man." -- Unknown. +with an argument, it searches for quotes containing that text; if you add `--author ` at the end, it searches for a quote by +that author; if you specify `text` and `--author`, it searches for quotes by that author, containing that text. -===Informative=== -====list==== +Usage: `quote [search text] [--author ]` + + quote + "Each success only buys an admission ticket to a more difficult problem." -- Henry Kissinger (1923 - ). + quote --author lao tzu + 41 matching quotes found. "A journey of a thousand miles begins with a single step." -- Lao-tzu (604 BC - 531 BC). + quote butterfly + 11 matching quotes found. "A chinese philosopher once had a dream that he was a butterfly. From that day on, he was never quite certain that he was not a butterfly, dreaming that he was a man." -- Unknown. + +Informative +----------- +### list Lists information about specified argument - Usage: list -====info==== +Usage: `list ` + +### info Shows detailed information about a module or a factoid - Usage: info -====version==== -Shows version information -====source==== +Usage: `info [channel] ` + +### version +Shows version information. + +### source Shows PBot's source information. -====help==== +### help Shows link to this page. -===Administrative=== -====login==== -You cannot use any of the admin commands unless you login first. - Usage: login -Note that login requires that your hostmask matches PBot's records. -====logout==== +Administrative +-------------- +### login +You cannot use any of the admin commands unless you login first. Note that login requires that your hostmask matches PBot's records. + +Usage: `login ` + +### logout Logs out of PBot. -====Admin Management==== -=====adminadd===== + +### Admin Management +#### adminadd Adds a bot admin. - Usage: adminadd -*''name'': a unique name to identify this account (usually the nick ofdmin, but can be any identifier). +Usage: `adminadd ` -*''channel'': which channel the admin can administrate; use "global" for all channels. This field cannot be changed without removing and re-adding the admin. +* `name`: a unique name to identify this account (usually the `nick` of the admin, but can be any identifier). -*''hostmask'': a regular expression of what hostmask the admin is recognized/allowed to login from (e.g., somenick!.*@.*.somedomain.com or .*@unaffiliated/someuser). This field cannot be changed without removing and re-adding the admin. +* `channel`: which channel the admin can administrate; use `global` for all channels. This field cannot be changed without removing and re-adding the admin. -*''level'': an integer representing their level of privileges. See [[#Admin_Levels|admin-levels]]. +* `hostmask`: a *regular expression* of what hostmask the admin is recognized/allowed to login from (e.g., `somenick!.*@.*.somedomain.com` or `.*@unaffiliated/someuser`). This field cannot be changed without removing and re-adding the admin. -*''password'': the password the admin will use to login (from /msg!). A password is not required if the `stayloggedin` meta-data is set for the admin; however, a dummy password still needs to be set. +* `level`: an integer representing their level of privileges. See [admin-levels](#Admin_Levels). -======Admin Levels====== +* `password`: the password the admin will use to login (from /msg!). A password is not required if the `stayloggedin` and `loggedin` meta-data are set for the admin; however, a dummy password still needs to be set. + +##### Admin Levels This is a list of admin commands allowed by each admin level. Higher level admins have access to all lower level admin commands. -* 10: whitelist, blacklist, chanlist, ban, unban, mute, unmute, kick, ignore, unignore -* 40: chanset, chanunset, chanadd, chanrem, join, part -* 60: adminadd, adminrem, adminset, adminunset, akalink, akaunlink, regadd, regrem, regset, regunset, regchange -* 90: sl, load, unload, export, rebuildaliases, refresh, die +* `10`: whitelist, blacklist, chanlist, ban, unban, mute, unmute, kick, ignore, unignore +* `40`: chanset, chanunset, chanadd, chanrem, join, part +* `60`: adminadd, adminrem, adminset, adminunset, akalink, akaunlink, regadd, regrem, regset, regunset, regchange +* `90`: sl, load, unload, export, rebuildaliases, refresh, die -=====adminrem===== +#### adminrem Removes a bot admin. You can use the name field or the hostmask field that was set via adminadd. - Usage: adminrem -=====adminset===== -Sets meta-data for an admin account. You can use the name field or the hostmask field that was set via adminadd. See also: [[#Admin_Metadata_List|admin metadata list]]. + +Usage: `adminrem ` + +#### adminset +Sets meta-data for an admin account. You can use the `name` field or the `hostmask` field that was set via `adminadd`. See also: [admin metadata list](#Admin_Metadata_List). If `key` is omitted, it will list all the keys and values that are set. If `value` is omitted, it will show the value for `key`. - Usage: adminset [ [value]] +Usage: `adminset [ [value]]` -======Admin Metadata List====== +##### Admin Metadata List This is a list of recognized meta-data keys for admin accounts. -* name: A unique name identifying this admin account. -* level: The privilege level of the admin. See [[#Admin_Levels|admin levels]]. -* password: The password for this admin account. -* loggedin: Whether the admin is logged in or not. -* stayloggedin: Do not automatically log the admin out when they part/quit. +* `name`: A unique name identifying this admin account. +* `level`: The privilege level of the admin. See [admin levels](#Admin_Levels). +* `password`: The password for this admin account. +* `loggedin`: Whether the admin is logged in or not. +* `stayloggedin`: Do not log the admin out when they part/quit. -=====adminunset===== -Deletes a meta-data key from an admin account. You can use the name field or the hostmask field that was set via adminadd. +#### adminunset +Deletes a meta-data key from an admin account. You can use the name `field` or the `hostmask` field that was set via adminadd. - Usage: adminunset +Usage: `adminunset ` -====Channel Management==== -=====chanadd===== -chanadd adds a channel to PBot's list of channels to auto-join and manage. +### Channel Management +#### chanadd +`chanadd` adds a channel to PBot's list of channels to auto-join and manage. - Usage: chanadd +Usage: `chanadd ` -=====chanrem===== -chanrem removes a channel from PBot's list of channels to auto-join and manage. +#### chanrem +`chanrem` removes a channel from PBot's list of channels to auto-join and manage. - Usage: chanrem +Usage: `chanrem ` -=====chanset===== -chanset sets a channel's meta-data. See [[#Channel_Metadata_List|channel meta-data list]] +#### chanset +`chanset` sets a channel's meta-data. See [channel meta-data list](#Channel_Metadata_List) - Usage: chanset [key [value]] +Usage: `chanset [key [value]]` -If both key and value are omitted, chanset will show all the keys and values for that channel. If only value is omitted, chanset will show the value for that key. +If both `key` and `value` are omitted, chanset will show all the keys and values for that channel. If only `value` is omitted, chanset will show the value for that key. -======Channel Metadata List====== -* enabled: when set to a true value, PBot will auto-join this channel after identifying to NickServ. -* chanop: when set to a true value, PBot will perform channel management (anti-flooding, ban-evasion, etc). -* permop: when set to a true value, PBot will automatically op itself when joining and remain opped instead of automatically opping and deopping as necessary. -=====chanunset===== -chanunset deletes a channel's meta-data key. +##### Channel Metadata List +* `enabled`: when set to a true value, PBot will auto-join this channel after identifying to NickServ (unless `general.autojoin_wait_for_nickserv` is `0`, in which case auto-join happens immediately). +* `chanop`: when set to a true value, PBot will perform channel management (anti-flooding, ban-evasion, etc). +* `permop`: when set to a true value, PBot will automatically op itself when joining and remain opped instead of automatically opping and deopping as necessary. - Usage: chanunset -=====chanlist===== -chanlist lists all added channels and their meta-data keys and values. +#### chanunset +`chanunset` deletes a channel's meta-data key. -====ignore==== -Ignore a user - Usage: ihostmask regex> [channel [timeout]] +Usage: `chanunset ` -Timeout can be specified as an relative time in English; for instance, "5 minutes", "1 month and 2 weeks", "next thursday", "friday after next", and so on. +#### chanlist +`chanlist` lists all added channels and their meta-data keys and values. -====unignore==== -Unignores a user2 - Usage: unignore [channel] +### ignore +Ignore a user. -====whitelist==== +Usage: `ignore [channel [timeout]]` + +Timeout can be specified as an relative time in English; for instance, `5 minutes`, `1 month and 2 weeks`, `next thursday`, `friday after next`, and so on. + +### unignore +Unignores a user. + +Usage: `unignore [channel]` + +### whitelist Whitelists a hostmask to be exempt from ban evasions. - Usage: whitelist - whitelist add - whitelist remove -====blacklist==== + +Usages: + +- `whitelist ` +- `whitelist add ` +- `whitelist remove ` + +### blacklist Blacklists a hostmask regex from joining a channel. - Usage: blacklist - blacklist add [channel] - blacklist remove [channel] -====ban==== -Bans a user. If the argument is a nick instead of a hostmask, it will determine an appropriate banmask for that nick. - Usage: ban [channel [timeout]] -If timeout is omitted, PBot will ban the user for 24 hours. Timeout can be specified as an relative time in English; for instance, "5 minutes", "1 month and 2 weeks", "next thursday", "friday after next", and so on. +Usages: -====unban==== -Unbans a user. If the argument is a nick instead of a hostmask, it will find all bans that match any of that nick's hostmasks or NickServ accounts and unban them. - Usage: - unban [channel] +- `blacklist ` +- `blacklist add [channel]` +- `blacklist remove [channel]` -====kick==== -Removes a nick from the channel. - Usage from channel: kick - From private message: kick +### ban +Bans a user. If the argument is a `nick` instead of a `hostmask`, it will determine an appropriate banmask for that nick. -====export==== +Usage: `ban [channel [timeout]]` + +If `timeout` is omitted, PBot will ban the user for 24 hours. Timeout can be specified as an relative time in English; for instance, `5 minutes`, `1 month and 2 weeks`, `next thursday`, `friday after next`, and so on. + +### unban +Unbans a user. If the argument is a `nick` instead of a `hostmask`, it will find all bans that match any of that nick's hostmasks or NickServ accounts and unban them. + +Usage: `unban [channel]` + +### kick +Removes a user from the channel. `nick` can be a comma-separated list of multiple users. If `reason` is omitted, a random insult will be used. + +Usage from channel: `kick [reason]` +From private message: `kick [reason]` + +### export Exports specified list to website. - Usage: export -====refresh==== -Refreshes/reloads PBot core modules (not the loadable modules since those are "loaded" each time they are invoked). + Usage: export `` -====sl==== +### refresh +Refreshes/reloads PBot core modules and plugins (not the command-line modules since those are executed/loaded each time they are invoked). + +### sl Sends a raw IRC line to the server. - Example: sl PRIVMSG #channel :Test message -====die==== +Usage: `sl ` + + sl PRIVMSG #channel :Test message + Test message + +### die Kills PBot. :-( Causes PBot to disconnect and exit. -===##c=== -====C-Aphorisms==== -The C Aphorisms can be triggered with c where is an integer representing one of the aphorisms. For example, to quote C Aphorism 1, use `c1`. +Flood control +============= +PBot can monitor the channel for excessive rapid traffic originating from an individual and automatically ban the offender for a certain length of time. -# The questioner's first description of the problem/question will be misleading. -# All examples given by the questioner will be incomplete, misleading, broken, wrong, and/or not representative of the actual question. -# The questioner will not read and apply the answers they are given but will instead continue to practice c1 and c2. -# The ignorant will continually mis-educate the questioner. -# When given a choice of solutions, the questioner will always choose the wrong one. -# The questioner will always find a reason to say, "It doesn't work." -# The questioner will paste code and say "I have a problem" or "It doesn't work" without any further information or description of the problem. -# The more beginner they are, the more likely they are to be overcomplicating it. -# The questioner will always have some excuse for doing it wrong. -# The newbie will not accept the answer you give, no matter how right it is. -# -# The newbie will think they are smarter than they really are. -# The newbie will fail to recognize undefined behavior, and will wrongly think that their program is correct because it appears to work. -# The more the questioner attempts to describe their problem, the less coherent their description becomes. -# When multiple people respond to the questioner's problem, the questioner will focus on the person giving incorrect advice and ignore everybody else. - -==Flood control== -PBot can monitor the channel for excessive rapid traffic originating from an individual and automaticallyoffender for a certain length of time. - -===Message flood=== +Message flood +------------- If four (4) or more messages are sent within five (5) seconds, the flood control is triggered. The offender will be muted for 30 seconds for the first offense. Each additional offense will result in the offender being muted for a much longer period. For example, the first offense will result in 30 seconds, the 2nd offense will be 5 minutes, the 3rd will be 1 hour, and so on. The offense counter is decremented once every 24 hours. The offender will be sent the following private message: "You have been muted due to flooding. Please use a web paste service such as http://ideone.com for lengthy pastes. You will be allowed to speak again in $timeout." -===Join flood=== -If four (4) or more JOINs are observed within thirty (30) minutes '''without any messages in between joins''', the offender will be forwarded to another channel for a limited time: 2^(number_of_offenses + 2) hours. +Join flood +---------- +If four (4) or more JOINs are observed within thirty (30) minutes *without any messages in between joins*, the offender will be forwarded to another channel for a limited time: 2^(number_of_offenses + 2) hours. -In addition to private instructions from PBot, this channel will have a /topic and ChanServ on-join message with instructions explaining to the offender how to remove the forwarding. The instructions are to message PBot with: unbanme . +In addition to private instructions from PBot, this channel will have a /topic and ChanServ on-join message with instructions explaining to the offender how to remove the forwarding. The instructions are to message PBot with: `unbanme`. Any messages sent to the public channel by the user at any time will reset their JOIN counter back to zero. The unbanme command can only be used for the first two offenses -- the offense counter is decremented once every 24 hours. -The offender will be sent the following private message: "You have been banned from $channel due to join flooding. If your connection issues have been resolved, or this was an accident, you may request an unban at any time by responding to this message with: unbanme $channel, otherwise you will be automatically unbanned in $timeout." +The offender will be sent the following private message: "You have been banned from $channel due to join flooding. If your connection issues have been resolved, or this was an accident, you may request an unban at any time by responding to this message with: `unbanme`, otherwise you will be automatically unbanned in $timeout." -===Enter key abuse=== +Enter key abuse +--------------- If four (4) consecutive messages are sent with ten (10) seconds or less between individual messages and without another person speaking, an enter-key-abuse counter is incremented. This counter will then continue to be incremented every two (2) consecutive messages with ten (10) seconds or less in between until another person speaks or more than ten (10) seconds have elapsed, whereupon it returns to requiring four (4) consecutive messages. When this counter reaches three (3) or greater, the offender will be muted using the same timeout rules as message flooding. This counter is automatically decremented once per hour. The offender will be sent the following private message: "You have been muted due to abusing the enter key. Please do not split your sentences over multiple messages. You will be allowed to speak again in $timeout." -===Nick flood=== +Nick flood +---------- If four (4) or more nick-changes are observed within thirty (30) minutes, the nick-change flood control is triggered. The offender will be muted for 15 minutes for the first offense. Each additional offense will result in the offender being muted for a much longer period. The offense counter is decremented once every 24 hours. The offender will be sent the following private message: "You have been temporarily banned due to nick-change flooding. You will be unbanned in $timeout." -==Anti-away/Nick-control== +Anti-away/Nick-control +====================== PBot can detect nick-changes to undesirable nicks such as those ending with |away, as well as undesirable ACTIONs such as /me is away. When such a case is detected, PBot will kick the offender with a link to http://sackheads.org/~bnaylor/spew/away_msgs.html in the kick message. -==Anti-auto-rejoin control== +Anti-auto-rejoin control +======================== PBot can detect if someone immediately auto-rejoins after having been kicked. -h a case is detected, PBot will kickban the offender (with a kick message of "$timeout ban for auto-rejoining after kick") for 5 minutes for the first offense. Each additional offense will result in the offender being banned for a much longer period. The offense counter is decremented once every 24 hours. +When such a case is detected, PBot will kickban the offender (with a kick message of "$timeout ban for auto-rejoining after kick") for 5 minutes for the first offense. Each additional offense will result in the offender being banned for a much longer period. The offense counter is decremented once every 24 hours. -==Opping/Deopping== -ChanServ will automagically op and deop PBot when necessary. PBot will wait until about 5 minutes have elapsed before requesting a deop from ChanServ. +Opping/Deopping +=============== +ChanServ can op and deop PBot as necessary, unless the channel `permop` meta-data is set to a true value. PBot will wait until about 5 minutes have elapsed before requesting a deop from ChanServ. This timeout can be controlled via the `general.deop_timeout` registry value, which can be overriden on a per-channel basis.