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