<liclass="toclevel-2"><ahref="#Directing_output_to_a_user"><spanclass="tocnumber">1.3</span><spanclass="toctext">Directing output to a user</span></a></li>
<liclass="toclevel-2"><ahref="#Viewing.2Ftriggering_a_factoid"><spanclass="tocnumber">2.4</span><spanclass="toctext">Viewing/triggering a factoid</span></a></li>
<liclass="toclevel-2"><ahref="#Viewing.2Ftriggering_another_channel.27s_factoid"><spanclass="tocnumber">2.5</span><spanclass="toctext">Viewing/triggering another channel's factoid</span></a>
<liclass="toclevel-2"><ahref="#Information_about_a_factoid"><spanclass="tocnumber">2.9</span><spanclass="toctext">Information about a factoid</span></a>
<liclass="toclevel-4"><ahref="#C_and_C.2B.2B_Functionality"><spanclass="tocnumber">3.2.1.4</span><spanclass="toctext">C and C++ Functionality</span></a></li>
<liclass="toclevel-4"><ahref="#Using_the_preprocessor"><spanclass="tocnumber">3.2.1.5</span><spanclass="toctext">Using the preprocessor</span></a>
<liclass="toclevel-4"><ahref="#main.28.29_Function_Unnecessary"><spanclass="tocnumber">3.2.1.6</span><spanclass="toctext">main() Function Unnecessary</span></a></li>
<liclass="toclevel-4"><ahref="#Printing_in_binary.2Fbase2"><spanclass="tocnumber">3.2.1.8</span><spanclass="toctext">Printing in binary/base2</span></a></li>
<liclass="toclevel-4"><ahref="#Disallowed_system_calls"><spanclass="tocnumber">3.2.1.9</span><spanclass="toctext">Disallowed system calls</span></a></li>
<liclass="toclevel-4"><ahref="#Using_the_GDB_debugger"><spanclass="tocnumber">3.2.1.10</span><spanclass="toctext">Using the GDB debugger</span></a>
<liclass="toclevel-5"><ahref="#Program_termination_with_no_output"><spanclass="tocnumber">3.2.1.10.6</span><spanclass="toctext">Program termination with no output</span></a></li>
<liclass="toclevel-5"><ahref="#Abnormal_program_termination"><spanclass="tocnumber">3.2.1.10.7</span><spanclass="toctext">Abnormal program termination</span></a></li>
<p>PBot is an IRC bot written in Perl in pragma_'s spare time.
</p><p>All of <b>PBot'</b>s commands may begin with its name or its trigger (defaults to exclaimation mark [!]; the freenode instance uses a comma [,]), or be followed by its name.
</p><p>Note that commands need not be submitted to the channel; you can /msg it instead. If you /msg <b>PBot</b>, 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.
<p>PBot's source may be found at <ahref="http://code.google.com/p/pbot2-pl/"class="external free"title="http://code.google.com/p/pbot2-pl/"rel="nofollow">http://code.google.com/p/pbot2-pl/</a>. It can be browsed at <ahref="http://code.google.com/p/pbot2-pl/source/browse/#svn/trunk/"class="external free"title="http://code.google.com/p/pbot2-pl/source/browse/#svn/trunk/"rel="nofollow">http://code.google.com/p/pbot2-pl/source/browse/#svn/trunk/</a>.<br/>
The URL for the source of any loaded modules may be found by using the 'info' command:
</p>
<pre><pragma_> info faq
<PBot> faq: Module loaded by pragma_ on Fri Dec 31 02:34:04 2004 ->
<ahref="http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/cfaq.pl"class="external free"title="http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/cfaq.pl"rel="nofollow">http://code.google.com/p/pbot2-pl/source/browse/trunk/modules/cfaq.pl</a>, used 512 times (last by ecrane)
</pre>
<aname="Directing_output_to_a_user"></a><h3><spanclass="mw-headline">Directing output to a user</span></h3>
<p>You may have <b>PBot</b> send the output of a command to a specific person via a /msg (opposed to in the channel), by using the
'tell <nick> about <command>' syntax:
</p>
<pre><pragma_> !tell prec about man fork
<pragma_> PBot, tell Major-Willard about faq fflush
</pre>
<p>You may also direct PBot to prepend the nickname of a specific person to a factoid in the channel by stating the nickname after the factoid:
</p>
<pre><pragma_> !help defrost
<PBot> defrost: To learn all about me, see <ahref="http://www.iso-9899.info/wiki/Candide"class="external free"title="http://www.iso-9899.info/wiki/Candide"rel="nofollow">http://www.iso-9899.info/wiki/Candide</a>
<p>Factoids added in one channel may be called/triggered in another channel, providing that the other channel doesn't already have a factoid of the same name.
</p><p>Factoids may also be added to a special channel named .*. 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 .* channel or other channels.
</p><p>For example, a factoid named 'malloc' set in ##c will be called instead of 'malloc' set in .*,
if the factoid were triggered in ##c; otherwise, the latter 'malloc' will be triggered if the factoid were triggered in another channel.
</p><p>Similiarily, if there were no 'malloc' factoid in the .* 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.
</p><p>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 .* factoid.
</p><p>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 command to call the correct factoid.
</p>
<aname="Adding_a_factoid"></a><h3><spanclass="mw-headline">Adding a factoid</span></h3>
<p>There are two ways to add a factoid. The first is:
</p>
<pre> !<factoid> is <description>
</pre>
<p>In this case, the factoid will be created as belonging to
the channel in which the command was executed. <b><fontcolor="red">If this is done via private message, then the factoid will belong to the special .* channel.</font></b>
<pragma_> !factchange ##c c s/rocks/rules/
<PBot> c changed.
<pragma_> !c
<PBot> C rules!
</pre>
<p>Note that the 2nd argument is a Perl-style regex. See 'man perlre'.
</p>
<pre> For instance, it is possible to append to a factoid by using:
'factchange channel factoid s/$/text to append/'
</pre>
<pre> Likewise, you can prepend to a factoid by using:
'factchange channel factoid s/^/text to prepend/'
</pre>
<p>Alternatively, you may append to a factoid by using 'is also':
</p>
<pre><pragma_> PBot, c is also See FAQ at <ahref="http://www.eskimo.com/~scs/C-faq/top.html"class="external free"title="http://www.eskimo.com/~scs/C-faq/top.html"rel="nofollow">http://www.eskimo.com/~scs/C-faq/top.html</a>
<PBot> Changed: c is /say C rules! ; See FAQ at <ahref="http://www.eskimo.com/~scs/C-faq/top.html"class="external free"title="http://www.eskimo.com/~scs/C-faq/top.html"rel="nofollow">http://www.eskimo.com/~scs/C-faq/top.html</a>
<p>Omit <key> and <value> to list all the keys and values for a factoid. Specify <key>, but omit <value> to see the value for a specific key.
<p>Omit <key> and <value> to list all the keys and values for a factoid. Specify <key>, but omit <value> to see the value for a specific key.
<p>Note that quotegrabs are a new addition and are currently a work-in-progress. Expect new features, and feel free to make suggestions!
</p>
<aname="Table_of_quotegrabs"></a><h4><spanclass="mw-headline">Table of quotegrabs</span></h4>
<p>A table of grabbed quotes can be found here: <ahref="http://blackshell.com/~msmud/candide/quotegrabs.html"class="external free"title="http://blackshell.com/~msmud/candide/quotegrabs.html"rel="nofollow">http://blackshell.com/~msmud/candide/quotegrabs.html</a>
<p>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.
</p><p>The program is executed within a gdb debugger instance, which may be interacted with via the gdb macros described below or with the gdb("command") function.
</p><p>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.
</p><p>Uses gcc 4.7-20120129 and gdb 7.4-20120124.
<p>The -lang option accepts the following languages: C, C99 and C11. You may also use the -std=<c89|gnu89|c99|gnu99|etc> compiler option to specify which standard to follow.
</p><p>Support for additional languages coming soon.
<p>In C and C++, you may #include <file.h> 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.
</p>
<pre><pragma_> cc #include <sys/utsname.h> struct utsname u; uname(&u);
<PBot> 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)"}>
<p>In the previous examples, only the specified includes (e.g., <sys/utsname.h> in the first example, <stdio.h> and <stdlib.h> in the second, will be included instead of the default includes.
<p>You can also #define macros; however, #defines require an explicit "\n" sequence to terminate, otherwise the remainder of the line will be part of the macro.
</p>
<pre><pragma_> cc #define GREETING "Hello, World"\n puts(GREETING);
<PBot> pragma_: Hello, World
</pre>
<aname="main.28.29_Function_Unnecessary"></a><h5><spanclass="mw-headline">main() Function Unnecessary</span></h5>
<p>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; anything outside of any functions, excluding preprocessor stuff, will be put into this new main function. Here's an example:
</p>
<pre><pragma_> !cc int add(int a, int b) { return a + b; } printf("4 + 6 = %d -- ", add(4, 6)); int add3(int a, int b, int c)
<PBot> 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
</pre>
<aname="Program_termination_with_no_output"></a><h6><spanclass="mw-headline">Program termination with no output</span></h6>
<p>If there is no output, information about the local variables will be displayed.
</p>
<pre><pragma_> cc int x = 5, y = 16; x ^= y, y ^= x, x ^= y;
<PBot> pragma_: <no output: x = 16; y = 5>
</pre>
<pre><pragma_> cc #include <sys/utsname.h> struct utsname u; uname(&u);
<PBot> 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)"}>
</pre>
<aname="Abnormal_program_termination"></a><h6><spanclass="mw-headline">Abnormal program termination</span></h6>
<p>If a signal is detected, the bot will display useful information.
</p><p>Example session:
</p>
<pre>< pragma_> ,cc char *p = 0; *p = 1;
< PBot> pragma_: Program received signal 11 (SIGSEGV) at statement: *p = 1; <local variables: p = 0x0>
<p>The !cc command supports interactive-editing. The general syntax is: !cc [command].
</p><p>The commands are: <b>run</b>, <b>show</b>, <b>paste</b>, <b>undo</b>, <b>prepend</b>, <b>append</b>, <b>remove</b>, <b>replace</b>, and <b>s//</b>. With the exception of <b>undo</b>, which must be the first command, the rest of the commands may be chained together by separating them with whitespace or "and".
</p><p>The commands are described in more detail below:
<p>This command is identical to the cc command, with the following exceptions: does not accept compiler options and may be using an older version of "interactive-editing".
<ul><li> The -nowarn option is specific to the C programming language; it removes the -Werror and -strict options, and changes -std to gnu89.
</li><li> The -showurl option reformats the final code with includes and indentation, and displays the Ideone pasted URL. (Useful for viewing the complete and compilable code.)
</li><li> The -input=<stdin input> option provides STDIN input (i.e., scanf(), getc(stdin), etc.); MUST be the last option.
</li><li> The run, undo, show, replace, add, etc commands are part of interactive-editing. See below.
<p>The cc3 command is identical to the cc2 command, with the exception of using an older version of GCC (4.1.2) through <ahref="http://codepad.org"class="external free"title="http://codepad.org"rel="nofollow">http://codepad.org</a>. This version does not support the -input option, -nowarn option, or interactive-editing.
</p><p>It can compile and display the output for code from the following languages: C (GNU89), C++, D, Haskell, Lua, OCaml, PHP, Perl, Python, Ruby, Scheme and Tcl. Defaults to C (GNU89).
<p>Displays questions from the <ahref="http://http://www.eskimo.com/~scs/C-faq/top.html"class="external text"title="http://http://www.eskimo.com/~scs/C-faq/top.html"rel="nofollow">comp.lang.c faq</a>. 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.
<p>Searches ISO/IEC 9899:TC3 (WG14/N1256), also known as the C99 draft standard. <ahref="http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf"class="external free"title="http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf"rel="nofollow">http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf</a>
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.
</pre>
<pre> Examples:
</pre>
<pre>< 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 <ahref="http://codepad.org/f2DULaGQ"class="external free"title="http://codepad.org/f2DULaGQ"rel="nofollow">http://codepad.org/f2DULaGQ</a> for full text.
</pre>
<pre>< pragma_> !c99std pointer value -list
6.7.5.1p3, 6.7.5.2p7, 7.1.1p1, 7.1.1p4, 7.1.4p1, 7... truncated; see <ahref="http://codepad.org/qQlnJYJk"class="external free"title="http://codepad.org/qQlnJYJk"rel="nofollow">http://codepad.org/qQlnJYJk</a> for full text.
</pre>
<pre>< pragma_> Hmm, how about just section 6.3?
</pre>
<pre>< pragma_> !cstd 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 <ahref="http://codepad.org/mf1RNnr2"class="external free"title="http://codepad.org/mf1RNnr2"rel="nofollow">http://codepad.org/mf1RNnr2</a> for full text.
</pre>
<pre>< pragma_> !cstd pointer value 6.3 -list
<p>Searches ISO/IEC 9811:201X (WG14/N1256), also known as the C11 draft standard. <ahref="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf"class="external free"title="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf"rel="nofollow">http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf</a>
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 - <ahref="http://www.iso-9899.info/man?getcwd"class="external free"title="http://www.iso-9899.info/man?getcwd"rel="nofollow">http://www.iso-9899.info/man?getcwd</a>
<PBot> brian kernighan (115,000): Brian Kernighan's Home Page:
(<ahref="http://www.cs.princeton.edu/~bwk/"class="external free"title="http://www.cs.princeton.edu/~bwk/"rel="nofollow">http://www.cs.princeton.edu/~bwk/</a>), An Interview with Brian
(<ahref="http://www.linuxjournal.com/article.php?sid=7035"class="external free"title="http://www.linuxjournal.com/article.php?sid=7035"rel="nofollow">http://www.linuxjournal.com/article.php?sid=7035</a>), Brian W.
Kernighan: (<ahref="http://www.lysator.liu.se/c/bwk/"class="external free"title="http://www.lysator.liu.se/c/bwk/"rel="nofollow">http://www.lysator.liu.se/c/bwk/</a>) ,Brian W.
<p>Displays dictionary defintions from <ahref="http://dict.org"class="external free"title="http://dict.org"rel="nofollow">http://dict.org</a> using DICT protocol.
</p><p>Databases for the -d option are listed here: <ahref="http://blackshell.com/~msmud/candide/dict_databases.txt"class="external free"title="http://blackshell.com/~msmud/candide/dict_databases.txt"rel="nofollow">http://blackshell.com/~msmud/candide/dict_databases.txt</a>
</p>
<pre> Usage: dict [-d database] [-n start from definition number] [-t first letter of word class type (n]oun, v]erb, etc)]
[-search <regex> for definitions matching <regex>] <word>
</pre>
<pre> Examples:
</pre>
<pre><pragma_> dict hit
<PBot> 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"
</pre>
<pre><pragma_> dict -n 4 hit
<PBot> 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"
</pre>
<pre><pragma_> dict -t v hit
<PBot> 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 earthquake struck at
midnight" [syn: strike], 4) deal a blow to
</pre>
<pre><pragma_> dict -search ball hit
<PBot> 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"
<p>PBot can monitor the channel for excessive rapid traffic originating from an individual and automatically ban the offender for a certain length of time.
<p>If four (4) or more messages are sent within ten (10) seconds, the flood control is triggered. The offender will be quieted for 30 seconds for the first offense. Each additional offense will result in the offender being quieted for 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.
<p>If four (4) or more JOINs are observed within thirty (30) minutes <b>without any messages in between joins</b>, the offender will be forwarded to another channel for a limited time: 2^(number_of_offenses + 2) hours.
</p><p>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 <channel>.
</p><p>(Any messages sent to the public channel by the user at any time will reset their JOIN counter back to zero.)
<p>"You have been quieted due to flooding. Please use a web paste service such as <ahref="http://codepad.org"class="external free"title="http://codepad.org"rel="nofollow">http://codepad.org</a> for lengthy pastes. You will be allowed to speak again in ### seconds."
<p>"You have been banned from $channel for $timeout 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"
<p>ChanServ will automagically op and deop PBot when necessary. PBot will wait until about 5 minutes have elapsed before requesting a deop from ChanServ.