[project @ 2002-08-02 04:31:30 by unknown_lamer]
[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 @c @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 Not here yet.
89
90 @node Configure File Placement, , Configuration File Syntax, Configuration
91 @section Configuration File Placement
92
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/}.
98
99 @node Using the Bot, Scripting, Configuration, Top
100 @chapter Using Bobot++
101
102 FIXME: stuff here...
103
104 @menu
105 * User Levels::
106 @end menu
107
108 @node User Levels, , Using the Bot, Using the Bot
109 @section User Levels
110
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
126 @code{!adduser}.
127
128 @node Scripting, Concept Index, Using the Bot, Top
129 @chapter Scripting
130
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.
137
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.
144
145 @menu
146 * Adding New Commands::
147 * Hooks::
148 * Scheme User Levels::
149 * Sending Messages::
150 * Misc Scripting Stuff::
151 @end menu
152
153 @node Adding New Commands, Hooks, Scripting, Scripting
154 @section Adding New Commands
155
156 @findex addcommand
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:
170 @verb{|
171 (define (hello channel name)
172 (if (string=? name "")}@*
173 (bot:say channel "Hello world!")
174 (bot:say channel (string-append "Hello " name "!")))
175
176 (bot:addcommand "hello" hello #t 2 0)
177 |}
178 This will display ``Hello World!'' if called as @kbd{!hello} and
179 ``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}.
180
181 @node Hooks, Scheme User Levels, Adding New Commands, Scripting
182 @section Hooks
183
184 @cindex Background on Hooks
185 Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
186 hooks and tiny fugue (a MUD bot) hooks. The basic idea of a hook if
187 that you match a text against regular expression and call a function
188 if text in a message matches that regex. The different types of hooks
189 provided by Bobot++ correspond to the different classes of messages
190 that Bobot++ can recieve. A Hook also has several properties,
191 including its priority and whether or not it is a fallthrough
192 hook. Higher priority hooks are executed before lower priority hooks
193 and fallthrough hooks are executed before non-fallthrough hooks of the
194 same priority. A fallthrough hook can match and processing of hooks
195 will continue; as soon as the first non-fallthrough hooks matches
196 processing of hooks stops.
197
198 @menu
199 * Creating a Hook::
200 * Hook Types::
201 @end menu
202
203 @node Creating a Hook, Hook Types, Hooks, Hooks
204 @subsection Creating a Hook
205
206 @findex addhook
207 To add a new hook you use the function
208 @code{bot:addhook}. @code{bot:addhook} is prototyped as
209 @code{(bot:addhook type regex function pri fall name)}. @code{type}
210 specifies the type of hook (the types of hooks are listed in @ref{Hook
211 Types}). @code{regex} is a standard regular expression. If
212 @code{regex} is matched, @code{function} will be
213 called. @code{function} will take a different number of args depending
214 on the hook type. @code{pri} specifies the priority of the
215 hook---higher priority hooks are executed first. This argument is
216 optional and defaults to @code{0}. @code{fall} is @code{#t} if the
217 hook is a fallthrough hook and @code{#f} is the hook is not a
218 fallthrough hook. This arg is also optional and default to
219 @code{#t}. @code{name} is the optional name of the hook that defaults
220 to ``DEFAULT''. If you set the name then you can have more than one
221 hook that matches the same regexp, as long as they have the same
222 name. E.g. in a log script you could have the regexps for the log
223 function all be @code{".*"} and set their names to @code{"log"} to
224 avoid a conflict with other hooks.
225
226 @node Hook Types, , Creating a Hook, Hooks
227 @subsection Hook Types
228
229 Here is a list of the various hooks are notes on each one. The general
230 format of a hook is:
231
232 @itemize @bullet
233 @item
234 @code{hooks/name} (this is the Scheme variable name of the hook)
235 @itemize @minus
236 @item
237 Description of the hook
238 @item
239 # of args
240 @itemize @minus
241 @item
242 @code{arg1}: desc
243 @item
244 @code{arg2}: desc
245 @item
246 ...
247 @item
248 @code{argN}: desc
249 @end itemize
250 @end itemize
251 @end itemize
252
253 That said, here is the list of available hooks:
254 FIXME: write docs
255
256 @itemize @bullet
257
258 @item
259 @vindex hooks/action
260 @code{hooks/action}
261 @itemize @minus
262 @item
263 Description of the hook
264 @item
265 # of args
266 @itemize @minus
267 @item
268 @code{arg1}: desc
269 @end itemize
270 @end itemize
271
272 @item
273 @vindex hooks/nickname
274 @code{hooks/nickname}
275 @itemize @minus
276 @item
277 Description of the hook
278 @item
279 # of args
280 @itemize @minus
281 @item
282 @code{arg1}: desc
283 @end itemize
284 @end itemize
285
286 @item
287 @vindex hooks/signoff
288 @code{hooks/signoff}
289 @itemize @minus
290 @item
291 Description of the hook
292 @item
293 # of args
294 @itemize @minus
295 @item
296 @code{arg1}: desc
297 @end itemize
298 @end itemize
299
300 @item
301 @vindex hooks/ctcp
302 @code{hooks/ctcp}
303 @itemize @minus
304 @item
305 Description of the hook
306 @item
307 # of args
308 @itemize @minus
309 @item
310 @code{arg1}: desc
311 @end itemize
312 @end itemize
313
314 @item
315 @vindex hooks/ctcp-reply
316 @code{hooks/ctcp-reply}
317 @itemize @minus
318 @item
319 Description of the hook
320 @item
321 # of args
322 @itemize @minus
323 @item
324 @code{arg1}: desc
325 @end itemize
326 @end itemize
327
328 @item
329 @vindex hooks/disconnect
330 @code{hooks/disconnect}
331 @itemize @minus
332 @item
333 Description of the hook
334 @item
335 # of args
336 @itemize @minus
337 @item
338 @code{arg1}: desc
339 @end itemize
340 @end itemize
341
342 @item
343 @vindex hooks/flood
344 @code{hooks/flood}
345 @itemize @minus
346 @item
347 Description of the hook
348 @item
349 # of args
350 @itemize @minus
351 @item
352 @code{arg1}: desc
353 @end itemize
354 @end itemize
355
356 @item
357 @vindex hooks/invite
358 @code{hooks/invite}
359 @itemize @minus
360 @item
361 Description of the hook
362 @item
363 # of args
364 @itemize @minus
365 @item
366 @code{arg1}: desc
367 @end itemize
368 @end itemize
369
370 @item
371 @vindex hooks/join
372 @code{hooks/join}
373 @itemize @minus
374 @item
375 Description of the hook
376 @item
377 # of args
378 @itemize @minus
379 @item
380 @code{arg1}: desc
381 @end itemize
382 @end itemize
383
384 @item
385 @vindex hooks/kick
386 @code{hooks/kick}
387 @itemize @minus
388 @item
389 Description of the hook
390 @item
391 # of args
392 @itemize @minus
393 @item
394 @code{arg1}: desc
395 @end itemize
396 @end itemize
397
398 @item
399 @vindex hooks/part
400 @code{hooks/part}
401 @itemize @minus
402 @item
403 Description of the hook
404 @item
405 # of args
406 @itemize @minus
407 @item
408 @code{arg1}: desc
409 @end itemize
410 @end itemize
411
412 @item
413 @vindex hooks/mode
414 @code{hooks/mode}
415 @itemize @minus
416 @item
417 Description of the hook
418 @item
419 # of args
420 @itemize @minus
421 @item
422 @code{arg1}: desc
423 @end itemize
424 @end itemize
425
426 @item
427 @vindex hooks/message
428 @code{hooks/message}
429 @itemize @minus
430 @item
431 Description of the hook
432 @item
433 # of args
434 @itemize @minus
435 @item
436 @code{arg1}: desc
437 @end itemize
438 @end itemize
439
440 @item
441 @vindex hooks/notice
442 @code{hooks/notice}
443 @itemize @minus
444 @item
445 Description of the hook
446 @item
447 # of args
448 @itemize @minus
449 @item
450 @code{arg1}: desc
451 @end itemize
452 @end itemize
453
454 @item
455 @vindex hooks/public
456 @code{hooks/public}
457 @itemize @minus
458 @item
459 Description of the hook
460 @item
461 # of args
462 @itemize @minus
463 @item
464 @code{arg1}: desc
465 @end itemize
466 @end itemize
467
468 @item
469 @vindex hooks/public-notice
470 @code{hooks/public-notice}
471 @itemize @minus
472 @item
473 Description of the hook
474 @item
475 # of args
476 @itemize @minus
477 @item
478 @code{arg1}: desc
479 @end itemize
480 @end itemize
481
482 @item
483 @vindex hooks/raw
484 @code{hooks/raw}
485 @itemize @minus
486 @item
487 Description of the hook
488 @item
489 # of args
490 @itemize @minus
491 @item
492 @code{arg1}: desc
493 @end itemize
494 @end itemize
495
496 @item
497 @vindex hooks/timer
498 @code{hooks/timer}
499 @itemize @minus
500 @item
501 Description of the hook
502 @item
503 # of args
504 @itemize @minus
505 @item
506 @code{arg1}: desc
507 @end itemize
508 @end itemize
509
510 @item
511 @vindex hooks/topic
512 @code{hooks/topic}
513 @itemize @minus
514 @item
515 Description of the hook
516 @item
517 # of args
518 @itemize @minus
519 @item
520 @code{arg1}: desc
521 @end itemize
522 @end itemize
523
524 @end itemize
525
526
527 @node Scheme User Levels, Sending Messages, Hooks, Scripting
528 @section Scheme User Levels
529
530 @vindex user-none
531 @vindex user-user
532 @vindex user-trusted
533 @vindex user-friend
534 @vindex user-master
535 There are five levels that a user may be when interfacing with a bot:
536 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
537 @var{master}. The Scheme variables for the user levels are
538 @code{bot:user-none}, @code{bot:user-user}, @code{bot:user-trusted},
539 @code{bot:user-friend}, and @code{bot:user-master}. See @ref{User
540 Levels} for more information on User Levels.
541
542 When adding a new command, think about who should be able to use
543 it. Is your command a general purpose command that helps the channel
544 (e.g. @code{!seen}) that everyone should be able to use? Or is it
545 something that should be restricted? See @ref{User Levels} for
546 information on what level users can do what with the built in bot
547 commands and think about what level a user your command is targetted
548 towards. You must be @emph{very} careful when giving new commands to
549 lower level users because you can do basically everything the bot can
550 do with a script. As the scripting interface becomes more powerful,
551 you must think more about what users can use new commands you add.
552
553 @node Sending Messages, Misc Scripting Stuff, Scheme User Levels, Scripting
554 @section Sending Messages
555
556 There are several types of messages you can send with Bobot++ from
557 scripts. There is the simple, but rather limited, @code{bot:say},
558 @code{bot:action} and @code{bot:msg}, and
559 the more powerful, but lower level, @code{bot:send-MESSAGE}
560 functions. Most bots will probably only need the higher level
561 functions, but for the sake of why-not Bobot++ lets you use the lower
562 level functions.
563
564 @menu
565 * High Level Message Functions::
566 * Low Level Message Functions::
567 @end menu
568
569 @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages
570 @subsection ``High Level'' Message Functions
571
572 ...
573
574 @node Low Level Message Functions, , High Level Message Functions, Sending Messages
575 @subsection ``Low Level'' Message Functions
576
577 The ``Low Level'' messaging functions allow you to do things like send
578 CTCP messages. You probably want to read rfc 2812 and the CTCP spec
579 before using these. If you have no idea what these do, read rfc 2812
580 (IRC Client Protocol) and CTCP spec. These functions all return
581 @code{*unspecified*} always, so don't use the return value for anything.
582
583 @itemize @bullet
584
585 @item @code{bot:send-CTCP to command message}
586 @code{to} is the target of your CTCP message, @code{command} is the
587 CTCP command, and @code{message} is the message (or arguments) of the
588 command. Make sure to @code{bot:ctcp-quote} the message!
589
590 @end itemize
591
592 @node Misc Scripting Stuff, , Sending Messages, Scripting
593 @section Misc. Scripting Stuff
594
595 These are a few useful things that I thought people writing scripts
596 might want to know.
597
598 If you want to execute code when the bot exits, just do
599 @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an
600 argumentless procedure (a thunk). When the bot exits your thunk will
601 be called.
602
603 Since a bot calls hooks on things it says, you have to be careful
604 about hooks that output text that might match itself. E.g. if you have
605 a hook that matches @code{"foo"} and the hook displays @code{"foo to
606 the whatsit?"}, then the hook will call itself over and over until the
607 stack overflows! To protect against this I wrote the macro
608 @code{not-from-me}. You call it like this: @code{(not-from-me from
609 (stmts if not from bot) (stmts if from bot))}. E.g.
610
611 @example
612 (bot:addhook hooks/public "foo"
613 (lambda (f t p)
614 (not-from-me f ((bot:say t "foo to the what!")))))
615 @end example
616
617 This say ``foo to the what!'' to the channel that ``foo'' was said in
618 and do nothing otherwise. You can optionally specify an action to be
619 executed if the message is from the bot:
620
621 @example
622 (bot:addhook hooks/public "foo"
623 (lambda (f t p)
624 (not-from-me f ((bot:say t "foo to the what!"))
625 ((bot:say t "moof")))))
626 @end example
627
628 That will do the same thing as the first example, but the bot will
629 say ``moof'' if it said ``foo'' before. That probably isn't a very
630 nice thing to do, but it works as an example. You can have as many
631 staments as you want in the clauses.
632
633 @node Concept Index, Function Index, Scripting, Top
634 @unnumbered Concept Index
635 @printindex cp
636
637 @node Function Index, Variable Index, Concept Index, Top
638 @unnumbered Function Index
639 @printindex fn
640
641 @node Variable Index, , Function Index, Top
642 @unnumbered Variable Index
643 @printindex vr
644
645 @bye