96c130c699a6f0581ff2c1111a41c3d89bbde3f8
[clinton/bobotpp.git] / bobot++.texinfo
1 \input texinfo @c -*- texinfo -*-
2 @c %**start of header
3 @setfilename bobot++.info
4 @settitle Bobot++: A Schemeable IRC Bot
5 @setchapternewpage on
6 @c %**end of header
7
8 @ifinfo
9 This file documents Bobot++ by Clinton Ebadi and Etienne Bernard
10 (original author, no longer works on program).
11
12 Copyright 2002 Clinton Ebadi
13
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
18 Texts.
19
20 @end ifinfo
21
22 @titlepage
23 @title Bobot++: A Schemeable IRC Bot
24 @author Clinton Ebadi
25
26 @page
27 @vskip O plus 1filll
28 Copyright @copyright{} 2002 Clinton Ebadi
29
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
34 Texts.
35
36 @end titlepage
37
38 @node Top, Introduction, (dir), (dir)
39 @comment node-name, next, previous, up
40
41 @ifinfo
42 This document describes Bobot++ by Clinton Ebadi and Etienne Bernard
43 (original author, no longer works on program).
44
45 This document applies to version 2.1.0 of the program named
46 Bobot++
47
48 Copyright 2002 Clinton Ebadi
49
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
54 Texts.
55 @end ifinfo
56
57 @menu
58 * Introduction::
59 * Configuration::
60 * Using the Bot::
61 * Scripting::
62 * Concept Index::
63 * Function Index::
64 * Variable Index::
65 @end menu
66
67 @node Introduction, Configuration, Top, Top
68 @chapter Introduction
69
70 This manual feels abused and neglected because it has almost no
71 content.
72
73 @node Configuration, Using the Bot, Introduction, Top
74 @chapter Configuration
75
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.
79
80 @menu
81 * Configuration File Syntax::
82 * Configure File Placement::
83 @end menu
84
85 @node Configuration File Syntax, Configure File Placement, Configuration, Configuration
86 @section Configuration File Syntax
87
88 @menu
89 * bot.conf::
90 @end menu
91
92 @node bot.conf, , Configuration File Syntax, Configuration File Syntax
93 @subsection bot.conf
94
95 bot.conf is the main configuration file for a Bobot++. The available
96 configuration variables are listed below in the format ``@var{variable}
97 <default-value>: description''
98
99 @itemize @bullet
100
101 @item @var{nickname} <Bobot>: The nickname of the bot (@var{nick} is an
102 alias for @var{nickname})
103 @item @var{username} <bobot>: The IRC username of the bot
104 @item @var{cmdchar} <!>: The character that prefixes commands given to
105 the bot (@var{command} is an alias for @var{cmdchar})
106 @item @var{ircname} <I'm a bobot++!>: The IRC name (or 'real name') of
107 the bot (@var{realname} is an alias for @var{ircname})
108 @item @var{userlist} <bot.users>: Name of the file where the userlist is
109 stored
110 @item @var{shitlist} <bot.shit>: Name of the file where the shitlist is
111 stored
112 @item @var{logfile} <$LOGDIR/bot.log>:
113
114 @end itemize
115
116 @node Configure File Placement, , Configuration File Syntax, Configuration
117 @section Configuration File Placement
118
119 Bobot++ will look in @file{/etc/bobotpp/default/} for its default
120 config if none is specified on the command line. Put the configuration
121 files you want to be loaded by default in this directory. If you are
122 not root or you want to have your own personal configration, put it in
123 @file{~/.bobotpp/config/default/}.
124
125 @node Using the Bot, Scripting, Configuration, Top
126 @chapter Using Bobot++
127
128 FIXME: stuff here...
129
130 @menu
131 * User Levels::
132 @end menu
133
134 @node User Levels, , Using the Bot, Using the Bot
135 @section User Levels
136
137 There are five levels that a user may be when interfacing with a bot:
138 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
139 @var{master}. All users default to @var{none} unless they are changed
140 by a script, the @code{!adduser} command or the @file{bot.users}
141 file. @var{none} is for everyone---very few commands (e.g. help) are
142 available to the users and almost everyone should be this
143 level. A @var{user} can execute many of the bot commands, but can't
144 use masks on kicks and bans. A @var{trusted} user can everything a
145 @var{user} can do, but can also use masks on kicks and bans. A
146 @var{friend} can do everything except for stopping the bot (be
147 careful who you give this to!). The @var{master} level is for the
148 bot's owner (probably you) and can do @emph{everything} to the bot. Be
149 @emph{very} careful if you give @var{master} level access to anyone
150 else. You cannot use this symbolic levels with the @code{!adduser}
151 command. See (FIXME: ref) for the numbers you must use with
152 @code{!adduser}.
153
154 @node Scripting, Concept Index, Using the Bot, Top
155 @chapter Scripting
156
157 Bobot++'s most powerful feature is its scripting system. You write
158 scripts using Guile Scheme. This manual does not cover how to use
159 Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual,
160 guile, The Guile Reference Manual}, for the Guile reference manual and
161 @url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for
162 a good tutorial on Scheme.
163
164 Note that in previous versions the scripting commands where in the
165 form @code{bot-@var{function}}. They are now in the form
166 @code{bot:@var{function}}. The old names are still available, but are
167 deprecated and will be removed in Bobot++ 2.4. The command
168 @command{perl -pi -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to
169 convert your code to use the new functions.
170
171 @menu
172 * Adding New Commands::
173 * Hooks::
174 * Scheme User Levels::
175 * Sending Messages::
176 * Misc Scripting Stuff::
177 @end menu
178
179 @node Adding New Commands, Hooks, Scripting, Scripting
180 @section Adding New Commands
181
182 @findex addcommand
183 Adding a new command is simple. To register a new command use
184 @code{bot:addcommand}. The prototype for @code{bot:addcommand} is
185 @code{(bot:addcommand name func needs-channel? num-of-args
186 min-level)}. The @code{name} is a string representing the name of the
187 command being added. @code{func} is a function accepting
188 @code{num-of-args} arguments. @code{needs-channel?} is a bool that is
189 true if the function needs the channel name as its first arg, and
190 false otherwise. @code{num-of-args} is the number of args @code{func}
191 will take and must be within zero (0) and twenty
192 (20). @code{min-level} is one of the @ref{Scheme User Levels}. A user must be
193 at least a @code{min-level} user to use the new command. None of the
194 arguments are guaranteed to be passed; if they aren't they are set to
195 the empty string @code{""}. An example of a new command would be:
196
197 @example
198 (define (hello channel name)
199 (if (string=? name "")
200 (bot:say channel "Hello world!")
201 (bot:say channel (string-append "Hello " name "!")))
202
203 (bot:addcommand "hello" hello #t 2 0)
204 @end example
205
206 This will display ``Hello World!'' if called as @kbd{!hello} and
207 ``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}.
208
209 @node Hooks, Scheme User Levels, Adding New Commands, Scripting
210 @section Hooks
211
212 @cindex Background on Hooks
213 Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
214 and tiny fugue (a MUD bot) hooks with a little bit of extra stuff
215 added in. The basic idea of a hook if that you match a text against
216 regular expression and call a function if text in a message matches
217 that regex. The different types of hooks provided by Bobot++
218 correspond to the different classes of messages that Bobot++ can
219 recieve. A Hook also has several properties, including its priority
220 and whether or not it is a fallthrough hook. Higher priority hooks are
221 executed before lower priority hooks and fallthrough hooks are
222 executed before non-fallthrough hooks of the same priority. A
223 fallthrough hook can match and processing of hooks will continue; as
224 soon as the first non-fallthrough hooks matches processing of hooks
225 stops.
226
227 @menu
228 * Creating a Hook::
229 * Hook Types::
230 @end menu
231
232 @node Creating a Hook, Hook Types, Hooks, Hooks
233 @subsection Creating a Hook
234
235 @findex addhook
236 To add a new hook you use the function
237 @code{bot:addhook}. @code{bot:addhook} is prototyped as
238 @code{(bot:addhook type regex function pri fall name)}. @code{type}
239 specifies the type of hook (the types of hooks are listed in @ref{Hook
240 Types}). @code{regex} is a standard regular expression. If
241 @code{regex} is matched, @code{function} will be
242 called. @code{function} will take a different number of args depending
243 on the hook type. @code{pri} specifies the priority of the
244 hook---higher priority hooks are executed first. This argument is
245 optional and defaults to @code{0}. @code{fall} is @code{#t} if the
246 hook is a fallthrough hook and @code{#f} is the hook is not a
247 fallthrough hook. This arg is also optional and default to
248 @code{#t}. @code{name} is the optional name of the hook that defaults
249 to ``DEFAULT''. If you set the name then you can have more than one
250 hook that matches the same regexp, as long as they have the same
251 name. E.g. in a log script you could have the regexps for the log
252 function all be @code{".*"} and set their names to @code{"log"} to
253 avoid a conflict with other hooks.
254
255 @node Hook Types, , Creating a Hook, Hooks
256 @subsection Hook Types
257
258 Here is a list of the various hooks are notes on each one. The general
259 format of a hook is:
260
261 @itemize @bullet
262 @item
263 @code{hooks/name} (this is the Scheme variable name of the hook)
264 @itemize @minus
265 @item
266 Description of the hook
267 @item
268 @var{arg1} @var{arg2} ... @var{argn}
269 @itemize @minus
270 @item
271 @var{arg1}: desc
272 @item
273 @var{arg2}: desc
274 @item
275 ...
276 @item
277 @var{argN}: desc
278 @end itemize
279 @end itemize
280 @end itemize
281
282 That said, here is the list of available hooks:
283 FIXME: write docs
284
285 @itemize @bullet
286
287 @item
288 @vindex hooks/action
289 @code{hooks/action}
290 @itemize @minus
291 @item
292 This hook is triggered when someone performs an action.
293 @item
294 @var{from}, @var{to}, @var{action}
295 @itemize @minus
296 @item
297 @var{from}: this is the address of the person that performed the
298 action in the form @samp{@var{nick} ! @var{user} @@ @var{host}}
299 (without the spaces).
300 @item
301 @var{to}: This is the target of the action, which is either a channel
302 or the Bot's nick.
303 @item
304 @var{action}: This is the text of the action. E.g. if someone did
305 @samp{* foobar does baz}, then @var{action} would be the string
306 @code{"does baz"}.
307 @end itemize
308 @end itemize
309
310 @item
311 @vindex hooks/nickname
312 @code{hooks/nickname}
313 @itemize @minus
314 @item
315 Description of the hook
316 @item
317 # of args
318 @itemize @minus
319 @item
320 @code{arg1}: desc
321 @end itemize
322 @end itemize
323
324 @item
325 @vindex hooks/signoff
326 @code{hooks/signoff}
327 @itemize @minus
328 @item
329 Description of the hook
330 @item
331 # of args
332 @itemize @minus
333 @item
334 @code{arg1}: desc
335 @end itemize
336 @end itemize
337
338 @item
339 @vindex hooks/ctcp
340 @code{hooks/ctcp}
341 @itemize @minus
342 @item
343 Description of the hook
344 @item
345 # of args
346 @itemize @minus
347 @item
348 @code{arg1}: desc
349 @end itemize
350 @end itemize
351
352 @item
353 @vindex hooks/ctcp-reply
354 @code{hooks/ctcp-reply}
355 @itemize @minus
356 @item
357 Description of the hook
358 @item
359 # of args
360 @itemize @minus
361 @item
362 @code{arg1}: desc
363 @end itemize
364 @end itemize
365
366 @item
367 @vindex hooks/disconnect
368 @code{hooks/disconnect}
369 @itemize @minus
370 @item
371 Description of the hook
372 @item
373 # of args
374 @itemize @minus
375 @item
376 @code{arg1}: desc
377 @end itemize
378 @end itemize
379
380 @item
381 @vindex hooks/flood
382 @code{hooks/flood}
383 @itemize @minus
384 @item
385 Description of the hook
386 @item
387 # of args
388 @itemize @minus
389 @item
390 @code{arg1}: desc
391 @end itemize
392 @end itemize
393
394 @item
395 @vindex hooks/invite
396 @code{hooks/invite}
397 @itemize @minus
398 @item
399 Description of the hook
400 @item
401 # of args
402 @itemize @minus
403 @item
404 @code{arg1}: desc
405 @end itemize
406 @end itemize
407
408 @item
409 @vindex hooks/join
410 @code{hooks/join}
411 @itemize @minus
412 @item
413 Description of the hook
414 @item
415 # of args
416 @itemize @minus
417 @item
418 @code{arg1}: desc
419 @end itemize
420 @end itemize
421
422 @item
423 @vindex hooks/kick
424 @code{hooks/kick}
425 @itemize @minus
426 @item
427 Description of the hook
428 @item
429 # of args
430 @itemize @minus
431 @item
432 @code{arg1}: desc
433 @end itemize
434 @end itemize
435
436 @item
437 @vindex hooks/part
438 @code{hooks/part}
439 @itemize @minus
440 @item
441 Description of the hook
442 @item
443 # of args
444 @itemize @minus
445 @item
446 @code{arg1}: desc
447 @end itemize
448 @end itemize
449
450 @item
451 @vindex hooks/mode
452 @code{hooks/mode}
453 @itemize @minus
454 @item
455 Description of the hook
456 @item
457 # of args
458 @itemize @minus
459 @item
460 @code{arg1}: desc
461 @end itemize
462 @end itemize
463
464 @item
465 @vindex hooks/message
466 @code{hooks/message}
467 @itemize @minus
468 @item
469 Description of the hook
470 @item
471 # of args
472 @itemize @minus
473 @item
474 @code{arg1}: desc
475 @end itemize
476 @end itemize
477
478 @item
479 @vindex hooks/notice
480 @code{hooks/notice}
481 @itemize @minus
482 @item
483 Description of the hook
484 @item
485 # of args
486 @itemize @minus
487 @item
488 @code{arg1}: desc
489 @end itemize
490 @end itemize
491
492 @item
493 @vindex hooks/public
494 @code{hooks/public}
495 @itemize @minus
496 @item
497 Description of the hook
498 @item
499 # of args
500 @itemize @minus
501 @item
502 @code{arg1}: desc
503 @end itemize
504 @end itemize
505
506 @item
507 @vindex hooks/public-notice
508 @code{hooks/public-notice}
509 @itemize @minus
510 @item
511 Description of the hook
512 @item
513 # of args
514 @itemize @minus
515 @item
516 @code{arg1}: desc
517 @end itemize
518 @end itemize
519
520 @item
521 @vindex hooks/raw
522 @code{hooks/raw}
523 @itemize @minus
524 @item
525 Description of the hook
526 @item
527 # of args
528 @itemize @minus
529 @item
530 @code{arg1}: desc
531 @end itemize
532 @end itemize
533
534 @item
535 @vindex hooks/timer
536 @code{hooks/timer}
537 @itemize @minus
538 @item
539 Description of the hook
540 @item
541 # of args
542 @itemize @minus
543 @item
544 @code{arg1}: desc
545 @end itemize
546 @end itemize
547
548 @item
549 @vindex hooks/topic
550 @code{hooks/topic}
551 @itemize @minus
552 @item
553 Description of the hook
554 @item
555 # of args
556 @itemize @minus
557 @item
558 @code{arg1}: desc
559 @end itemize
560 @end itemize
561
562 @item
563 @vindex hooks/dcc/begin
564 @code{hooks/dcc/begin}
565 @itemize @minus
566 @item
567 This hook is triggered when a user begins a DCC CHAT with the bot.
568 @item
569 @var{FROM}
570 @itemize @minus
571 @item
572 @var{FROM}: This is the user's address in the form
573 @samp{nick!user@@host}.
574 @end itemize
575 @end itemize
576
577 @item
578 @vindex hooks/dcc/message
579 @code{hooks/dcc/message}
580 @itemize @minus
581 @item
582 This hook is triggered when a user sends a message to the bot through
583 a DCC CHAT
584 @item
585 @var{FROM} @var{MESSAGE}
586 @itemize @minus
587 @item
588 @var{FROM}: This is the user's address in the form
589 @samp{nick!user@@host}.
590 @item
591 @var{MESSAGE}: This is the message the user sent to the bot.
592 @end itemize
593 @end itemize
594 @end itemize
595
596
597 @node Scheme User Levels, Sending Messages, Hooks, Scripting
598 @section Scheme User Levels
599
600 @vindex user-none
601 @vindex user-user
602 @vindex user-trusted
603 @vindex user-friend
604 @vindex user-master
605 There are five levels that a user may be when interfacing with a bot:
606 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
607 @var{master}. The Scheme variables for the user levels are
608 @code{bot:user-none}, @code{bot:user-user}, @code{bot:user-trusted},
609 @code{bot:user-friend}, and @code{bot:user-master}. See @ref{User
610 Levels} for more information on User Levels.
611
612 When adding a new command, think about who should be able to use
613 it. Is your command a general purpose command that helps the channel
614 (e.g. @code{!seen}) that everyone should be able to use? Or is it
615 something that should be restricted? See @ref{User Levels} for
616 information on what level users can do what with the built in bot
617 commands and think about what level a user your command is targetted
618 towards. You must be @emph{very} careful when giving new commands to
619 lower level users because you can do basically everything the bot can
620 do with a script. As the scripting interface becomes more powerful,
621 you must think more about what users can use new commands you add.
622
623 @node Sending Messages, Misc Scripting Stuff, Scheme User Levels, Scripting
624 @section Sending Messages
625
626 There are several types of messages you can send with Bobot++ from
627 scripts. There is the simple, but rather limited, @code{bot:say},
628 @code{bot:action} and @code{bot:msg}, and
629 the more powerful, but lower level, @code{bot:send-MESSAGE}
630 functions. Most bots will probably only need the higher level
631 functions, but for the sake of why-not Bobot++ lets you use the lower
632 level functions (in progress).
633
634 @menu
635 * High Level Message Functions::
636 * Low Level Message Functions::
637 @end menu
638
639 @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages
640 @subsection ``High Level'' Message Functions
641
642 ...
643
644 @node Low Level Message Functions, , High Level Message Functions, Sending Messages
645 @subsection ``Low Level'' Message Functions
646
647 The ``Low Level'' messaging functions allow you to do things like send
648 CTCP messages. You probably want to read rfc 2812 and the CTCP spec
649 before using these. If you have no idea what these do, read rfc 2812
650 (IRC Client Protocol) and CTCP spec. These functions all return
651 @code{*unspecified*} always, so don't use the return value for anything.
652
653 @itemize @bullet
654
655 @item @code{bot:send-CTCP to command message}
656 @code{to} is the target of your CTCP message, @code{command} is the
657 CTCP command, and @code{message} is the message (or arguments) of the
658 command. Make sure to @code{bot:ctcp-quote} the message!
659
660 @end itemize
661
662 @node Misc Scripting Stuff, , Sending Messages, Scripting
663 @section Misc. Scripting Stuff
664
665 These are a few useful things that I thought people writing scripts
666 might want to know.
667
668 @vindex exit-hook
669 If you want to execute code when the bot exits, just do
670 @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an
671 argumentless procedure (a thunk). When the bot exits your thunk will
672 be called.
673
674 @node Concept Index, Function Index, Scripting, Top
675 @unnumbered Concept Index
676 @printindex cp
677
678 @node Function Index, Variable Index, Concept Index, Top
679 @unnumbered Function Index
680 @printindex fn
681
682 @node Variable Index, , Function Index, Top
683 @unnumbered Variable Index
684 @printindex vr
685
686 @bye