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