1 \input texinfo @c -*- texinfo -*-
3 @setfilename bobot++.info
4 @settitle Bobot++: A Schemeable IRC Bot
9 This file documents Bobot++ by Clinton Ebadi and Etienne Bernard
10 (The original author who no longer works on the program).
12 Copyright 2002,2004,2005 Clinton Ebadi
14 Permission is granted to copy, distribute and/or modify this document
15 under the terms of the GNU Free Documentation License, Version 1.1 or
16 any later version published by the Free Software Foundation; with no
17 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
23 @title Bobot++: A Schemeable IRC Bot
27 @vskip 0pt plus 1filll
28 Copyright @copyright{} 2002,2004,2005 Clinton Ebadi
30 Permission is granted to copy, distribute and/or modify this document
31 under the terms of the GNU Free Documentation License, Version 1.1 or
32 any later version published by the Free Software Foundation; with no
33 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
38 @node Top, Introduction, (dir), (dir)
39 @comment node-name, next, previous, up
42 This document describes Bobot++ by Clinton Ebadi and Etienne Bernard
43 (The original author who no longer works on the program).
45 This document applies to version 2.2 of the program named
48 Copyright 2002,2004,2005 Clinton Ebadi
50 Permission is granted to copy, distribute and/or modify this document
51 under the terms of the GNU Free Documentation License, Version 1.1 or
52 any later version published by the Free Software Foundation; with no
53 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
67 --- The Detailed Node Listing ---
71 * Configuration File Placement::
72 * Configuration Files::
109 * Bot Control Commands::
113 * User List Commands::
114 * Server List Commands::
115 * Shit List Commands::
117 * Scripting Commands::
118 * Authentication Commands::
119 * Miscellaneous Commands::
123 * Adding New Commands::
126 * Misc Scripting Stuff::
137 * Received Message Hooks::
138 * Sent Message Hooks::
140 * Miscellaneous Hooks::
144 * High Level Message Functions::
145 * Low Level Message Functions::
147 Misc. Scripting Stuff
155 @node Introduction, Configuration, Top, Top
156 @chapter Introduction
158 Bobot++ is a powerful IRC bot written in C++. It can be used
159 standalone as a channel maintenence bot, or extended to do almost
160 anything using Scheme scripts.
162 FIXME: Fill the intro in more?
164 @node Configuration, Using the Bot, Introduction, Top
165 @chapter Configuration
167 Bobot++ is easy to configure. See the @file{examples} directory for an
168 example configuration.
170 The main configuration file is @file{bot.conf}. There are several
171 auxiliary configuration files (a user list, aliases file, ban list,
172 and a script autoexec).
175 * Configuration File Placement::
176 * Configuration Files::
179 @node Configuration File Placement, Configuration Files, Configuration, Configuration
180 @section Configuration File Placement
182 Bobot++ will look in @file{/etc/bobotpp/default/} for its default
183 config if none is specified on the command line. Put the configuration
184 files you want to be loaded by default in this directory. If you are
185 not root, or you want to have your own personal configuration, put it
186 in @file{~/.bobotpp/config/default/}.
188 @node Configuration Files, , Configuration File Placement, Configuration
189 @section Configuration Files
199 @node bot.conf, bot.users, Configuration Files, Configuration Files
202 @file{bot.conf} contains key value pairs separated by @code{=}.
204 @code{<key> = <value>}
206 Comments are started with a @code{#} and cause the entire line to be
207 ignored. @emph{Note that this only works when the @code{#} is the first
208 character of the line}.
210 bot.conf is the main configuration file for a Bobot++. The available
211 configuration variables are listed below in the format ``@var{variable}
212 <default-value>: description''
214 A few of the options have more complex syntax, they are documented in
215 their own subsections.
224 @item @var{maxnicklength} <9>: The maximum length a valid nickname may
225 be. This should be set before setting the bot's nickname if it will be
226 more than nine characters long. Most IRC servers support nicknames
227 longer than nine characters, but Bobot++ still follows the old spec
228 and defaults to nine.
229 @item @var{nickname} <Bobot>: The nickname of the bot (@var{nick} is an
230 alias for @var{nickname})
231 @item @var{username} <bobot>: The IRC username of the bot
232 @item @var{cmdchar} <!>: The character that prefixes commands given to
233 the bot (@var{command} is an alias for @var{cmdchar})
234 @item @var{ircname} <I'm a bobot++!>: The IRC name (or 'real name') of
235 the bot (@var{realname} is an alias for @var{ircname})
236 @item @var{userlist} <bot.users>: Name of the file where the userlist is
238 @item @var{autoexecfile} <bot.autoexec>: Name of the file containing
239 Scheme code to be executed when the bot starts (only used if the bot
240 is compiled with scripting support)
241 @item @var{initfile} <bot.init>: Name of the file containing the
242 default command aliases
243 @item @var{shitlist} <bot.shit>: Name of the file where the shitlist
245 @item @var{logfile} <$LOGDIR/bot.log>: Location of the bot logfile
246 (set this to @file{/dev/null} to disable logging).
247 @item @var{server} <None>: This specifies the server to which the bot
248 will connect. Note that this has a special syntax @pxref{server
250 @item @var{channel} <None>: This specifies the channels the bot will join
251 when it starts up. This has a special syntax @pxref{channel
256 @node server syntax, channel syntax, bot.conf, bot.conf
257 @subsubsection server syntax
259 The server syntax in @file{bot.conf} allows you to specify an
260 alternate port to connect on, and a password to send the server.
262 You may use more than one server line; Bobot++ will attempt to connect
263 to the first one, and will connect to the next one in the list if it
264 fails. The bot will continue cycling through the server list until it
265 is able to connect to one. There is a command (@code{!cycle}) to make
266 the bot to cycle servers.
268 @var{server} = @var{server_name} [@var{port} [@var{password}]]
270 This will make Bobot++ attempt to connect to @var{server_name} on port
271 @var{port} with the password @var{password}. @var{server_name} should
272 be the address of the server. @var{port} and @var{password} are
275 @node channel syntax, , server syntax, bot.conf
276 @subsubsection channel syntax
278 The channel syntax in @file{bot.conf} allows you to specify the
279 initial modes the bot should set on a channel, the modes the bot
280 should maintain, and a key if the channel needs it.
282 You may have any number of channel lines. When Bobot++ starts it will
283 attempt to join and gain operator status in every channel listed.
286 @var{name}:@var{initial_modes}:@var{modes_to_keep}:@var{channel_key}
288 The bot will join @var{name} and set the channel modes to
289 @var{initial_modes} (e.g. ``nt'') if it is able to gain operator
290 status. It will then maintain @var{modes_to_keep}. If the channel
291 requires a key to enter simply set @var{channel_key}. Every argument
292 except for @var{name} is optional.
297 @var{channel} = #foo:nt:nt:bar
300 The bot will join @code{#foo} with the channel key @code{bar} and will
301 then maintain the modes @code{nt}.
304 @var{channel} = #bar:::
307 The bot will join @code{#bar} and will not set any modes nor will it
308 attempt to maintain any modes.
310 @node bot.users, bot.init, bot.conf, Configuration Files
311 @subsection bot.users (User List)
313 @file{bot.users} is the default file name of the userlist. It may be
314 changed in @file{bot.conf} via the @var{userlist} option. @strong{You
315 must add an entry for yourself manually.} You will probably want to
316 add other entries using the IRC command interface as it is more
317 intuitive than editing the file by hand.
319 The file contains lines with the format:
321 @samp{@var{host_mask}:@var{channel_mask}:@var{level}:@var{protection}:@var{auto-op}:@var{expiration}:@var{password}}
325 @item @var{host_mask} is the host mask
326 (e.g. @samp{*!*username@*.domain.com}) of the user
328 @item @var{channel_mask} is a channel mask of the channels that the user
329 has priviliges to use the bot in (e.g. @samp{*} for all channels,
330 @samp{#*} for all non-local channel, @samp{#foo*} for all channels
331 starting with ``foo,'' @samp{#bar} for channel ``#bar'' only, etc.)
333 @item @var{level} is the user level of the user (@ref{User Levels}).
335 @item @var{protection} is the protection level of the user
338 @item @var{auto-op} is set to control whether a user is automatically
339 given operator priviliges on channel entry (@ref{Automatic Op}).
341 @item @var{expiration} is the UNIX timestamp of when the user entry
342 becomes invalid. Setting this to -1 will make the entry permanent.
344 @item @var{password} is the password the user must supply to the bot
345 to authenticate. This can be set to @code{*NONE*} to not have a password.
349 @node bot.init, bot.autoexec, bot.users, Configuration Files
350 @subsection bot.init (Command Aliases)
352 This file stores a list of IRC command aliases. The filename may be
353 changed in @file{bot.conf} via the @var{initfile} option. You use this
354 file to set up aliases for IRC commands, e.g. to make @code{!a} call
355 @code{!adduser}. This way you can save typing for commonly used commands.
357 The format of a line in the file is:
358 @var{alias} @var{command}
360 This will make @var{alias} call @var{command}. e.g. @samp{t topic}
361 will make @code{!t New Topic} set the current channel's topic to ``New
362 Topic,'' just as if you had used @code{!topic New Topic}.
364 @node bot.autoexec, bot.shit, bot.init, Configuration Files
365 @subsection bot.autoexec (Scheme Init File)
367 This file is only used when Bobot++ is compiled with scripting
368 support. The name of the autoexec file can be changed in
369 @file{bot.conf} via the @var{autoexecfile} option.
371 The contents of this file are evaluated by Guile when the bot
372 starts. You can use this to do things like loading a few default
373 modules when the bot starts.
375 @node bot.shit, , bot.autoexec, Configuration Files
376 @subsection bot.shit (Ban/Shit List)
378 This file stores the ban list. The name may be changed in
379 @file{bot.conf} via the @var{shitlist} option. You will most likely
380 want to use the IRC command interface to edit this file instead of
383 The file contains lines in the form:
385 @samp{@var{host_mask}:@var{channel_mask}:@var{level}:@var{expiration}:@var{reason}}
389 @item @var{host_mask} is the host mask
390 (e.g. @samp{*!*username@*.domain.com}) of the user
392 @item @var{channel_mask} is a channel mask of the channels that the user
393 is banned on (e.g. @samp{*} for all channels,
394 @samp{#*} for all non-local channel, @samp{#foo*} for all channels
395 starting with ``foo,'' @samp{#bar} for channel ``#bar'' only, etc.
397 @item @var{level} is a number specifying if the bot should not allow
398 the user to gain ops, to kick the user upon joining, or to prevent the
399 user from being debanned by other users. @ref{Shit Levels} for
400 information on the available levels.
402 @item @var{expiration} is the UNIX timestamp of when the shit entry
403 becomes invalid. This may be set to -1 to make it valid forever.
405 @item @var{reason} is text that is sent to the user when they are
406 kicked or banned from the channel.
410 @node Using the Bot, Scripting, Configuration, Top
411 @chapter Using Bobot++
413 Using Bobot++ is easy. This chapter covers starting the bot, a few
414 Bobot++ specific concepts, and using the built-in commands of the bot.
419 * Built-In Commands::
422 @node Starting the Bot, Concepts, Using the Bot, Using the Bot
423 @section Starting the Bot
425 The bot is usually installed with the binary name @file{bobotpp}. It
426 accepts the following command line arguments.
429 @item @code{[--help][-h]} - Shows detailed help and exits
430 @item @code{[--version][-v]} - Shows version information and exits
431 @item @code{[--no-background][-b]} - Run bobot++ in the foreground
432 @item @code{[--config-file file][-f]} - Use file instead of @file{bot.conf}
433 @item @code{[--config-dir dir][-d]} - Use dir as dir to load config file from
434 @item @code{[--config dir][-c]} - Search your config path (defaults to
435 @file{@var{$HOME}/.bobotpp/config/} and then @file{/etc/bobotpp/}) for
436 dir and then loads your config data using dir
437 @item @code{[--sys-config dir][-s]} - Looks for config in
438 @file{/etc/bobotpp/dir}. Note that the user dir is still searched
440 @item @code{[--user-config dir][-u]} - Looks for config in
441 @file{@var{$HOME}/.bobotpp/config/dir/}. Note that the system dir is
442 still searched after this if dir is not found.
443 @item @code{[--debug][-D]} Makes Bobot++ print debugging info and run
445 @item @code{[--debug-scripts][-S]} Enables the Guile debugging
446 evaluator for verbose script errors and backtraces while still running
447 the bot in the background.
450 The default configuration is read from
451 @file{@var{$HOME}/.bobotpp/config/default/} and then
452 @file{/etc/bobotpp/default/} if the user config is not found.
454 The bot defaults to running in the background as a daemon.
456 @node Concepts, Built-In Commands, Starting the Bot, Using the Bot
459 There are a few general concepts that a user of Bobot++ should know
469 @node User List, Shit List, Concepts, Concepts
470 @subsection User List
472 @node Shit List, Spy List, User List, Concepts
473 @subsection Shit List
475 @node Spy List, Levels, Shit List, Concepts
478 @node Levels, , Spy List, Concepts
488 @node User Levels, Protection, Levels, Levels
489 @subsubsection User Levels
491 There are several user levels available in Bobot++ to provide gradated
492 access to commands. @command{!adduser} and @file{bot.users} use the
493 numeric code; Scheme uses the textual name for the level. By default
494 (if the user is not found in the userlist) a user has access to
495 commands with the level @code{bot:user-none}.
499 @item @code{bot:user-none} - No @strong{built-in} commands may be
500 executed @emph{by default} (commands may be added from Scheme that can
501 be executed by users of level none and the level required to execute a
502 command may be changed from Scheme).
504 @item @code{bot:user-user} - Will be able to execute most commands but
505 not all and cannot use masks on kicks and bans.
507 @item @code{bot:user-trusted} - For built-ins with a default
508 configuration this user has access to the same set of commands as an
509 @code{user} but may use masks on kicks and bans. Scheme commands may
510 be added which require a user to be of this level.
512 @item @code{bot:user-friend} - In the default configuration a user who
513 is a friend will be able to do everything short of stopping the
514 bot. Again, there may be user added commands that require a higher
517 @item @code{bot:user-master} - This is the highest user level and has
518 access to every feature of the bot.
522 @node Protection, Automatic Op, User Levels, Levels
523 @subsubsection Protection
525 A user added via Scheme, the @file{bot.users} file, or
526 @command{!adduser} may be protected from being deoped, kicked, or
527 banned. The user list and IRC commands use the numeric codes, Scheme
528 uses the symbolic names.
531 @item @code{bot:protection/none} No protection
532 @item @code{bot:protection/no-ban} No ban. If a user is banned the bot will unban him..
533 @item @code{bot:protection/no-kick} No kick. The user may still be kicked but the bot will kickban
534 the user who kicked the protected user.
535 @item @code{bot:protection/no-deop} No deop. The bot will ensure that the user always maintains
539 @node Automatic Op, Shit Levels, Protection, Levels
540 @subsubsection Automatic Op
542 A user may be automatically given operator status upon entering a
543 channel. Scheme uses the symbolic name, the user list
544 (@file{bot.users}) and IRC commands use the numeric value.
547 @item @code{bot:aop/no} Do not automatically op the user
548 @item @code{bot:aop/yes} Do automatically op the user
551 @node Shit Levels, , Automatic Op, Levels
552 @subsubsection Shit Levels
554 The shit list and shit list related commands use different levels to
555 define how much the bot hates a user. Scheme uses the symbolic names,
556 the shit list and IRC commands use the numbers.
559 @item @code{bot:shit/none} The bot doesn't hate the user (this is the
561 @item @code{bot:shit/no-op} The bot will deop the user any time he
562 gains operator priviliges in the channel
563 @item @code{bot:shit/no-join} The bot will kick and ban the user when he
565 @item @code{bot:shit/no-deban} The bot will kick and ban usre when he
566 joins the channel, and will prevent other users from debanning him.
569 @node Built-In Commands, , Concepts, Using the Bot
570 @section Built-In Commands
572 Bobot++ has many built-in commands that make it useful without
573 scripting support. The reference leaves off the command char; remember
574 to use whatever you defined the command char to be in
577 If a command needs the channel name then you must specify the channel
578 as the first argument to the command when private messaging the bot a
579 command. If, however, you are using the command in a channel you may
580 omit the channel argument, and the bot will use the current channel.
583 * Bot Control Commands::
587 * User List Commands::
588 * Server List Commands::
589 * Shit List Commands::
591 * Scripting Commands::
592 * Authentication Commands::
593 * Miscellaneous Commands::
596 @node Bot Control Commands, Message Commands, Built-In Commands, Built-In Commands
597 @subsection Bot Control Commands
599 These commands are used to control the behaviour of the bot.
601 @deffn Command cycle channel
602 Makes the bot leave and join @var{channel}.
606 Makes the bot stop immediately.
609 @deffn Command join channel
610 Makes the bot join @var{channel}.
613 @deffn Command nick newnick
614 Makes the bot use nickname @var{new-nick}.
617 @deffn Command setfloodrate messages-per-second
618 Sets the flood rate to @var{messages-per-second}. The bot will
619 consider users sending more than @var{messages-per-second} messges in
620 a second to be flooding and will ignore them.
623 @deffn Command setversion version-info
624 Sets the string returned when someone requestions the version info of
629 @node Message Commands, Channel Control, Bot Control Commands, Built-In Commands
630 @subsection Message Commands
632 These commands cause the bot to send messages (e.g. sending a message
633 to a channel or performing an action). For all commands @var{target}
634 may be either a user or a channel.
636 @deffn Command action target do
637 Makes the bot to perform the action @var{do} in a message sent to
641 @deffn Command do command
642 Sends a raw irc command. @var{command} is the IRC command you wish to
643 send (e.g. @samp{PRIVMSG #foo Hello!}).
646 @deffn Command msg target message
647 @deffnx Command say target message
648 Makes the bot say @var{message} to @var{target}.
651 @node Channel Control, Spylist Commands, Message Commands, Built-In Commands
652 @subsection Channel Control
654 @deffn Command ban channel mask
655 Bans @var{mask} from @var{channel}. You must be a trusted user to ban
656 using a host mask, but a normal user may ban individual nicks.
659 @deffn Command deban channel mask
660 Debans @var{mask} from @var{channel}. You must be a trusted user to
661 deban with a @var{mask}.
664 @deffn Command deop channel mask
665 Deops @var{mask} on @var{channel}.
668 @deffn Command invite nick channel
669 Invites @var{nick} to @var{channel}.
672 @deffn Command keep channel modes
673 Sets the @var{modes} that the bot will keep for @var{channel}.
676 @deffn Command kick channel mask reason
677 @deffnx Command kickban channel mask reason
678 Kicks @var{mask} out of @var{channel}, because of
679 @var{reason}. @command{kickban} also bans @var{mask}.You must be a
680 trusted user to use a mask.
683 @deffn Command lock channel
684 Locks topic on @var{channel}
687 @deffn Command mode channel modes
688 Sets mode of @var{channel} to the mode string @var{modes}.
691 @deffn Command op channel nick
692 Ops @var{nick} on @var{channel}
695 @deffn Command part channel
696 Makes the bot leave @var{channel}.
699 @deffn Command tban channel mask time
700 @deffnx Command tkban channel mask time
701 Bans @var{mask} from @var{channel} for @var{time}
702 seconds. @command{tkban} also kicks the user. You must be a trusted
706 @deffn Command topic channel [topic]
707 Sets the topic in @var{channel} to @var{topic}. If @var{topic} is not
708 supplied the current topic is sent as a notice to the user calling the
712 @deffn Command unlock channel
713 Unlocks the topic on @var{channel}
716 @node Spylist Commands, User List Commands, Channel Control, Built-In Commands
717 @subsection Spylist Commands
721 @item @command{spylist} Shows the bot's spylist.
723 @item @command{spymessage} Adds you to the spylist
725 @item @command{rspymessage} Removes you from the spy
731 @node User List Commands, Server List Commands, Spylist Commands, Built-In Commands
732 @subsection User List Commands
734 @deffn Command adduser mask
738 @command{deluser} Removes @var{nick} or
739 @var{mask} from the userlist.
745 @command{userlist} Shows the bot's userlist
747 @node Server List Commands, Shit List Commands, User List Commands, Built-In Commands
748 @subsection Server List Commands
752 @item @command{addserver} Adds the server specified by
753 @var{host name} or @var{ip address} to the server list.
755 @item @command{delserver} Deletes server from server
756 list whose number in the server list is @var{server number}.
758 @item @command{nextserver} Makes the bot connect to the
759 next server in its server list.
761 @item @command{reconnect} Makes the bot reconnect to
764 @item @command{server} Select the server to connect
765 to. @var{server number} is the number of the server in the serverlist.
767 @item @command{serverlist} Shows the bot's serverlist.
771 @node Shit List Commands, Channel Info, Server List Commands, Built-In Commands
772 @subsection Shit List Commands
776 @item @command{addshit}
778 @item @command{delshit} Removes @var{nick} or
779 @var{mask} from the shitlist
781 @item @command{shitlist} Shows the bot's shitlist.
785 @node Channel Info, Scripting Commands, Shit List Commands, Built-In Commands
786 @subsection Channel Info
790 @item @command{banlist}
792 @item @command{channels} Prints the channel(s) where
793 the bot is currently.
795 @item @command{names} Yes Shows the nicknames and
796 status of users on @var{channel}.
798 @item @command{stats} Yes Gives @var{channel}'s statistics.
801 @node Scripting Commands, Authentication Commands, Channel Info, Built-In Commands
802 @subsection Scripting Commands
806 @item @command{execute} @strong{Only available if scripting support is enabled}
808 @item @command{load} Reloads the userlist from disk.
810 @item @command{loadscript} @strong{Only available if scripting support is enabled}
814 @node Authentication Commands, Miscellaneous Commands, Scripting Commands, Built-In Commands
815 @subsection Authentication Commands
819 @item @command{ident} Identifies you on the bot. Note
820 that you should not use this command in public @dots{}
822 @item @command{password} Changes your password on the
823 bot. Use @code{NONE} as password if you want to clear it. Do not use this
828 @node Miscellaneous Commands, , Authentication Commands, Built-In Commands
829 @subsection Miscellaneous Commands
833 @item @command{alias} Makes an alias, and adds the
834 function @var{new name}, that will do exactly the same command as
837 @item @command{dcclist} Gives the list of all DCC Chat
842 @item @command{nslookup} Does a nameserver query about
843 @var{nick} host, @var{host} or @var{ip address}.
846 @item @command{who} Yes Show your level on @var{channel}
848 @item @command{whois} Yes Shows information about
849 @var{nick} on @var{channel}
853 @node Scripting, Concept Index, Using the Bot, Top
856 Bobot++'s most powerful feature is its scripting system. You write
857 scripts using Guile Scheme. This manual does not cover how to use
858 Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual,
859 guile, The Guile Reference Manual}, for the Guile reference manual and
860 @url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for
861 a good tutorial on Scheme.
863 Note that in previous versions the scripting commands where in the
864 form @code{bot-@var{function}}. They are now in the form
865 @code{bot:@var{function}}. The old names are still available, but are
866 deprecated and will be removed in Bobot++ 3.0. New commands are only
867 available with the @code{bot:} prefix. The command @command{perl -pi
868 -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to convert
869 your code to use the new functions.
871 @strong{NOTE}: All arguments to functions and hooks called by the bot
872 are strings unless otherwise specified.
875 * Adding New Commands::
878 * Misc Scripting Stuff::
883 @node Adding New Commands, Hooks, Scripting, Scripting
884 @section Adding New Commands
886 Adding a new command is simple. To register a new command use
887 @code{bot:addcommand}.
889 @defun bot:addcommand name func needs-channel? num-of-args min-level
891 The @var{name} is a string representing the name of the command being
892 added. @var{func} is a function accepting @var{num-of-args}
893 arguments. @var{needs-channel?} is a bool that is true if the function
894 needs the channel name as its first arg, and false otherwise.
895 @var{num-of-args} is the number of args @var{func} will take and must
896 be within zero (0) and twenty (20). @var{min-level} is one of the
897 @ref{User Levels}. A user must be at least a @var{min-level} user to
898 use the new command. None of the arguments are guaranteed to be
899 passed; if they aren't they are set to the empty string @code{""}. An
900 example of a new command would be:
903 (define (hello channel name)
904 (if (string=? name "")
905 (bot:say channel "Hello world!")
906 (bot:say channel (string-append "Hello " name "!")))
908 (bot:addcommand "hello" hello #t 2 0)
911 This will display ``Hello World!'' if called as @kbd{!hello} and
912 ``Hello World @var{USER}'' if called as @kbd{!hello @var{USER}}.
915 @node Hooks, Sending Messages, Adding New Commands, Scripting
918 @cindex Background on Hooks
919 Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
920 and tiny fugue (a MUD bot) hooks with a little bit of extra stuff
921 added in. A hook is called when a regular expression is matched
922 against a message sent to or by the bot.
924 Bobot++ uses different hook types for each IRC message type, and also
925 includes a hook for accessing raw irc messages. Hooks are tagged with
926 a priority and a flag that specifies whether to call the next hook
927 that matches after calling the current one or to stop
930 Hooks are processed from the highest to lowest priority, with
931 fallthrough hooks of equal priority to non-fallthrough hooks being
939 @node Creating a Hook, Hook Types, Hooks, Hooks
940 @subsection Creating a Hook
942 To add a new hook you use the function @code{bot:addhook}.
944 @defun bot:addhook type regex function [pri fall name]
945 @var{type} specifies the type of hook (the types of hooks are listed
946 in @ref{Hook Types}).
948 @var{regex} is a standard regular expression. If
949 @var{regex} is matched, @var{function} will be called.
951 @var{function} will take a different number of args depending on the
954 @var{pri} specifies the priority of the hook---higher priority hooks
955 are executed first. This argument is optional and defaults to
958 @var{fall} is @code{#t} if the hook is a fallthrough hook and
959 @code{#f} is the hook is not a fallthrough hook. This arg is also
960 optional and defaults to @code{#t}.
962 @var{name} is the optional name of the hook that defaults to
963 @code{"DEFAULT"}. If you set the name then you can have more than
964 one hook that matches the same regexp, as long as they have the same
965 name. E.g. in a log script you could have the regexps for the log
966 function all be @code{".*"} and set their names to @code{"log"} to
967 avoid a conflict with other hooks.
970 @node Hook Types, , Creating a Hook, Hooks
971 @subsection Hook Types
973 The following sections document the different hooks Bobot++ exposes.
975 The general format of each hook description is as if it were a
976 function to be defined, but these describe the function to be passed
977 to @code{bot:add-hook}. Do @emph{not} name your functions these
980 That said, here is the list of available hooks functions.
984 * Received Message Hooks::
985 * Sent Message Hooks::
987 * Miscellaneous Hooks::
990 @node Received Message Hooks, Sent Message Hooks, Hook Types, Hook Types
991 @subsubsection Receieved Message Hooks
993 The following hooks are triggered when a mesage is received by the bot.
995 @defun hooks/action from to action
996 This hook is triggered when someone performs an action.
998 @var{from} is the nickname the person that performed the
1001 @var{to} is the target of the action, which is either a channel or the
1002 Bot's nick if the user private messages the bot.
1004 @var{action} is the text of the action. E.g. if someone did @samp{*
1005 foobar does baz}, then @var{action} would be the string @code{"does
1009 @defun hooks/nickname old-nick new-nick
1010 This hook is called when someone changes his nickname from
1011 @var{old-nick} to @var{new-nick}.
1014 @defun hooks/signoff nick message
1015 This hook is called when someone signs off of IRC.
1017 @var{nick} is the nickname of the person signing off.
1019 @var{message} is his quit message
1022 @defun hooks/ctcp nick to command rest
1023 This hook is called when a CTCP request is received by the bot.
1025 @var{nick} is the nickname of the sender.
1027 @var{to} is the target of the CTCP request. This will either be a
1028 channel the bot is in, or the nickname of the bot.
1030 @var{command} is the CTCP command issued.
1032 @var{rest} contains the arguments to the CTCP command.
1035 @defun hooks/ctcp-reply nick command rest
1036 This hook is called when a CTCP REPLY is received. This occurs when
1037 the bot has sent a CTCP request to another client. The CTCP REPLY is
1038 always addressed to the bot directly.
1040 @var{nick} is the nickname of the person who replied.
1042 @var{command} is the command to which @var{nick} is replying.
1044 @var{rest} contains the body of the reply.
1047 @defun hooks/disconnect server intentional
1048 This is called when the bot is disconnected from a server.
1050 @var{server} is the hostname of the server from which the bot was
1053 @var{intentional} is a flag set to @code{#t} when the bot disonnected
1054 from the server as the result of a command (issued by a user from IRC,
1055 SIGHUP, or from a script), or @code{#f} when the bot disconnected from
1056 the server unintentionally..
1059 @defun hooks/invite nick channel
1060 This hook is called when a user invited the bot to join a channel.
1062 @var{nick} is the nickname of the user who sent the invite.
1064 @var{channel} is the channel to which the bot was invited.
1067 @defun hooks/join nick channel
1068 This is called when a user or the bot joins a channel.
1070 @var{nick} is the nickname of the user who joined @var{channel}. This
1071 may be the bot's nickname (the IRC server sends the JOIN command back
1072 to the the bot after it joins a channel).
1074 @var{channel} is the channel that was joined
1077 @defun hooks/kick target from channel reason
1078 This hook is called when a user, including the bot, is kicked out of a
1081 @var{target} is the nick of the user who was kicked. This may be the
1084 @var{from} is the nick of the user who issued the kick. This may also
1087 @var{channel} is the channel the kick was issued in.
1089 @var{reason} is the reason the user was kicked.
1092 @defun hooks/part nick channel
1093 This hook is called when a user parts a channel.
1095 @var{nick} is the user who parted the channel. This may be the bot.
1097 @var{channel} is the channel from which the user parted.
1100 @defun hooks/mode nick target modes
1101 This hook is called when someone sets the modes of @var{target}.
1103 @var{nick} is the user who set the modes. This may be the bot.
1105 @var{target} is the target of the MODE command. This may be a
1106 channel or a user. If it is a user, it may be the bot.
1108 @var{modes} is the MODE string.
1111 @defun hooks/message nick message
1112 This hook is called when someone sends a private message to the bot.
1114 @var{nick} is the nickname of the user who sent the message.
1116 @var{message} is the message the user sent.
1119 @defun hooks/notice nick message
1120 This hook is called when a user send a private notice to the bot.
1122 @var{nick} is the user who sent the notice.
1124 @var{message} is the message the user sent.
1127 @defun hooks/public nick channel message
1128 This hook is called when a user sends a normal message to a channel.
1130 @var{nick} is the user who sent the message.
1132 @var{channel} is the channel to which the message was sent.
1134 @var{message} is the message that was sent.
1137 @defun hooks/public-notice nick channel message
1138 This hook is called when a user send a notice to a channel.
1140 @var{nick} is the user who sent the notice.
1142 @var{channel} is the channel to which the notice was sent.
1144 @var{message} is the message that was sent.
1147 @defun hooks/raw raw-message
1148 This hook is called every time a message is received. This matches on
1149 the raw message text and passes the hook function the raw IRC message.
1151 @var{raw-message} is the raw IRC message.
1154 @defun hooks/topic nick channel new-topic
1155 This hook is called when a user changes the topic in a channel.
1157 @var{nick} is the user who set the topic. This may be the bot.
1159 @var{channel} is the channel that's topic was changed.
1161 @var{new-topic} is the new topic.
1164 @node Sent Message Hooks, DCC CHAT Hooks, Received Message Hooks, Hook Types
1165 @subsubsection Sent Message Hooks
1167 These hooks are called when the bot sends a message. @var{mynick} is
1168 always the bot's nick and will not be documented in each hook
1171 @defun hooks/send/public mynick channel message
1172 This hook is called when the bot sends a normal message to a channel.
1174 @var{channel} is the channel to which the bot sent the message.
1176 @var{message} is the message the bot sent.
1179 @defun hooks/send/message mynick to message
1180 This hook is called when the bot sends a private message to a user.
1182 @var{to} is the nick of the user to whom the message was sent.
1184 @var{message} is the message that was sent.
1187 @defun hooks/send/action mynick to message
1188 This hook is called when the bot sents an action to a channel or a
1191 @var{to} is the channel or nick of the user to which the action was
1194 @var{message} is the text of the action.
1197 @defun hooks/send/ctcp mynick to command message
1198 This hook is called when the bot sends a CTCP message @emph{other
1199 than} an ACTION to a channel or user.
1201 @var{to} is the channel or nick of the user to which the CTCP was
1204 @var{command} is the CTCP command that was sent.
1206 @var{message} is a string containing the arguments to the CTCP command.
1209 @defun hooks/send/who who
1210 This is called when the bot sends a WHO message. The regex is matched
1211 on @var{who}, which is also passed as the only argument to your
1214 @var{who} is the channel or nick that was WHOed.
1217 @defun hooks/send/whois nick
1218 This is called when the bot sends a WHOIS message. The regex is
1219 matched on @var{nick}, which is also passed as the only argument to
1222 @var{nick} is the nickname of the person who was WHOISed.
1225 @node DCC CHAT Hooks, Miscellaneous Hooks, Sent Message Hooks, Hook Types
1226 @subsubsection DCC CHAT Hooks
1228 These hooks are called when a user initializes a DCC CHAT and when the
1229 bot receives messages from the user in a DCC CHAT.
1231 @defun hooks/dcc/chat-begin from
1232 This hook is called when a user begins a DCC CHAT with the bot.
1233 @var{from} is the user's address in the form @samp{nick!user@@host}.
1236 @defun hooks/dcc/chat-end address
1237 This hook is called when a DCC CHAT is purged after being idle for a
1238 while, or when the user closes the DCC CHAT. As such, you cannot write
1239 any more data to the DCC CHAT.
1241 @var{address} is the address (nick!user@@host) of the person on the
1242 other side of the DCC.
1245 @defun hooks/dcc/chat-message from message
1246 This hook is called when a user sends a message to the bot through
1249 @var{from} is the user's address in the form @samp{nick!user@@host}.
1251 @var{message} is the message the user sent to the bot.
1254 @node Miscellaneous Hooks, , DCC CHAT Hooks, Hook Types
1255 @subsubsection Miscellaneous Hooks
1257 @defun hooks/flood nick
1258 This hook is called when a user is detected flooding the bot.
1260 @var{nick} is the nickname of the user flooding the bot.
1263 @defun hooks/timer time
1264 This hook is called once a minute. The regex is @strong{not} used.
1266 @var{time} is the in zero-padded @code{hh:mm} format.
1270 @node Sending Messages, Misc Scripting Stuff, Hooks, Scripting
1271 @section Sending Messages
1273 There are several types of messages you can send with Bobot++ from
1274 scripts. They are split into High and Low level message sending
1275 functions. Most bots will only use the high level functions, but the
1276 low level ones are provided for when a bot needs to do things like
1277 send raw IRC messages or CTCP commands.
1280 * High Level Message Functions::
1281 * Low Level Message Functions::
1284 @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages
1285 @subsection ``High Level'' Message Functions
1287 @defun bot:action channel message
1288 Send an ``action'' type @var{message} to @var{channel}
1292 @defun bot:msg target message
1293 @defunx bot:say target message
1294 Send a public or private message to @var{target}.
1296 @var{target} may be a channel or a nickname.
1298 In versions of Bobot++ prior to 2.1.8 @code{bot:say} could only send
1299 to channels, and @code{bot:msg} could only send private messages to
1300 users. They are aliases of the same command now, but it may be worth
1301 using them as they used to for clarity.
1304 @defun bot:notice target message
1305 Sends @var{message} as a NOTICE to @var{target}. @var{target} may be a
1306 user (nick) or a channel.
1309 @node Low Level Message Functions, , High Level Message Functions, Sending Messages
1310 @subsection ``Low Level'' Message Functions
1312 @c Add a url for rfc2812
1313 The ``Low Level'' messaging functions allow you to do things like send
1314 CTCP messages. You probably want to read rfc 2812 and the CTCP spec
1315 before using these. If you have no idea what these do, read rfc 2812
1316 (IRC Client Protocol) and CTCP spec. These functions all return
1317 @code{*unspecified*} always, so don't use the return value for
1320 @defun bot:ctcp to command message
1321 @var{to} is the target of your CTCP message, @var{command} is the
1322 CTCP command, and @var{message} is the message (or arguments) of the
1323 command. Make sure to @code{bot:ctcp-quote} the message!
1326 @defun bot:ctcp-reply to command message
1327 @var{to} is the target of your CTCP reply, @var{command} is the
1328 CTCP command, and @var{message} is the message (or arguments) of the
1329 command. Make sure to @code{bot:ctcp-quote} the message!
1331 This is used to reply to a ctcp that the bot has received.
1334 @node Misc Scripting Stuff, Scheme Commands, Sending Messages, Scripting
1335 @section Misc. Scripting Stuff
1337 These are a few useful things that I thought people writing scripts
1341 If you want to execute code when the bot exits, just do
1342 @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an
1343 argumentless procedure (a thunk). When the bot exits your thunk will
1352 @node Scheme Commands, Query Functions, Misc Scripting Stuff, Scripting
1353 @section Scheme Commands
1355 These scheme functions are the same as the commands.
1356 They allow you to execute bot commands from scheme scripts.
1358 @defun bot:adduser nick-or-mask cbannel-mask level prot auto-op
1359 Adds an user to the userlist, for a @code{nick!user@@host} matching the
1360 one given, on a channel matching the @var{channelMask} given.
1362 @multitable @columnfractions 0.33 0.33 0.33
1363 @item The @var{level} can be: @tab The @var{prot} can be: @tab The @var{auto-op} can be:
1364 @item 0 - No level @tab 0 - No protection @tab 0 - No auto-op
1365 @item 1 - User @tab 1 - No ban @tab 1 - Op on join
1366 @item 2 - Trusted User @tab 2 - No kick @tab
1367 @item 3 - Friend @tab 3 - No deop @tab
1368 @item 4 - Master @tab @tab
1374 @defun bot:addserver hostname ip-address [portnumber]
1375 Adds the server specified by @var{hostname} or @var{ip-address} to
1380 @defun bot:addshit nick-or-mask channel-mask level [time reason]
1381 Adds an user to the shitlist, for a nick!user@@host matching the
1382 one given, on a channel matching the @var{channelMask} given.
1385 The @var{level} can be:
1388 2 - Kick and Ban on join
1389 3 - Kick and Ban on join, no deban
1395 @defun bot:ban channel mask-or-nick
1396 Bans @var{mask} or @var{nick} from @var{channel}. You must be a trusted
1397 user to ban with a @var{mask}.
1401 @defun bot:change-command-level nick-or-mask channel-mask new-level
1402 Gives @var{nick} or @var{mask} level @var{new-level} on channel(s)
1403 @var{channel-mask}. Note that you can not change level for someone
1404 whose level is greater than yours, and that you can not give a
1405 level greater than yours.
1409 @defun bot:cycle channel
1410 Makes the bot leave and join @var{channel}.
1414 @defun bot:deban channel mask-or-nick
1415 Debans @var{mask} or @var{nick} from @var{channel}. You must be a trusted
1416 user to deban with a @var{mask}.
1420 @defun bot:delserver server-number
1421 Deletes server from server list whose number in the server list
1422 is @var{server-number}
1426 @defun bot:deluser nick-or-mask channel-mask
1427 Removes @var{nick} or @var{mask} from the userlist.
1431 @defun bot:delshit nick-or-mask channel-mask
1432 Removes @var{nick} or @var{mask} from the shitlist.
1436 @defun bot:deop channel mask-or-nick
1437 Deops @var{mask} or @var{nick} on @var{channel}.
1441 @defun bot:die reason
1442 Makes the bot stop immediately.
1450 @defun bot:invite channel nick
1451 Invites @var{nick} on @var{channel}.
1455 @defun bot:join channel
1456 Makes the bot join @var{channel}.
1460 @defun bot:keep channel modes
1461 Sets the @var{modes} that the bot will keep for @var{channel}.
1466 @defun bot:kick channel mask-or-nick [reason]
1467 Kicks @var{mask} or @var{nick} out of @var{channel}, because of @var{reason}.
1468 You must be a trusted user to use a @var{mask}.
1472 @defun bot:kickban channel mask-or-nick [reason]
1473 Bans then kicks @var{mask} or @var{nick} out of @var{channel},
1474 because of @var{reason}.
1475 You must be a trusted user to use a @var{mask}.
1479 @defun bot:lock channel
1480 Locks topic on @var{channel}.
1484 @defun bot:mode channel mode-string
1485 Sends @var{mode-string} as mode for @var{channel}.
1489 @defun bot:nextserver
1490 Makes the bot connect to the next server in its server list.
1494 @defun bot:nick nick
1495 Makes the bot use nickname @var{nick}.
1499 @defun bot:op channel nick
1500 Ops @var{nick} on @var{channel}.
1504 @defun bot:part channel
1505 Makes the bot leave @var{channel}.
1509 @defun bot:reconnect
1510 Makes the bot reconnect to its current server.
1514 @defun bot:server server-number
1515 Select the server to connect to. @var{server-number} is the number of
1516 the server in the serverlist.
1520 @defun bot:setfloodrate ?
1524 @defun bot:setversion ?
1528 @defun bot:tban channel nick-or-mask time
1529 Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds.
1533 @defun bot:tkban channel nick-or-mask time [reason]
1534 Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds,
1535 then kicks him/them because of @var{reason}.
1539 @defun bot:topic channel topic
1540 If no @var{topic} is given, prints @var{channel}'s topic. Otherwise,
1541 the bot will change @var{channel}'s topic to @var{topic}.
1544 @defun bot:unlock channel
1545 Makes the bot unlock topic on @var{channel}.
1548 @defun bot:who target
1549 Sends a WHO command to @var{target}. @var{target} may be either a
1553 @defun bot:whois nick
1554 Sends a WHOIS command to @var{nick}. @var{nick} @strong{must} be a
1555 nickname, you cannot send a WHOIS to a channel.
1561 @defun bot:delcommand
1562 [ Probably deletes a command added with @code{bot:addcommand} ? ]
1567 @node Query Functions, , Scheme Commands, Scripting
1568 @section Query Functions
1571 [ I didn't know where to put any of these, so I just stuck them in
1574 There probably needs to be several sections added, like dealing with
1575 users (kicking, added, etc), dealing with the bot (channels, nickname
1576 of the bot, etc), server issues (serverlist), useful tools (nslookup,
1577 whois), and do on. ]
1580 These functions allow scripts to get various bits of information.
1584 [ Probably returns the log port? ]
1588 @defun bot:getnickname
1589 [ Gets the bot's nickname? ]
1593 @defun bot:getserver
1597 @defun bot:getserverlist
1602 [ Flushes the socket to the server? ]
1606 @defun bot:flushport
1607 [ Flushes the log port? ]
1612 [ Returns a random number? What range? Why? ]
1616 @defun bot:addtimer ? ?
1620 @defun bot:deltimer ?
1624 @defun bot:dcc-chat-send ? ?
1628 [ And what about the stuff defined in @file{bobot-utils.scm} ? I just
1629 added it here so it could be somewhere. There should also be a
1630 section dealing with modules. How to use them. What module scripts
1631 are in. What module bobot++ provided primites are in. And so on. ]
1634 @defun bot:log . messages
1635 Write as many @var{messages} as you want to the log. If the arg is a
1636 thunk it will be executed and it's output will be written to the log.
1639 @defun bot:load file
1642 @defun bot:load-module module-spec
1645 @defun bot:use-module module-spec
1648 @defun bot:match-not-channel regex
1649 @code{bot:match-not-channel} adds a prefix regex to your @var{regex} so it
1650 doesn't match the sender or channel in a PUBLIC message
1653 @defun bot:match-to-me regex
1654 @code{bot:match-to-me} matches text that was addressed to the bot with a
1655 ':', ',', or nothing after the bot name.
1658 @defun bot:sent-to-me? message
1661 @defun bot:ctcp-quote message
1662 Returns the CTCP quoted message
1663 Input @emph{MUST NOT} contain the trailing @code{\r\n}
1664 (it is added by the message sending code).
1668 @defvar %bot:loadpath
1671 @defun %bot:load-extensions
1676 @node Concept Index, Function Index, Scripting, Top
1677 @unnumbered Concept Index
1680 @node Function Index, Variable Index, Concept Index, Top
1681 @unnumbered Function Index
1684 @node Variable Index, , Function Index, Top
1685 @unnumbered Variable Index