Candide
From C
Contents |
Candide
About Candide
Candide is an IRC bot written in Perl in _pragma's spare time.
All of candide's commands may begin with her name or !, or be followed by her name.
Note that commands need not be submitted to the channel; you can /msg her instead. If you /msg candide, she will respond with a private message in return. Also, you do not need to specify her name or one of the trigger symbols.
Directing output to a user
You may have candide 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:
<pragma_> !tell prec about man fork <pragma_> candide, tell Major-Willard about faq fflush
You may also direct candide to prepend the nickname of a specific person to a factoid in the channel by stating the nickname after the factoid:
<pragma_> !help defrost <candide> defrost: To learn all about me, see http://www.iso-9899.info/wiki/Candide
Source
Candide's source may be found at http://code.google.com/p/pbot2-pl/.
The URL for the source of any loaded modules may be found by using the 'info' command:
<pragma_> !info man
<candide> man: Loaded by pragma_ on 18:18:21-2005/01/30 ->
http://pragma.homeip.net/stuff/scripts/man.pl, used 10 times (last by pragma_)
Factoids
Adding a factoid
To add a factoid, use the following syntax:
!<factoid> is <description> example a: !add keyword is Information about factoid example b: candide, c is C rocks! example c: !c is C rocks!
Special commands
/say
If a factoid begins with "/say " then candide will not use the "<factoid> is <description>" format when displaying the factoid. Also, the "$nick" special variable will expand to the nick of the caller.
Example: <pragma_> !hi is /say Well, hello there, $nick. <candide> 'hi' added. <prec> candide, hi <candide> Well, hello there, prec.
/me
If a factoid begins with "/me " then candide will ACTION the factoid.
Example: <pragma_> !bounce is /me bounces around. <candide> 'bounce' added. <pragma_> !bounce *candide bounces around.
/call
If a factoid begins with "/call " then candide will call an existing command.
Example: <pragma_> !boing is /call bounce <candide> 'boing' added. <pragma_> !boing *candide bounces around.
/msg
If a factoid begins with "/msg <nick> " then candide will /MSG the factoid text to <nick>
Special variables
Currently there are two special variables:
$nick
$nick: expands to the nick of the caller
$args
$args: expands to any text following the keyword
adlib list variables
You may create a list of adlib words by using the normal factoid creation method. Also note that multiple words can be surrounded with double quotes to constitute one element.
Example: <pragma_> !colors is red green blue "bright yellow" pink "dark purple" orange <candide> 'colors' added
Then you can instruct candide to pick a random word from this list to use in another factoid by inserting the list as a variable.
Example: <pragma_> !sky is /say The sky is $colors. <candide> 'sky' added. <pragma_> !sky <candide> The sky is dark purple. <pragma_> !sky <candide> The sky is green.
A practical example, creating the RTFM trigger:
<pragma_> !sizes is big large tiny small huge gigantic teeny <candide> 'sizes' added. <pragma_> !attacks is whaps thwacks bashes smacks punts whacks <candide> 'attacks' added. <pragma_> !rtfm is /me $attacks $args with a $sizes $colors manual. <candide> 'rtfm' added. <pragma_> !rtfm mauke * candide thwacks mauke with a big red manual.
Viewing a factoid
To view a factoid, one merely issues its keyword as a command.
<pragma_> candide, c? <candide> c is C rocks!
Changing a factoid
To change a factoid, use the 'change' command:
Usage: change <keyword> s/<to change>/<change to>/
<pragma_> !change c s/rocks/rules/ <candide> c changed. <pragma_> !c <candide> c is C rules!
Note that the 2nd argument is a Perl-style regex. See 'man perlre'.
For instance, it is possible to append to a factoid by using:
'change factoid s/$/text to append/'
Likewise, you can prepend to a factoid by using:
'change factoid s/^/text to prepend/'
Alternatively, you may append to a factoid by using 'is also':
<pragma_> candide, c is also See FAQ at http://www.eskimo.com/~scs/C-faq/top.html <candide> Changed: c is C rules! ; See FAQ at http://www.eskimo.com/~scs/C-faq/top.html
Aliasing a factoid
To alias a factoid, use the 'alias' command or '!<alias> is /call <new command>'.
Example: <pragma_> !book is /me points accusingly at $args, "Where is your book?!" <candide> 'book' added. <pragma_> !book newbie *candide points accusingly at newbie, "Where is your book?!" <pragma_> !rafb is /call book <candide> 'rafb' added. <pragma_> !rafb runtime *candide points accusingly at runtime, "Where is your book?!"
Another example: <pragma_> !offtopic is /say In this channel, '$args' is off-topic. <pragma_> !offtopic C++ <candide> In this channel, 'C++' is off-topic. <pragma_> !alias C++ offtopic C++ (or !C++ is /call offtopic C++) <pragma_> !C++ <candide> In this channel, 'C++' is off-topic.
Deleting a factoid
To remove a factoid, use the 'remove' or 'forget' command.
!remove keyword !forget keyword
Finding a factoid
To search the database for a factoid, you may use the 'find' command. If there is only one match for the query, it will display that factoid, otherwise it will list all matches:
<pragma_> candide, find cast <candide> 3 factoids match: NULL casting dontcastmalloc
Information about a factoid
To get information about a factoid such as who submitted it and when (among other things soon to come), use the 'info' command:
<pragma_> candide, info NULL
<candide> NULL: Submitted by Major-Willard on 08:17:42-2005/01/01,
referenced 12 times (last by twkm)
To see the factoid string literal, use the 'show' command:
<pragma_> !show hi <candide> hi: /say Well, hello there, $nick.
To see how many factoids and what percentage of the database <nick> has submitted, use the 'count' command:
<pragma_> count prec <candide> prec has submitted 28 factoids out of 233 (12%) <pragma_> count twkm <candide> twkm has submitted 74 factoids out of 233 (31%) <pragma_> count pragma <candide> pragma has submitted 27 factoids out of 233 (11%)
To see a histogram of the top 10 factoid submitters, use the 'histogram' command:
<pragma_> !histogram
<candide> 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%)
To see the top 10 most popular factoids, use the 'top10' command.
List of factoids
The most recent exported list of factoids can be found here: http://blackshell.com/~msmud/candide/factoids.html.
Commands
Some commands are:
Modules
faq
Displays questions from the 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 #] <search regex>
Samples:
<pragma_> !faq cast malloc
<candide> 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
<pragma_> !faq 2 cast malloc
<candide> 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
<pragma_> !faq ^6.4
<candide> 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
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:
<pragma_> !man fork
<candide> 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
<pragma_> !man atexit
<candide> Includes: stdlib.h - int atexit(void (*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
<pragma_> !man getcwd
<candide> 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
Displays google results for a query.
Usage: !google [number of results] query
Samples:
<pragma_> !google brian kernighan
<candide> brian kernighan (115,000): Brian Kernighan's Home Page:
(http://www.cs.princeton.edu/~bwk/)
<pragma_> !google 3 brian kernighan
<candide> 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://dictionary.com.
Usage: !dict query
Samples:
<pragma_> !dict dennis ritchie
<candide> dennis ritchie (1 of 1 entries): Dennis M. Ritchie,
co-author of the Unix operating system, inventor of the {C}
programming language and demigod. See also KR, Core War, If
you want X, you know where to find it.
gdict
Displays dictionary definitions from http://google.com's define:<entry> search.
Usage: !gdict query
udict
Displays dictionary definitions from http://urbandictionary.com.
Usage: !udict query
wdict
Displays Wikipedia article abstracts (first paragraph). Note: case-sensitive and very picky.
Usage: !wdict query
acronym
Displays expanded acronyms.
Usage: !acronym query
Samples:
<pragma_> !acronym posix
<candide> posix (3 entries): Portable Operating System for
Information Exchange, Portable Operating System Interface
Extensions (IBM), Portable Operating System Interface for
Unix
<pragma_> !acronym linux
<candide> linux (1 entries): Linux Is Not UniX
weather
Displays current conditions and forecasts. (Note: currently half-broken.)
Usage: !weather zipcode or !weather city, state, country
Samples:
<pragma_> !weather chicago, il
<candide> United States, Illinois, Chicago (Updated 9:53 pm CST):
Temp: 9F/-12C (Feels like: -2F/-18C), High: 9F/-12C, Low:
9F/-12C, Sky: Mostly Cloudy, Humidity: 48%, Wind: W 8 mph,
Sunrise: 7:16 am, Sunset: 4:44 pm, Tonight: Partly cloudy
skies. Cold. Low around 5F. Winds WNW at 5 to 10 mph.
map
Displays nearby locations to provided location (for use with .weather).
Usage: !map zipcode or .map city, state, country
Samples:
<pragma_> !map chicago, il
<candide> United States, Illinois, Chicago - Nearby Locations: Fox
Valley, Chicago/Meigs Field, Cicero, Chicago/Midway Arpt,
Berwyn, Oak Park,
gspy
Displays recent search queries for a popular search engine.
Usage: !gspy
Samples:
<pragma_> !gspy
<candide> Recent search queries: cranberry mall, westminster,
architectural styles in glens falls, architectural styles
in glens falls, cameras, dayh-f036n090a, virgin valley art
association, spacemaker heat shield, calvinist, video
capture software, subaru wrx performance modifications
math
Extremely basic calculations.
Usage: !math expression Samples: <pragma_> !math 5 + 5 <candide> 5 + 5 = 10
compliment
Displays a random Markov-chain compliment/insult.
Usage: !compliment [nick]
insult
Displays a random insult.
Usage: !insult [nick]
excuse
Displays a random excuse.
Usage: !excuse [nick]
horoscope
Displays a horoscope for a Zodiac sign (google this if you don't know your sign).
Usage: !horoscope <sign>
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 <name> 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 <author name>]
Samples:
<pragma_> !quote
<candide> "Each success only buys an admission ticket to a more difficult problem." -- Henry Kissinger (1923 - ). Discuss!
<pragma_> !quote --author lao tzu
<candide> 41 matching quotes found. "A journey of a thousand miles begins with a single step." -- Lao-tzu (604 BC - 531 BC). Discuss!
<pragma_> !quote butterfly
<candide> 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. Discuss!
Informative
list
Lists information about specified argument
Usage: .list <modules|factoids|commands|admins>
info
Shows detailed information about a module or a factoid
Usage: .info <module|factoid>
version
Shows version information
source
Shows candide's source information.
Source for candide: http://pragma.homeip.net/stuff/scripts/pbot2.pl.
help
Shows link to this page.
Quotegrabs
Note that quotegrabs are a new addition and are currently a work-in-progress. Expect new features, and feel free to make suggestions!
Table of quotegrabs
A table of grabbed quotes can be found here: http://blackshell.com/~msmud/candide/quotegrabs.html
grab
Grabs a message someone says, and adds it to the quotegrabs database.
Usage: !grab <nick> [history] [channel] -- where [history] is an optional argument that is an integer number of recent messages; e.g., to grab the 3rd most recent message for nick, use !grab nick 3.
getq
Retrieves and displays a specific grabbed quote from the quotegrabs database.
Usage: !getq <quote-id>
rq
Retrieves and displays a random grabbed quote from the quotegrabs database.
Usage: !rq [nick search regex] [channel]
delq
Deletes a specific grabbed quote from the quotegrabs database. (Admins only.)
Usage: delq <quote-id>
Administrative
login
You cannot use any of the admin commands unless you login first
Usage: login <password>
Note that login requires that your nick and hostmask match candide's records.
logout
Logs out of candide.
ignore
Ignore a user
Usage: .ignore hostmask
unignore
Unignores a user
Usage: .unignore hostmask
quiet
Quiets a user
Usage: !quiet nick [timeout seconds]
If timeout is omitted, candide will quiet the user for one hour. Timeout is in seconds.
ban
Bans a user with a reason message using ChanServ's AUTOREM command
Usage:
If messaging candide: !ban <channel> <nick or hostmask> <reason>
If in channel: !ban <nick or hostmask> <reason>
Ban will kick the user from the channel if you supplied a nick instead of a hostmask. Using nick instead of hostmask is recommended where possible as ChanServ will expand it to the proper hostmask and Candide will also kick the offender.
unban
Removes a ChanServ AUTOREM ban
Usage: If messaging candide: !unban <channel> <hostmask> If in channel: !unban <hostmask>
Note that <hostmask> must EXACTLY match the hostmask in the ban list for the channel.
kick
Removes a nick from the channel
Usage: !kick <nick> <reason>
Must be used in the channel.
unquiet
Unquiets a user
Usage: !unquiet nick
export
exports specified list to web page
Usage: !export <commands|factoids|admins|channels>
Flood control
Candide now has hi-res timer support. As a result, he can now monitor the channel for excessive rapid traffic originating from an individual and automatically quiet the offender for a certain length of time.
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 a length of (offense * offense * 30) seconds. For example, the first offense will result in 30 seconds, the 2nd offense will be 120 seconds, the 3rd will be 270, and so on.
Candide will send the following message to the offender each offense, "You have been quieted due to flooding. Please use a web paste service such as http://rafb.net/paste for lengthy pastes. You will be allowed to speak again in ### seconds."
ChanServ will automagically op and deop Candide when necessary. ChanServ will wait until about 5 minutes have elapsed before deopping Candide.
