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 (original author, no longer works on program).
12 Copyright 2002 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 @c @vskip O plus 1filll
28 Copyright @copyright{} 2002 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 (original author, no longer works on program).
45 This document applies to version 2.1.0 of the program named
48 Copyright 2002 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 @node Introduction, Configuration, Top, Top
70 This manual feels abused and neglected because it has almost no
73 @node Configuration, Using the Bot, Introduction, Top
74 @chapter Configuration
76 Bobot++ is easy to configure. The configuration file format may be
77 changing in the 2.1 series, so it is not documented for now. See the
78 @file{examples} directory for an example configuration.
81 * Configuration File Syntax::
82 * Configure File Placement::
85 @node Configuration File Syntax, Configure File Placement, Configuration, Configuration
86 @section Configuration File Syntax
90 @node Configure File Placement, , Configuration File Syntax, Configuration
91 @section Configuration File Placement
93 Bobot++ will look in @file{/etc/bobotpp/default/} for its default
94 config if none is specified on the command line. Put the configuration
95 files you want to be loaded by default in this directory. If you are
96 not root or you want to have your own personal configration, put it in
97 @file{~/.bobotpp/config/default/}.
99 @node Using the Bot, Scripting, Configuration, Top
100 @chapter Using Bobot++
108 @node User Levels, , Using the Bot, Using the Bot
111 There are five levels that a user may be when interfacing with a bot:
112 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
113 @var{master}. All users default to @var{none} unless they are changed
114 by a script, the @code{!adduser} command or the @file{bot.users}
115 file. @var{none} is for everyone---very few commands (e.g. help) are
116 available to the users and almost everyone should be this
117 level. A @var{user} can execute many of the bot commands, but can't
118 use masks on kicks and bans. A @var{trusted} user can everything a
119 @var{user} can do, but can also use masks on kicks and bans. A
120 @var{friend} can do everything except for stopping the bot (be
121 careful who you give this to!). The @var{master} level is for the
122 bot's owner (probably you) and can do @emph{everything} to the bot. Be
123 @emph{very} careful if you give @var{master} level access to anyone
124 else. You cannot use this symbolic levels with the @code{!adduser}
125 command. See (FIXME: ref) for the numbers you must use with
128 @node Scripting, Concept Index, Using the Bot, Top
131 Bobot++'s most powerful feature is its scripting system. You write
132 scripts using Guile Scheme. This manual does not cover how to use
133 Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual,
134 guile, The Guile Reference Manual}, for the Guile reference manual and
135 @url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for
136 a good tutorial on Scheme.
138 Note that in previous versions the scripting commands where in the
139 form @code{bot-@var{function}}. They are now in the form
140 @code{bot:@var{function}}. The old names are still available, but are
141 deprecated and will be removed in Bobot++ 2.4. The command
142 @command{perl -pi -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to
143 convert your code to use the new functions.
146 * Adding New Commands::
148 * Scheme User Levels::
150 * Misc Scripting Stuff::
153 @node Adding New Commands, Hooks, Scripting, Scripting
154 @section Adding New Commands
157 Adding a new command is simple. To register a new command use
158 @code{bot:addcommand}. The prototype for @code{bot:addcommand} is
159 @code{(bot:addcommand name func needs-channel? num-of-args
160 min-level)}. The @code{name} is a string representing the name of the
161 command being added. @code{func} is a function accepting
162 @code{num-of-args} arguments. @code{needs-channel?} is a bool that is
163 true if the function needs the channel name as its first arg, and
164 false otherwise. @code{num-of-args} is the number of args @code{func}
165 will take and must be within zero (0) and twenty
166 (20). @code{min-level} is one of the @ref{Scheme User Levels}. A user must be
167 at least a @code{min-level} user to use the new command. None of the
168 arguments are guaranteed to be passed; if they aren't they are set to
169 the empty string @code{""}. An example of a new command would be:
172 (define (hello channel name)
173 (if (string=? name "")
174 (bot:say channel "Hello world!")
175 (bot:say channel (string-append "Hello " name "!")))
177 (bot:addcommand "hello" hello #t 2 0)
180 This will display ``Hello World!'' if called as @kbd{!hello} and
181 ``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}.
183 @node Hooks, Scheme User Levels, Adding New Commands, Scripting
186 @cindex Background on Hooks
187 Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
188 and tiny fugue (a MUD bot) hooks with a little bit of extra stuff
189 added in. The basic idea of a hook if that you match a text against
190 regular expression and call a function if text in a message matches
191 that regex. The different types of hooks provided by Bobot++
192 correspond to the different classes of messages that Bobot++ can
193 recieve. A Hook also has several properties, including its priority
194 and whether or not it is a fallthrough hook. Higher priority hooks are
195 executed before lower priority hooks and fallthrough hooks are
196 executed before non-fallthrough hooks of the same priority. A
197 fallthrough hook can match and processing of hooks will continue; as
198 soon as the first non-fallthrough hooks matches processing of hooks
206 @node Creating a Hook, Hook Types, Hooks, Hooks
207 @subsection Creating a Hook
210 To add a new hook you use the function
211 @code{bot:addhook}. @code{bot:addhook} is prototyped as
212 @code{(bot:addhook type regex function pri fall name)}. @code{type}
213 specifies the type of hook (the types of hooks are listed in @ref{Hook
214 Types}). @code{regex} is a standard regular expression. If
215 @code{regex} is matched, @code{function} will be
216 called. @code{function} will take a different number of args depending
217 on the hook type. @code{pri} specifies the priority of the
218 hook---higher priority hooks are executed first. This argument is
219 optional and defaults to @code{0}. @code{fall} is @code{#t} if the
220 hook is a fallthrough hook and @code{#f} is the hook is not a
221 fallthrough hook. This arg is also optional and default to
222 @code{#t}. @code{name} is the optional name of the hook that defaults
223 to ``DEFAULT''. If you set the name then you can have more than one
224 hook that matches the same regexp, as long as they have the same
225 name. E.g. in a log script you could have the regexps for the log
226 function all be @code{".*"} and set their names to @code{"log"} to
227 avoid a conflict with other hooks.
229 @node Hook Types, , Creating a Hook, Hooks
230 @subsection Hook Types
232 Here is a list of the various hooks are notes on each one. The general
237 @code{hooks/name} (this is the Scheme variable name of the hook)
240 Description of the hook
242 @var{arg1} @var{arg2} ... @var{argn}
256 That said, here is the list of available hooks:
266 This hook is triggered when someone performs an action.
268 @var{from}, @var{to}, @var{action}
271 @var{from}: this is the address of the person that performed the
272 action in the form @samp{@var{nick} ! @var{user} @@ @var{host}}
273 (without the spaces).
275 @var{to}: This is the target of the action, which is either a channel
278 @var{action}: This is the text of the action. E.g. if someone did
279 @samp{* foobar does baz}, then @var{action} would be the string
285 @vindex hooks/nickname
286 @code{hooks/nickname}
289 Description of the hook
299 @vindex hooks/signoff
303 Description of the hook
317 Description of the hook
327 @vindex hooks/ctcp-reply
328 @code{hooks/ctcp-reply}
331 Description of the hook
341 @vindex hooks/disconnect
342 @code{hooks/disconnect}
345 Description of the hook
359 Description of the hook
373 Description of the hook
387 Description of the hook
401 Description of the hook
415 Description of the hook
429 Description of the hook
439 @vindex hooks/message
443 Description of the hook
457 Description of the hook
471 Description of the hook
481 @vindex hooks/public-notice
482 @code{hooks/public-notice}
485 Description of the hook
499 Description of the hook
513 Description of the hook
527 Description of the hook
537 @vindex hooks/dcc/begin
538 @code{hooks/dcc/begin}
541 This hook is triggered when a user begins a DCC CHAT with the bot.
546 @var{FROM}: This is the user's address in the form
547 @samp{nick!user@@host}.
552 @vindex hooks/dcc/message
553 @code{hooks/dcc/message}
556 This hook is triggered when a user sends a message to the bot through
559 @var{FROM} @var{MESSAGE}
562 @var{FROM}: This is the user's address in the form
563 @samp{nick!user@@host}.
565 @var{MESSAGE}: This is the message the user sent to the bot.
571 @node Scheme User Levels, Sending Messages, Hooks, Scripting
572 @section Scheme User Levels
579 There are five levels that a user may be when interfacing with a bot:
580 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
581 @var{master}. The Scheme variables for the user levels are
582 @code{bot:user-none}, @code{bot:user-user}, @code{bot:user-trusted},
583 @code{bot:user-friend}, and @code{bot:user-master}. See @ref{User
584 Levels} for more information on User Levels.
586 When adding a new command, think about who should be able to use
587 it. Is your command a general purpose command that helps the channel
588 (e.g. @code{!seen}) that everyone should be able to use? Or is it
589 something that should be restricted? See @ref{User Levels} for
590 information on what level users can do what with the built in bot
591 commands and think about what level a user your command is targetted
592 towards. You must be @emph{very} careful when giving new commands to
593 lower level users because you can do basically everything the bot can
594 do with a script. As the scripting interface becomes more powerful,
595 you must think more about what users can use new commands you add.
597 @node Sending Messages, Misc Scripting Stuff, Scheme User Levels, Scripting
598 @section Sending Messages
600 There are several types of messages you can send with Bobot++ from
601 scripts. There is the simple, but rather limited, @code{bot:say},
602 @code{bot:action} and @code{bot:msg}, and
603 the more powerful, but lower level, @code{bot:send-MESSAGE}
604 functions. Most bots will probably only need the higher level
605 functions, but for the sake of why-not Bobot++ lets you use the lower
609 * High Level Message Functions::
610 * Low Level Message Functions::
613 @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages
614 @subsection ``High Level'' Message Functions
618 @node Low Level Message Functions, , High Level Message Functions, Sending Messages
619 @subsection ``Low Level'' Message Functions
621 The ``Low Level'' messaging functions allow you to do things like send
622 CTCP messages. You probably want to read rfc 2812 and the CTCP spec
623 before using these. If you have no idea what these do, read rfc 2812
624 (IRC Client Protocol) and CTCP spec. These functions all return
625 @code{*unspecified*} always, so don't use the return value for anything.
629 @item @code{bot:send-CTCP to command message}
630 @code{to} is the target of your CTCP message, @code{command} is the
631 CTCP command, and @code{message} is the message (or arguments) of the
632 command. Make sure to @code{bot:ctcp-quote} the message!
636 @node Misc Scripting Stuff, , Sending Messages, Scripting
637 @section Misc. Scripting Stuff
639 These are a few useful things that I thought people writing scripts
643 If you want to execute code when the bot exits, just do
644 @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an
645 argumentless procedure (a thunk). When the bot exits your thunk will
648 @c Since a bot calls hooks on things it says, you have to be careful
649 @c about hooks that output text that might match itself. E.g. if you have
650 @c a hook that matches @code{"foo"} and the hook displays @code{"foo to
651 @c the whatsit?"}, then the hook will call itself over and over until the
652 @c stack overflows! To protect against this I wrote the macro
653 @c @code{not-from-me}. You call it like this: @code{(not-from-me from
654 @c (stmts if not from bot) (stmts if from bot))}. E.g.
657 @c (bot:addhook hooks/public "foo"
659 @c (not-from-me f ((bot:say t "foo to the what!")))))
662 @c This say ``foo to the what!'' to the channel that ``foo'' was said in
663 @c and do nothing otherwise. You can optionally specify an action to be
664 @c executed if the message is from the bot:
667 @c (bot:addhook hooks/public "foo"
669 @c (not-from-me f ((bot:say t "foo to the what!"))
670 @c ((bot:say t "moof")))))
673 @c That will do the same thing as the first example, but the bot will
674 @c say ``moof'' if it said ``foo'' before. That probably isn't a very
675 @c nice thing to do, but it works as an example. You can have as many
676 @c staments as you want in the clauses.
678 @node Concept Index, Function Index, Scripting, Top
679 @unnumbered Concept Index
682 @node Function Index, Variable Index, Concept Index, Top
683 @unnumbered Function Index
686 @node Variable Index, , Function Index, Top
687 @unnumbered Variable Index