[project @ 2005-06-23 18:49:38 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,2004,2005 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 Opt plus 1filll
28 Copyright @copyright{} 2002,2004,2005 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.5 of the program named
46 Bobot++
47
48 Copyright 2002,2004 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
66 @detailmenu
67 --- The Detailed Node Listing ---
68
69 Configuration
70
71 * Configuration Files::
72 * Configuration File Placement::
73
74 Configuration Files
75
76 * bot.conf::
77 * bot.users::
78
79 bot.conf
80
81 * server syntax::
82 * channel syntax::
83
84 Using Bobot++
85
86 * Starting the Bot::
87 * User Levels::
88 * Protection::
89 * Automatic Op::
90 * Built-In Commands::
91
92 Scripting
93
94 * Adding New Commands::
95 * Hooks::
96 * Scheme User Levels::
97 * Sending Messages::
98 * Misc Scripting Stuff::
99
100 Hooks
101
102 * Creating a Hook::
103 * Hook Types::
104
105 Sending Messages
106
107 * High Level Message Functions::
108 * Low Level Message Functions::
109
110 @end detailmenu
111 @end menu
112
113 @node Introduction, Configuration, Top, Top
114 @chapter Introduction
115
116 This manual feels abused and neglected because it has almost no
117 content.
118
119 @node Configuration, Using the Bot, Introduction, Top
120 @chapter Configuration
121
122 Bobot++ is easy to configure. See the @file{examples} directory for an
123 example configuration.
124
125 @menu
126 * Configuration Files::
127 * Configuration File Placement::
128 @end menu
129
130 @node Configuration Files, Configuration File Placement, Configuration, Configuration
131 @section Configuration Files
132
133 @menu
134 * bot.conf::
135 * bot.users::
136 @end menu
137
138 @node bot.conf, bot.users, Configuration Files, Configuration Files
139 @subsection bot.conf
140
141 @menu
142 * server syntax::
143 * channel syntax::
144 @end menu
145
146 @file{bot.conf} contains key value pairs separated by @code{=}.
147
148 @code{<key> = <value>}
149
150 Comments are started with a @code{#} and cause the entire line to be
151 ignored. @emph{Note that this only works when the @code{#} is the first
152 character of the line}.
153
154 bot.conf is the main configuration file for a Bobot++. The available
155 configuration variables are listed below in the format ``@var{variable}
156 <default-value>: description''
157
158 @itemize @bullet
159
160 @item @var{nickname} <Bobot>: The nickname of the bot (@var{nick} is an
161 alias for @var{nickname})
162 @item @var{username} <bobot>: The IRC username of the bot
163 @item @var{cmdchar} <!>: The character that prefixes commands given to
164 the bot (@var{command} is an alias for @var{cmdchar})
165 @item @var{ircname} <I'm a bobot++!>: The IRC name (or 'real name') of
166 the bot (@var{realname} is an alias for @var{ircname})
167 @item @var{userlist} <bot.users>: Name of the file where the userlist is
168 stored
169 @item @var{shitlist} <bot.shit>: Name of the file where the shitlist is
170 stored
171 @item @var{logfile} <$LOGDIR/bot.log>: Location of the bot logfile
172 (set this to @file{/dev/null} to disable logging).
173 @item @var{server} <None>: This specifies the server to connect
174 to. Note that this has a special syntax.
175 @item @var{channel} <None>: This specifies a channel the bot will join
176 when it starts up. This also has a special syntax.
177
178 @end itemize
179
180 @node server syntax, channel syntax, bot.conf, bot.conf
181 @subsubsection server syntax
182
183 @var{server} = @var{server_name} [@var{port} [@var{password}]]
184
185 This will make Bobot++ attempt to connect to @var{server_name} on port
186 @var{port} with the password @var{password}. @var{server_name} should
187 be the address of the server. @var{port} and @var{password} are
188 optional. You may use more than one server line; Bobot++ will attempt
189 to connect to the first one and, if it fails, will connect to the next
190 one in the list. There is also a command to cause the bot to cycle
191 servers. At the present time Bobot++ cannot connect to more than one
192 server at a time. This is a planned feature of 3.0 (which is a very
193 long way away; the current structure of the program would make it very
194 difficult to add support for connecting to multiple servers at a time
195 in a usable manner).
196
197 @node channel syntax, , server syntax, bot.conf
198 @subsubsection channel syntax
199
200 @var{channel} =
201 @var{name}:@var{initial_modes}:@var{modes_to_keep}:@var{channel_key}
202
203 You may have any number of channel lines. When Bobot++ starts it will
204 attempt to join and gain ops in every channel listed. It will join
205 @var{name} and set the channel modes to @var{initial_modes}
206 (e.g. ``nt'') if it is able to gain operator status. It will then
207 maintain @var{modes_to_keep}. If the channel requires a key to enter
208 simply set @var{channel_key}. Every argument except for @var{name} is
209 optional.
210
211 A few example lines:
212
213 @code{@var{channel} = #foo:nt:nt:bar}
214
215 The bot will join @code{#foo} with the channel key @code{bar} and will
216 then maintain the modes @code{nt}.
217
218 @code{@var{channel} = #bar:::}
219
220 The bot will join @code{#bar} and will not set any modes nor will it
221 attempt to maintain any modes.
222
223 @node bot.users, , bot.conf, Configuration Files
224 @subsection bot.users
225
226 @file{bot.users} is the default file name of the userlist. It may be
227 changed in @file{bot.conf}. The file contains lines with the format:
228
229 @samp{@var{mask}:@var{channel}:@var{level}:@var{protection}:@var{auto-op}}
230
231 @itemize
232
233 @item @var{mask} is the host mask
234 (e.g. @samp{*!*username@*.domain.com}) of the user
235
236 @item @var{channel} is a channel mask of the channels that the user
237 has priviliges to use the bot in (e.g. @samp{*} for all channels,
238 @samp{#*} for all non-local channel, @samp{#foo*} for all channels
239 starting with ``foo,'' @samp{#bar} for channel ``#bar'' only, etc.)
240
241 @item @var{level} is the user level of the user (@ref{User Levels}).
242
243 @item @var{protection} is the protection level of the user
244 (@ref{Protection}).
245
246 @item @var{auto-op} is set to control whether a user is automatically
247 given operator priviliges on channel entry (@ref{Automatic Op}).
248
249 @end itemize
250
251 @node Configuration File Placement, , Configuration Files, Configuration
252 @section Configuration File Placement
253
254 @quotation
255 [ I kinda think this should go before the detailed description of the
256 config file. I was didn't see it at first and was very frustrated
257 trying to find out @emph{where} to edit all this wonderful stuff. ]
258 @end quotation
259
260 Bobot++ will look in @file{/etc/bobotpp/default/} for its default
261 config if none is specified on the command line. Put the configuration
262 files you want to be loaded by default in this directory. If you are
263 not root or you want to have your own personal configuration, put it
264 in @file{~/.bobotpp/config/default/}.
265
266 @node Using the Bot, Scripting, Configuration, Top
267 @chapter Using Bobot++
268
269 FIXME: stuff here...
270
271 @menu
272 * Starting the Bot::
273 * User Levels::
274 * Protection::
275 * Automatic Op::
276 * Built-In Commands::
277 @end menu
278
279 @node Starting the Bot, User Levels, Using the Bot, Using the Bot
280 @section Starting the Bot
281
282 The bot is usually installed with the binary name @file{bobotpp}. It
283 accepts the following command line arguments:
284
285 @itemize
286 @item @code{[--help][-h]} - Shows detailed help and exits
287 @item @code{[--version][-v]} - Shows version information and exits
288 @item @code{[--no-background][-b]} - Run bobot++ in the foreground
289 @item @code{[--config-file file][-f]} - Use file instead of @file{bot.conf}
290 @item @code{[--config-dir dir][-d]} - Use dir as dir to load config file from
291 @item @code{[--config dir][-c]} - Search your config path (defaults to
292 @file{@var{$HOME}/.bobotpp/config/} and then @file{/etc/bobotpp/}) for
293 dir and then loads your config data using dir
294 @item @code{[--sys-config dir][-s]} - Looks for config in
295 @file{/etc/bobotpp/dir}. Note that the user dir is still searched
296 first
297 @item @code{[--user-config dir][-u]} - Looks for config in
298 @file{@var{$HOME}/.bobotpp/config/dir/}. Note that the system dir is
299 still searched after this if dir is not found.
300 @item @code{[--debug][-D]} Makes Bobot++ print debugging info and run
301 in the foreground
302 @end itemize
303
304 The default configuration is read from
305 @file{@var{$HOME}/.bobotpp/config/default/} and then
306 @file{/etc/bobotpp/default/} if the user config is not found.
307
308 The bot defaults to running in the background as a daemon.
309
310 @node User Levels, Protection, Starting the Bot, Using the Bot
311 @section User Levels
312
313 There are several user levels available in Bobot++ to provide gradated
314 access to commands. @command{!adduser} and @file{bot.users} use the
315 numeric code; Scheme uses the textual name for the level. By default
316 (if no catch-all setting is found in @xref{bot.users}.) a user is not
317 even a @code{bot:user-none} and cannot execute @strong{any} commands,
318 even commands available to @code{bot:user-none}.
319
320 @enumerate 0
321
322 @item @code{bot:user-none} - No @strong{built-in} commands may be
323 executed @emph{by default} (commands may be added from Scheme that can
324 be executed by users of level none and the level required to execute a
325 command may be changed from Scheme).
326
327 @item @code{bot:user-user} - Will be able to execute most commands but
328 not all and cannot use masks on kicks and bans.
329
330 @item @code{bot:user-trusted} - For built-ins with a default
331 configuration this user has access to the same set of commands as an
332 @code{user} but may use masks on kicks and bans. Scheme commands may
333 be added which require a user to be of this level.
334
335 @item @code{bot:user-friend} - In the default configuration a user who
336 is a friend will be able to do everything short of stopping the
337 bot. Again, there may be user added commands that require a higher
338 user level.
339
340 @item @code{bot:user-master} - This is the highest user level and has
341 access to every feature of the bot.
342
343 @end enumerate
344
345 @node Protection, Automatic Op, User Levels, Using the Bot
346 @section Protection
347
348 A user added via Scheme, the @file{bot.users} file, or
349 @command{!adduser} may be protected from being deoped, kicked, or
350 banned. There are currently no symbolic levels in Scheme; just use the
351 numeric code.
352
353 @enumerate 0
354 @item No protection
355 @item No ban. If a user is banned the bot will unban him..
356 @item No kick. The user may still be kicked but the bot will kickban
357 the user who kicked the protected user.
358 @item No deop. The bot will ensure that the user always maintains
359 operator status.
360 @end enumerate
361
362 @node Automatic Op, Built-In Commands, Protection, Using the Bot
363 @section Automatic Op
364
365 A user may be automatically given operator status upon entering a
366 channel. Set the @var{aop} field to ``0'' to disable auto-op or ``1''
367 to enable auto-op.
368
369 @node Built-In Commands, , Automatic Op, Using the Bot
370 @section Built-In Commands
371
372 Bobot++ has many built-in commands that make it useful without
373 scripting support. The reference leaves off the command char; remember
374 to use whatever you defined the command char to be in
375 @file{bot.conf}. If a command needs the channel name then you must
376 specify the channel as the first argument to the command when private
377 messaging the bot a command.
378
379 @multitable @columnfractions 0.20 0.15 0.15 0.50
380 @item @sc{command} @tab @sc{Needs Channel} @tab @sc{Min Level to Use} @tab @sc{Description}
381
382 @item @command{action} @option{do} @tab Yes @tab @var{USER} @tab
383 Causes the bot to perform the action @option{do} in the current
384 channel.
385
386 @item @command{adduser} @tab @tab @tab
387
388 @item @command{addserver} @tab @tab @tab Adds the server specified by
389 @var{host name} or @var{ip address} to the server list.
390
391 @item @command{addshit} @tab @tab @tab
392
393 @item @command{alias} @tab @tab @tab Makes an alias, and adds the
394 function @var{new name}, that will do exactly the same command as
395 @var{old name}.
396
397 @item @command{ban} @tab @tab @tab Bans @var{mask} or @var{nick} from
398 @var{channel}. You need to be a trusted user to ban with a
399 @var{mask}.
400
401 @item @command{banlist} @tab @tab @tab
402
403 @item @command{channels} @tab @tab @tab Prints the channel(s) where
404 the bot is currently.
405
406 @item @command{cycle} @tab Yes @tab @tab Makes the bot leave and join
407 @var{channel}.
408
409 @item @command{dcclist} @tab @tab @tab Gives the list of all DCC Chat
410 connections.
411
412 @item @command{deban} @tab Yes @tab @tab Debans @var{mask} or
413 @var{nick} from @var{channel}. You need to be a trusted user to deban
414 with a @var{mask}.
415
416 @item @command{delserver} @tab @tab @tab Deletes server from server
417 list whose number in the server list is @var{server number}.
418
419 @item @command{deluser} @tab @tab @tab Removes @var{nick} or
420 @var{mask} from the userlist.
421
422 @item @command{delshit} @tab @tab @tab Removes @var{nick} or
423 @var{mask} from the shitlist.
424
425 @item @command{deop} @tab Yes @tab @tab Deops @var{mask} or @var{nick}
426 on @var{channel}.
427
428 @item @command{die} @tab @tab @tab Makes the bot stop immediately.
429
430 @item @command{do} @tab @tab @tab
431
432 @item @command{execute} @tab @tab @tab @strong{Only available if
433 scripting support is enabled}
434
435 @item @command{help} @tab @tab @tab
436
437 @item @command{ident} @tab @tab @tab Identifies you on the bot. Note
438 that you should not use this command in public @dots{}
439
440 @item @command{invite} @tab Yes @tab @tab Invites @var{nick} on
441 @var{channel}.
442
443 @item @command{join} @tab @tab @tab Makes the bot join @var{channel}.
444
445 @item @command{keep} @tab Yes @tab @tab Sets the @var{modes} that the
446 bot will keep for @var{channel}.
447
448 @item @command{kick} @tab Yes @tab @tab Kicks @var{mask} or @var{nick}
449 out of @var{channel}, because of @var{reason}. You need to be a
450 trusted user to use a @var{mask}.
451
452 @item @command{kickban} @tab Yes @tab @tab Bans then kicks @var{mask}
453 or @var{nick} out of @var{channel}, because of @var{reason}. You need
454 to be a trusted user to use a @var{mask}.
455
456 @item @command{load} @tab @tab @tab Reloads the userlist from disk.
457
458 @item @command{loadscript} @tab @tab @tab @strong{Only available if
459 scripting support is enabled}
460
461 @item @command{lock} @tab @tab @tab Locks topic on @var{channel}.
462
463 @item @command{mode} @tab Yes @tab @tab Sends @var{mode string} as
464 mode for @var{channel}.
465
466 @item @command{msg} @tab @tab @tab
467
468 @item @command{names} @tab Yes @tab @tab Shows the nicknames and
469 status of users on @var{channel}.
470
471 @item @command{nextserver} @tab @tab @tab Makes the bot connect to the
472 next server in its server list.
473
474 @item @command{nick} @tab @tab @tab Makes the bot use nickname @var{nick}.
475
476 @item @command{nslookup} @tab @tab @tab Does a nameserver query about
477 @var{nick} host, @var{host} or @var{ip address}.
478
479 @item @command{op} @tab Yes @tab @tab Ops @var{nick} on @var{channel}.
480
481 @item @command{part} @tab Yes @tab @tab Makes the bot leave @var{channel}.
482
483 @item @command{password} @tab @tab @tab Changes your password on the
484 bot. Use @code{NONE} as password if you want to clear it. Do not use this
485 command in public!
486
487 @item @command{reconnect} @tab @tab @tab Makes the bot reconnect to
488 its current server.
489
490 @item @command{rspymessage} @tab @tab @tab Removes you from the spy
491 list.
492
493 @item @command{save} @tab @tab @tab Saves the userlist.
494
495 @item @command{say} @tab Yes @tab @tab Makes the bot say @var{message}
496 on @var{channel}.
497
498 @item @command{server} @tab @tab @tab Select the server to connect
499 to. @var{server number} is the number of the server in the serverlist.
500
501 @item @command{serverlist} @tab @tab @tab Shows the bot's serverlist.
502
503 @item @command{setfloodrate} @tab @tab @tab
504
505 @item @command{setversion} @tab @tab @tab
506
507 @item @command{shitlist} @tab @tab @tab Shows the bot's shitlist.
508
509 @item @command{spylist} @tab @tab @tab Shows the bot's spylist.
510
511 @item @command{spymessage} @tab @tab @tab Adds you to the spylist
512
513 @item @command{stats} @tab Yes @tab @tab Gives @var{channel}'s statistics.
514
515 @item @command{tban} @tab Yes @tab @tab Bans @var{nick} or @var{mask}
516 from @var{channel} for @var{time} seconds.
517
518 @item @command{tkban} @tab Yes @tab @tab Bans @var{nick} or @var{mask}
519 from @var{channel} for @var{time} seconds, then kicks him/them because
520 of @var{reason}.
521
522 @item @command{topic} @tab Yes @tab @tab If no @var{topic}is given,
523 prints @var{channel}'s topic. Otherwise, the bot will change
524 @var{channel}'s topic to @var{topic}.
525
526 @item @command{unlock} @tab Yes @tab @tab Makes the bot unlock topic
527 on @var{channel}
528
529 @item @command{userlist} @tab @tab @tab Shows the bot's userlist
530
531 @item @command{who} @tab Yes @tab @tab Show your level on @var{channel}
532
533 @item @command{whois} @tab Yes @tab @tab Shows information about
534 @var{nick} on @var{channel}
535
536 @end multitable
537
538 @node Scripting, Concept Index, Using the Bot, Top
539 @chapter Scripting
540
541 Bobot++'s most powerful feature is its scripting system. You write
542 scripts using Guile Scheme. This manual does not cover how to use
543 Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual,
544 guile, The Guile Reference Manual}, for the Guile reference manual and
545 @url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for
546 a good tutorial on Scheme.
547
548 Note that in previous versions the scripting commands where in the
549 form @code{bot-@var{function}}. They are now in the form
550 @code{bot:@var{function}}. The old names are still available, but are
551 deprecated and will be removed in Bobot++ 3.0. New commands are only
552 available with the @code{bot:} prefix. The command @command{perl -pi
553 -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to convert
554 your code to use the new functions.
555
556 @menu
557 * Adding New Commands::
558 * Hooks::
559 * Scheme User Levels::
560 * Sending Messages::
561 * Misc Scripting Stuff::
562 @end menu
563
564 @node Adding New Commands, Hooks, Scripting, Scripting
565 @section Adding New Commands
566
567 Adding a new command is simple. To register a new command use
568 @code{bot:addcommand}.
569
570 @defun bot:addcommand name func needs-channel? num-of-args min-level
571
572 The @var{name} is a string representing the name of the command being
573 added. @var{func} is a function accepting @var{num-of-args}
574 arguments. @var{needs-channel?} is a bool that is true if the function
575 needs the channel name as its first arg, and false otherwise.
576 @var{num-of-args} is the number of args @var{func} will take and must
577 be within zero (0) and twenty (20). @var{min-level} is one of the
578 @ref{Scheme User Levels}. A user must be at least a @code{min-level}
579 user to use the new command. None of the arguments are guaranteed to
580 be passed; if they aren't they are set to the empty string @code{""}.
581 An example of a new command would be:
582
583 @example
584 (define (hello channel name)
585 (if (string=? name "")
586 (bot:say channel "Hello world!")
587 (bot:say channel (string-append "Hello " name "!")))
588
589 (bot:addcommand "hello" hello #t 2 0)
590 @end example
591
592 This will display ``Hello World!'' if called as @kbd{!hello} and
593 ``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}.
594 @end defun
595
596 @node Hooks, Scheme User Levels, Adding New Commands, Scripting
597 @section Hooks
598
599 @cindex Background on Hooks
600 Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
601 and tiny fugue (a MUD bot) hooks with a little bit of extra stuff
602 added in. A hook is called when a regular expression is matched
603 against a message sent to or by the bot.
604
605 Bobot++ uses different hook types for each IRC message type, and also
606 includes a hook for accessing raw irc messages. Hooks are tagged with
607 a priority and a flag that specifies whether to call the next hook
608 that matches after calling the current one or to stop
609 processing.
610
611 Hooks are processed from the highest to lowest priority, with
612 fallthrough hooks of equal priority to non-fallthrough hooks being
613 executed first.
614
615 @menu
616 * Creating a Hook::
617 * Hook Types::
618 @end menu
619
620 @node Creating a Hook, Hook Types, Hooks, Hooks
621 @subsection Creating a Hook
622
623 To add a new hook you use the function @code{bot:addhook}.
624
625 @defun bot:addhook type regex function [pri fall name]
626 @var{type} specifies the type of hook (the types of hooks are listed
627 in @ref{Hook Types}). @var{regex} is a standard regular expression. If
628 @var{regex} is matched, @var{function} will be called. @var{function}
629 will take a different number of args depending on the hook
630 type. @var{pri} specifies the priority of the hook---higher priority
631 hooks are executed first. This argument is optional and defaults to
632 @code{0}. @var{fall} is @code{#t} if the hook is a fallthrough hook
633 and @code{#f} is the hook is not a fallthrough hook. This arg is also
634 optional and default to @code{#t}. @var{name} is the optional name of
635 the hook that defaults to ``DEFAULT''. If you set the name then you
636 can have more than one hook that matches the same regexp, as long as
637 they have the same name. E.g. in a log script you could have the
638 regexps for the log function all be @code{".*"} and set their names to
639 @code{"log"} to avoid a conflict with other hooks.
640 @end defun
641
642 @node Hook Types, , Creating a Hook, Hooks
643 @subsection Hook Types
644
645 Here is a list of the various hooks funtions and notes on each
646 one. The general format of each hook description is as if it was was
647 function to be defined, but these describe the function to be passwd
648 to @code{bot:add-hook}. Do @emph{not} name your functions these
649 names.
650
651 @quotation
652 [ Boy, that's clumsy. I want to say that the hook/xx functions that
653 are documented below are not funtions that you call. They are the
654 functions that needs to be passed to bot:addhook for that kind of
655 hook.
656
657 Still clumsy. Oh well. ]
658 @end quotation
659
660
661 That said, here is the list of available hooks functions.
662 FIXME: write docs
663
664 @defun hooks/action from to action
665 This hook is triggered when someone performs an action. @var{from} is
666 the address of the person that performed the action in the form
667 @samp{@var{nick} ! @var{user} @@ @var{host}} (without the spaces).
668 @var{to} is the target of the action, which is either a channel or the
669 Bot's nick. @var{action} is the text of the action. E.g. if someone
670 did @samp{* foobar does baz}, then @var{action} would be the string
671 @code{"does baz"}.
672 @end defun
673
674
675 @defun hooks/nickname old-nick new-nick
676 This hook gets called when someone changes thir nickname from
677 @var{old-nick} to @var{new-nick}.
678 @end defun
679
680 @defun hooks/signoff nick rest
681 @end defun
682
683 @defun hooks/ctcp nick to command rest
684 @end defun
685
686 @defun hooks/ctcp-reply nick command rest
687 @end defun
688
689 @defun hooks/disconnect server
690 This is called when the bot is disconnected from a server
691 unintentionally. @code{hooks/signoff} is called when the bot purposefully
692 disconnected. The hook function is passed the hostname of the
693 server it was disconnected from.
694 @end defun
695
696 @defun hooks/flood nick
697 @end defun
698
699 @defun hooks/invite nick channel
700 @end defun
701
702 @defun hooks/join nick channel
703 @end defun
704
705 @defun hooks/kick target from channel reason
706 @end defun
707
708 @defun hooks/leave nick channel
709 @defunx hooks/part nick channel
710 @end defun
711
712 @defun hooks/mode nick channel modes
713 @end defun
714
715 @defun hooks/message from message
716 @end defun
717
718 @defun hooks/notice nick message
719 @end defun
720
721 @defun hooks/public from to message
722 @end defun
723
724 @defun hooks/public-notice nick to message
725 @end defun
726
727 @defun hooks/raw raw-message
728 @end defun
729
730 @defun hooks/timer time
731 This hook seems to be called once a minute. @var{time} is in
732 @code{hh:mm} format.
733 @end defun
734
735 @defun hooks/topic nick channel new-topic
736 @end defun
737
738 @defun hooks/send/public mynick dest message
739 @end defun
740
741 @defun hooks/send/message botnick message
742 @end defun
743
744 @defun hooks/send/action mynick to message
745 @end defun
746
747 @defun hooks/send/ctcp mynick to command message
748 @end defun
749
750 @defun hooks/dcc/chat-begin from
751 This hook is triggered when a user begins a DCC CHAT with the bot.
752 @var{from} is the user's address in the form @samp{nick!user@@host}.
753 @end defun
754
755 @defun hooks/dcc/chat-message from message
756 This hook is triggered when a user sends a message to the bot through
757 a DCC CHAT @var{from} is the user's address in the form
758 @samp{nick!user@@host}. @var{message} is the message the user sent to
759 the bot.
760 @end defun
761
762 @node Scheme User Levels, Sending Messages, Hooks, Scripting
763 @section Scheme User Levels
764
765 @vindex user-none
766 @vindex user-user
767 @vindex user-trusted
768 @vindex user-friend
769 @vindex user-master
770 There are five levels that a user may be when interfacing with a bot:
771 @var{none}, @var{user}, @var{trusted_user}, @var{friend},
772 @var{master}. The Scheme variables for the user levels are
773 @code{bot:user-none}, @code{bot:user-user}, @code{bot:user-trusted},
774 @code{bot:user-friend}, and @code{bot:user-master}. See @ref{User
775 Levels} for more information on User Levels.
776
777 When adding a new command, think about who should be able to use
778 it. Is your command a general purpose command that helps the channel
779 (e.g. @code{!seen}) that everyone should be able to use? Or is it
780 something that should be restricted? See @ref{User Levels} for
781 information on what level users can do what with the built in bot
782 commands and think about what level a user your command is targetted
783 towards. You must be @emph{very} careful when giving new commands to
784 lower level users because you can do basically everything the bot can
785 do with a script. As the scripting interface becomes more powerful,
786 you must think more about what users can use new commands you add.
787
788 @node Sending Messages, Misc Scripting Stuff, Scheme User Levels, Scripting
789 @section Sending Messages
790
791 There are several types of messages you can send with Bobot++ from
792 scripts. There is the simple, but rather limited, @code{bot:say},
793 @code{bot:action} and @code{bot:msg}, and the more powerful, but lower
794 level, @code{bot:send-MESSAGE} functions. Most bots will probably only
795 need the higher level functions, but for the sake of why-not Bobot++
796 lets you use the lower level functions (in progress).
797
798 @menu
799 * High Level Message Functions::
800 * Low Level Message Functions::
801 @end menu
802
803 @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages
804 @subsection ``High Level'' Message Functions
805
806 @defun bot:say channel message
807 Send a public or private @var{message} to @var{channel}.
808
809 Sends a normal text message, as if a user had typed it in. The
810 @var{dest} can be a nickname or a channel.
811 @end defun
812
813 @defun bot:action channel message
814 Send an ``action'' type @var{message} to @var{channel}
815 @end defun
816
817 @defun bot:msg nick message
818 The same as if a user typed @code{/msg nick message} to their IRC client.
819 @end defun
820
821 @defun bot:notice target message
822 Sends @var{message} as a NOTICE to @var{target}. @var{target} may be a
823 user (nick) or a channel. This returns @code{#t} if the message was
824 sent successfull, @code{#f} otherwise.
825 @end defun
826
827 @node Low Level Message Functions, , High Level Message Functions, Sending Messages
828 @subsection ``Low Level'' Message Functions
829
830 @c Add a url for rfc2812
831 The ``Low Level'' messaging functions allow you to do things like send
832 CTCP messages. You probably want to read rfc 2812 and the CTCP spec
833 before using these. If you have no idea what these do, read rfc 2812
834 (IRC Client Protocol) and CTCP spec. These functions all return
835 @code{*unspecified*} always, so don't use the return value for
836 anything.
837
838 @defun bot:send-CTCP to command message
839 @code{to} is the target of your CTCP message, @code{command} is the
840 CTCP command, and @code{message} is the message (or arguments) of the
841 command. Make sure to @code{bot:ctcp-quote} the message!
842 @end defun
843
844 @node Misc Scripting Stuff, , Sending Messages, Scripting
845 @section Misc. Scripting Stuff
846
847 These are a few useful things that I thought people writing scripts
848 might want to know.
849
850 @vindex exit-hook
851 If you want to execute code when the bot exits, just do
852 @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an
853 argumentless procedure (a thunk). When the bot exits your thunk will
854 be called.
855
856 @quotation
857 [ I didn't know where to put any of these, so I jsut stuck them in
858 here.
859
860 There probably needs to be several sections added, like dealing with
861 users (kicking, added, etc), dealing with the bot (channels, nickname
862 of the bot, etc), server issues (serverlist), useful tools (nslookup,
863 whois), and do on. ]
864 @end quotation
865
866
867 @defun bot:adduser nick-or-mask cbannel-mask level prot auto-op
868 Adds an user to the userlist, for a @code{nick!user@@host} matching the
869 one given, on a channel matching the @var{channelMask} given.
870
871 @multitable @columnfractions 0.33 0.33 0.33
872 @item The @var{level} can be: @tab The @var{prot} can be: @tab The @var{auto-op} can be:
873 @item 0 - No level @tab 0 - No protection @tab 0 - No auto-op
874 @item 1 - User @tab 1 - No ban @tab 1 - Op on join
875 @item 2 - Trusted User @tab 2 - No kick @tab
876 @item 3 - Friend @tab 3 - No deop @tab
877 @item 4 - Master @tab @tab
878 @end multitable
879
880 @end defun
881
882 @c (3, 4, 0)
883 @defun bot:addserver hostname ip-address [portnumber]
884 Adds the server specified by @var{hostname} or @var{ip-address} to
885 the server list.
886 @end defun
887
888 @c (3, 2, 0)
889 @defun bot:addshit nick-or-mask channel-mask level [time reason]
890 Adds an user to the shitlist, for a nick!user@@host matching the
891 one given, on a channel matching the @var{channelMask} given.
892
893 @display
894 The @var{level} can be:
895 0 - No shit
896 1 - No op
897 2 - Kick and Ban on join
898 3 - Kick and Ban on join, no deban
899 @end display
900
901 @end defun
902
903 @c (2, 0, 0)
904 @defun bot:ban channel mask-or-nick
905 Bans @var{mask} or @var{nick} from @var{channel}. You need to be a trusted
906 user to ban with a @var{mask}.
907 @end defun
908
909 @c (2, 0, 0)
910 @defun bot:change-command-level nick-or-mask channel-mask new-level
911 Gives @var{nick} or @var{mask} level @var{new-level} on channel(s)
912 @var{channel-mask}. Note that you can not change level for someone
913 whose level is greater than yours, and that you can not give a
914 level greater than yours.
915 @end defun
916
917 @c (1, 0, 0)
918 @defun bot:cycle channel
919 Makes the bot leave and join @var{channel}.
920 @end defun
921
922 @c (2, 0, 0)
923 @defun bot:deban channel mask-or-nick
924 Debans @var{mask} or @var{nick} from @var{channel}. You need to be a trusted
925 user to deban with a @var{mask}.
926 @end defun
927
928 @c (1, 0, 0)
929 @defun bot:delserver server-number
930 Deletes server from server list whose number in the server list
931 is @var{server-number}
932 @end defun
933
934 @c (2, 0, 0)
935 @defun bot:deluser nick-or-mask channel-mask
936 Removes @var{nick} or @var{mask} from the userlist.
937 @end defun
938
939 @c (2, 0, 0)
940 @defun bot:delshit nick-or-mask channel-mask
941 Removes @var{nick} or @var{mask} from the shitlist.
942 @end defun
943
944 @c (2, 0, 0)
945 @defun bot:deop channel mask-or-nick
946 Deops @var{mask} or @var{nick} on @var{channel}.
947 @end defun
948
949 @c (1, 0, 0)
950 @defun bot:die reason
951 Makes the bot stop immediately.
952 @end defun
953
954 @c (1, 0, 0)
955 @defun bot:do ?
956 @end defun
957
958 @c (2, 0, 0)
959 @defun bot:invite channel nick
960 Invites @var{nick} on @var{channel}.
961 @end defun
962
963 @c (1, 1, 0)
964 @defun bot:join channel
965 Makes the bot join @var{channel}.
966 @end defun
967
968 @c (2, 0, 0)
969 @defun bot:keep channel modes
970 Sets the @var{modes} that the bot will keep for @var{channel}.
971 See also STATS.
972 @end defun
973
974 @c (2, 1, 0)
975 @defun bot:kick channel mask-or-nick [reason]
976 Kicks @var{mask} or @var{nick} out of @var{channel}, because of @var{reason}.
977 You need to be a trusted user to use a @var{mask}.
978 @end defun
979
980 @c (2, 1, 0)
981 @defun bot:kickban channel mask-or-nick [reason]
982 Bans then kicks @var{mask} or @var{nick} out of @var{channel},
983 because of @var{reason}.
984 You need to be a trusted user to use a @var{mask}.
985 @end defun
986
987 @c (1, 0, 0)
988 @defun bot:lock channel
989 Locks topic on @var{channel}.
990 @end defun
991
992 @c (0, 0, 0)
993 @defun bot:logport
994 [ Probably returns the log port? ]
995 @end defun
996
997 @c (2, 0, 0)
998 @defun bot:mode channel mode-string
999 Sends @var{mode-string} as mode for @var{channel}.
1000 @end defun
1001
1002 @c (0, 0, 0)
1003 @defun bot:nextserver
1004 Makes the bot connect to the next server in its server list.
1005 @end defun
1006
1007 @c (1, 0, 0)
1008 @defun bot:nick nick
1009 Makes the bot use nickname @var{nick}.
1010 @end defun
1011
1012 @c (2, 0, 0)
1013 @defun bot:op channel nick
1014 Ops @var{nick} on @var{channel}.
1015 @end defun
1016
1017 @c (1, 0, 0)
1018 @defun bot:part channel
1019 Makes the bot leave @var{channel}.
1020 @end defun
1021
1022 @c (0, 0, 0)
1023 @defun bot:reconnect
1024 Makes the bot reconnect to its current server.
1025 @end defun
1026
1027 @c (1, 0, 0)
1028 @defun bot:server server-number
1029 Select the server to connect to. @var{server-number} is the number of
1030 the server in the serverlist.
1031 @end defun
1032
1033 @c (1, 0, 0)
1034 @defun bot:setfloodrate ?
1035 @end defun
1036
1037 @c (1, 0, 0)
1038 @defun bot:setversion ?
1039 @end defun
1040
1041 @c (3, 0, 0)
1042 @defun bot:tban channel nick-or-mask time
1043 Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds.
1044 @end defun
1045
1046 @c (3, 1, 0)
1047 @defun bot:tkban channel nick-or-mask time [reason]
1048 Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds,
1049 then kicks him/them because of @var{reason}.
1050 @end defun
1051
1052 @c (2, 0, 0)
1053 @defun bot:topic channel topic
1054 If no @var{topic} is given, prints @var{channel}'s topic. Otherwise,
1055 the bot will change @var{channel}'s topic to @var{topic}.
1056 @end defun
1057
1058 @defun bot:unlock channel
1059 Makes the bot unlock topic on @var{channel}.
1060 @end defun
1061
1062 @c (0, 0, 0)
1063 @defun bot:getnickname
1064 [ Gets the bot's nickname? ]
1065 @end defun
1066
1067 @c (0, 0, 0)
1068 @defun bot:getserver
1069 @end defun
1070
1071 @c (0, 0, 0)
1072 @defun bot:getserverlist
1073 @end defun
1074
1075 @c (0, 0, 0)
1076 @defun bot:flush
1077 [ Flushes the socket to the server? ]
1078 @end defun
1079
1080 @c (0, 0, 0)
1081 @defun bot:flushport
1082 [ Flushes the log port? ]
1083 @end defun
1084
1085 @c (1, 0, 0)
1086 @defun bot:random ?
1087 [ Returns a random number? What range? Why? ]
1088 @end defun
1089
1090 @c (1, 0, 0)
1091 @defun bot:delcommand
1092 [ Probably deletes a command added with @code{bot:addcommand} ? ]
1093 @end defun
1094
1095 @c (2, 0, 0)
1096 @defun bot:addtimer ? ?
1097 @end defun
1098
1099 @c (1, 0, 0)
1100 @defun bot:deltimer ?
1101 @end defun
1102
1103 @c (2, 0, 0)
1104 @defun bot:dcc-chat-send ? ?
1105 @end defun
1106
1107 @quotation
1108 [ And what about the stuff defined in @file{bobot-utils.scm} ? I just
1109 added it here so it could be somewhere. There should also be a
1110 section dealing with modules. How to use them. What module scripts
1111 are in. What module bobot++ provided primites are in. And so on. ]
1112 @end quotation
1113
1114 @defun bot:log . messages
1115 Write as many @var{messages} as you want to the log. If the arg is a
1116 thunk it will be executed and it's output will be written to the log.
1117 @end defun
1118
1119 @defun bot:load file
1120 @end defun
1121
1122 @defun bot:load-module module-spec
1123 @end defun
1124
1125 @defun bot:use-module module-spec
1126 @end defun
1127
1128 @defun bot:match-not-channel regex
1129 match-not-channel adds a prefix regex to your @var{regex} so it
1130 doesn't match the sender or channel in a PUBLIC message
1131 @end defun
1132
1133 @defun bot:match-to-me regex
1134 match-to-me matches text that was addressed to the bot with a
1135 ':', ',', or nothing after the bot name.
1136 @end defun
1137
1138 @defun bot:sent-to-me? message
1139 @end defun
1140
1141 @defun bot:ctcp-quote message
1142 Returns the CTCP quoted message
1143 Input @emph{MUST NOT} contain the trailing @code{\r\n}
1144 (it is added by the message sending code).
1145 @end defun
1146
1147
1148 @defvar %bot:loadpath
1149 @end defvar
1150
1151 @defun %bot:load-extensions
1152 @end defun
1153
1154
1155
1156 @node Concept Index, Function Index, Scripting, Top
1157 @unnumbered Concept Index
1158 @printindex cp
1159
1160 @node Function Index, Variable Index, Concept Index, Top
1161 @unnumbered Function Index
1162 @printindex fn
1163
1164 @node Variable Index, , Function Index, Top
1165 @unnumbered Variable Index
1166 @printindex vr
1167
1168 @bye