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 |
9 | This file documents Bobot++ by Clinton Ebadi and Etienne Bernard |
e45daca1 |
10 | (The original author who no longer works on the program). |
2e20c3e1 |
11 | |
2e18045a |
12 | Copyright 2002,2004,2005 Clinton Ebadi |
2e20c3e1 |
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 |
ac18ad3d |
27 | @vskip 0pt plus 1filll |
2e18045a |
28 | Copyright @copyright{} 2002,2004,2005 Clinton Ebadi |
2e20c3e1 |
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 |
e45daca1 |
43 | (The original author who no longer works on the program). |
2e20c3e1 |
44 | |
7b564711 |
45 | This document applies to version 2.2 of the program named |
e45daca1 |
46 | Bobot++. |
439869bf |
47 | |
7b564711 |
48 | Copyright 2002,2004,2005 Clinton Ebadi |
439869bf |
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. |
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 | |
69 | Configuration |
70 | |
c7d9fb19 |
71 | * Configuration File Placement:: |
ac18ad3d |
72 | * Configuration Files:: |
c7d9fb19 |
73 | |
74 | Configuration Files |
75 | |
76 | * bot.conf:: |
c8f13c06 |
77 | * bot.users:: |
9b2fe824 |
78 | * bot.init:: |
79 | * bot.autoexec:: |
528799bd |
80 | * bot.shit:: |
c7d9fb19 |
81 | |
82 | bot.conf |
83 | |
84 | * server syntax:: |
85 | * channel syntax:: |
86 | |
87 | Using Bobot++ |
88 | |
6b59e728 |
89 | * Starting the Bot:: |
9b2fe824 |
90 | * Concepts:: |
91 | * Built-In Commands:: |
92 | |
93 | Concepts |
94 | |
c7d9fb19 |
95 | * User Levels:: |
c8f13c06 |
96 | * Protection:: |
97 | * Automatic Op:: |
528799bd |
98 | * Shit Levels:: |
c7d9fb19 |
99 | |
3fed2165 |
100 | Built-In Commands |
101 | |
102 | * Message Commands:: |
103 | * User List Commands:: |
104 | |
c7d9fb19 |
105 | Scripting |
106 | |
107 | * Adding New Commands:: |
108 | * Hooks:: |
c7d9fb19 |
109 | * Sending Messages:: |
110 | * Misc Scripting Stuff:: |
3fed2165 |
111 | * Scheme Commands:: |
112 | * Query Functions:: |
c7d9fb19 |
113 | |
114 | Hooks |
115 | |
116 | * Creating a Hook:: |
117 | * Hook Types:: |
118 | |
ae97d6ec |
119 | Hook Types |
120 | |
121 | * Received Message Hooks:: |
122 | * Sent Message Hooks:: |
123 | * DCC CHAT Hooks:: |
124 | * Miscellaneous Hooks:: |
125 | |
c7d9fb19 |
126 | Sending Messages |
127 | |
128 | * High Level Message Functions:: |
129 | * Low Level Message Functions:: |
130 | |
3fed2165 |
131 | Misc. Scripting Stuff |
132 | |
133 | * Scheme Commands:: |
134 | * Query Functions:: |
135 | |
c7d9fb19 |
136 | @end detailmenu |
2e20c3e1 |
137 | @end menu |
138 | |
31433d27 |
139 | @node Introduction, Configuration, Top, Top |
2e20c3e1 |
140 | @chapter Introduction |
141 | |
528799bd |
142 | Bobot++ is a powerful IRC bot written in C++. It can be used |
143 | standalone as a channel maintenence bot, or extended to do almost |
144 | anything using Scheme scripts. |
145 | |
146 | FIXME: Fill the intro in more? |
31433d27 |
147 | |
e07b6b46 |
148 | @node Configuration, Using the Bot, Introduction, Top |
31433d27 |
149 | @chapter Configuration |
150 | |
c8f13c06 |
151 | Bobot++ is easy to configure. See the @file{examples} directory for an |
e45daca1 |
152 | example configuration. |
153 | |
154 | The main configuration file is @file{bot.conf}. There are several |
155 | auxiliary configuration files (a user list, aliases file, ban list, |
156 | and a script autoexec). |
31433d27 |
157 | |
158 | @menu |
c7d9fb19 |
159 | * Configuration File Placement:: |
ac18ad3d |
160 | * Configuration Files:: |
31433d27 |
161 | @end menu |
162 | |
ac18ad3d |
163 | @node Configuration File Placement, Configuration Files, Configuration, Configuration |
164 | @section Configuration File Placement |
165 | |
166 | Bobot++ will look in @file{/etc/bobotpp/default/} for its default |
167 | config if none is specified on the command line. Put the configuration |
168 | files you want to be loaded by default in this directory. If you are |
e45daca1 |
169 | not root, or you want to have your own personal configuration, put it |
ac18ad3d |
170 | in @file{~/.bobotpp/config/default/}. |
171 | |
172 | @node Configuration Files, , Configuration File Placement, Configuration |
c7d9fb19 |
173 | @section Configuration Files |
31433d27 |
174 | |
e171dcce |
175 | @menu |
176 | * bot.conf:: |
c8f13c06 |
177 | * bot.users:: |
9b2fe824 |
178 | * bot.init:: |
179 | * bot.autoexec:: |
528799bd |
180 | * bot.shit:: |
e171dcce |
181 | @end menu |
182 | |
c8f13c06 |
183 | @node bot.conf, bot.users, Configuration Files, Configuration Files |
e171dcce |
184 | @subsection bot.conf |
185 | |
c7d9fb19 |
186 | @file{bot.conf} contains key value pairs separated by @code{=}. |
187 | |
188 | @code{<key> = <value>} |
189 | |
190 | Comments are started with a @code{#} and cause the entire line to be |
191 | ignored. @emph{Note that this only works when the @code{#} is the first |
192 | character of the line}. |
193 | |
e171dcce |
194 | bot.conf is the main configuration file for a Bobot++. The available |
195 | configuration variables are listed below in the format ``@var{variable} |
196 | <default-value>: description'' |
197 | |
e45daca1 |
198 | A few of the options have more complex syntax, they are documented in |
199 | their own subsections. |
200 | |
201 | @menu |
202 | * server syntax:: |
203 | * channel syntax:: |
204 | @end menu |
205 | |
e171dcce |
206 | @itemize @bullet |
207 | |
528799bd |
208 | @item @var{maxnicklength} <9>: The maximum length a valid nickname may |
209 | be. This should be set before setting the bot's nickname if it will be |
210 | more than nine characters long. Most IRC servers support nicknames |
211 | longer than nine characters, but Bobot++ still follows the old spec |
212 | and defaults to nine. |
e171dcce |
213 | @item @var{nickname} <Bobot>: The nickname of the bot (@var{nick} is an |
214 | alias for @var{nickname}) |
215 | @item @var{username} <bobot>: The IRC username of the bot |
216 | @item @var{cmdchar} <!>: The character that prefixes commands given to |
217 | the bot (@var{command} is an alias for @var{cmdchar}) |
218 | @item @var{ircname} <I'm a bobot++!>: The IRC name (or 'real name') of |
219 | the bot (@var{realname} is an alias for @var{ircname}) |
220 | @item @var{userlist} <bot.users>: Name of the file where the userlist is |
221 | stored |
9b2fe824 |
222 | @item @var{autoexecfile} <bot.autoexec>: Name of the file containing |
223 | Scheme code to be executed when the bot starts (only used if the bot |
224 | is compiled with scripting support) |
225 | @item @var{initfile} <bot.init>: Name of the file containing the |
226 | default command aliases |
e45daca1 |
227 | @item @var{shitlist} <bot.shit>: Name of the file where the shitlist |
228 | (ban list) is stored |
c7d9fb19 |
229 | @item @var{logfile} <$LOGDIR/bot.log>: Location of the bot logfile |
230 | (set this to @file{/dev/null} to disable logging). |
e45daca1 |
231 | @item @var{server} <None>: This specifies the server to which the bot |
232 | will connect. Note that this has a special syntax @pxref{server |
233 | syntax}. |
234 | @item @var{channel} <None>: This specifies the channels the bot will join |
235 | when it starts up. This has a special syntax @pxref{channel |
236 | syntax}. |
e171dcce |
237 | |
238 | @end itemize |
31433d27 |
239 | |
c7d9fb19 |
240 | @node server syntax, channel syntax, bot.conf, bot.conf |
241 | @subsubsection server syntax |
242 | |
e45daca1 |
243 | The server syntax in @file{bot.conf} allows you to specify an |
244 | alternate port to connect on, and a password to send the server. |
245 | |
246 | You may use more than one server line; Bobot++ will attempt to connect |
247 | to the first one, and will connect to the next one in the list if it |
248 | fails. The bot will continue cycling through the server list until it |
249 | is able to connect to one. There is a command (@code{!cycle}) to make |
250 | the bot to cycle servers. |
251 | |
c7d9fb19 |
252 | @var{server} = @var{server_name} [@var{port} [@var{password}]] |
253 | |
254 | This will make Bobot++ attempt to connect to @var{server_name} on port |
255 | @var{port} with the password @var{password}. @var{server_name} should |
256 | be the address of the server. @var{port} and @var{password} are |
e45daca1 |
257 | optional. |
c7d9fb19 |
258 | |
259 | @node channel syntax, , server syntax, bot.conf |
260 | @subsubsection channel syntax |
261 | |
e45daca1 |
262 | The channel syntax in @file{bot.conf} allows you to specify the |
263 | initial modes the bot should set on a channel, the modes the bot |
264 | should maintain, and a key if the channel needs it. |
265 | |
266 | You may have any number of channel lines. When Bobot++ starts it will |
267 | attempt to join and gain operator status in every channel listed. |
268 | |
c7d9fb19 |
269 | @var{channel} = |
270 | @var{name}:@var{initial_modes}:@var{modes_to_keep}:@var{channel_key} |
271 | |
e45daca1 |
272 | The bot will join @var{name} and set the channel modes to |
273 | @var{initial_modes} (e.g. ``nt'') if it is able to gain operator |
274 | status. It will then maintain @var{modes_to_keep}. If the channel |
275 | requires a key to enter simply set @var{channel_key}. Every argument |
276 | except for @var{name} is optional. |
c7d9fb19 |
277 | |
278 | A few example lines: |
279 | |
e45daca1 |
280 | @example |
281 | @var{channel} = #foo:nt:nt:bar |
282 | @end example |
c7d9fb19 |
283 | |
284 | The bot will join @code{#foo} with the channel key @code{bar} and will |
285 | then maintain the modes @code{nt}. |
286 | |
e45daca1 |
287 | @example |
288 | @var{channel} = #bar::: |
289 | @end example |
c7d9fb19 |
290 | |
291 | The bot will join @code{#bar} and will not set any modes nor will it |
292 | attempt to maintain any modes. |
293 | |
9b2fe824 |
294 | @node bot.users, bot.init, bot.conf, Configuration Files |
528799bd |
295 | @subsection bot.users (User List) |
c8f13c06 |
296 | |
297 | @file{bot.users} is the default file name of the userlist. It may be |
9b2fe824 |
298 | changed in @file{bot.conf} via the @var{userlist} option. @strong{You |
299 | must add an entry for yourself manually.} You will probably want to |
300 | add other entries using the IRC command interface as it is more |
301 | intuitive than editing the file by hand. |
528799bd |
302 | |
303 | The file contains lines with the format: |
c8f13c06 |
304 | |
528799bd |
305 | @samp{@var{host_mask}:@var{channel_mask}:@var{level}:@var{protection}:@var{auto-op}:@var{expiration}:@var{password}} |
c8f13c06 |
306 | |
307 | @itemize |
308 | |
528799bd |
309 | @item @var{host_mask} is the host mask |
c8f13c06 |
310 | (e.g. @samp{*!*username@*.domain.com}) of the user |
311 | |
528799bd |
312 | @item @var{channel_mask} is a channel mask of the channels that the user |
c8f13c06 |
313 | has priviliges to use the bot in (e.g. @samp{*} for all channels, |
314 | @samp{#*} for all non-local channel, @samp{#foo*} for all channels |
315 | starting with ``foo,'' @samp{#bar} for channel ``#bar'' only, etc.) |
316 | |
317 | @item @var{level} is the user level of the user (@ref{User Levels}). |
318 | |
319 | @item @var{protection} is the protection level of the user |
320 | (@ref{Protection}). |
321 | |
322 | @item @var{auto-op} is set to control whether a user is automatically |
323 | given operator priviliges on channel entry (@ref{Automatic Op}). |
324 | |
528799bd |
325 | @item @var{expiration} is the UNIX timestamp of when the user entry |
326 | becomes invalid. Setting this to -1 will make the entry permanent. |
327 | |
328 | @item @var{password} is the password the user must supply to the bot |
329 | to authenticate. This can be set to @code{*NONE*} to not have a password. |
330 | |
331 | @end itemize |
332 | |
9b2fe824 |
333 | @node bot.init, bot.autoexec, bot.users, Configuration Files |
334 | @subsection bot.init (Command Aliases) |
335 | |
336 | This file stores a list of IRC command aliases. The filename may be |
337 | changed in @file{bot.conf} via the @var{initfile} option. You use this |
338 | file to set up aliases for IRC commands, e.g. to make @code{!a} call |
339 | @code{!adduser}. This way you can save typing for commonly used commands. |
340 | |
341 | The format of a line in the file is: |
342 | @var{alias} @var{command} |
343 | |
344 | This will make @var{alias} call @var{command}. e.g. @samp{t topic} |
345 | will make @code{!t New Topic} set the current channel's topic to ``New |
346 | Topic,'' just as if you had used @code{!topic New Topic}. |
347 | |
348 | @node bot.autoexec, bot.shit, bot.init, Configuration Files |
349 | @subsection bot.autoexec (Scheme Init File) |
350 | |
351 | This file is only used when Bobot++ is compiled with scripting |
352 | support. The name of the autoexec file can be changed in |
353 | @file{bot.conf} via the @var{autoexecfile} option. |
354 | |
355 | The contents of this file are evaluated by Guile when the bot |
356 | starts. You can use this to do things like loading a few default |
357 | modules when the bot starts. |
358 | |
359 | @node bot.shit, , bot.autoexec, Configuration Files |
528799bd |
360 | @subsection bot.shit (Ban/Shit List) |
361 | |
362 | This file stores the ban list. The name may be changed in |
9b2fe824 |
363 | @file{bot.conf} via the @var{shitlist} option. You will most likely |
364 | want to use the IRC command interface to edit this file instead of |
365 | editing it directly. |
528799bd |
366 | |
367 | The file contains lines in the form: |
368 | |
369 | @samp{@var{host_mask}:@var{channel_mask}:@var{level}:@var{expiration}:@var{reason}} |
370 | |
371 | @itemize |
372 | |
373 | @item @var{host_mask} is the host mask |
374 | (e.g. @samp{*!*username@*.domain.com}) of the user |
375 | |
376 | @item @var{channel_mask} is a channel mask of the channels that the user |
377 | is banned on (e.g. @samp{*} for all channels, |
378 | @samp{#*} for all non-local channel, @samp{#foo*} for all channels |
379 | starting with ``foo,'' @samp{#bar} for channel ``#bar'' only, etc. |
380 | |
381 | @item @var{level} is a number specifying if the bot should not allow |
382 | the user to gain ops, to kick the user upon joining, or to prevent the |
383 | user from being debanned by other users. @ref{Shit Levels} for |
384 | information on the available levels. |
385 | |
386 | @item @var{expiration} is the UNIX timestamp of when the shit entry |
387 | becomes invalid. This may be set to -1 to make it valid forever. |
388 | |
389 | @item @var{reason} is text that is sent to the user when they are |
390 | kicked or banned from the channel. |
391 | |
c8f13c06 |
392 | @end itemize |
393 | |
e07b6b46 |
394 | @node Using the Bot, Scripting, Configuration, Top |
395 | @chapter Using Bobot++ |
396 | |
9b2fe824 |
397 | Using Bobot++ is easy. This chapter covers starting the bot, a few |
398 | Bobot++ specific concepts, and using the built-in commands of the bot. |
e07b6b46 |
399 | |
400 | @menu |
6b59e728 |
401 | * Starting the Bot:: |
9b2fe824 |
402 | * Concepts:: |
6b59e728 |
403 | * Built-In Commands:: |
e07b6b46 |
404 | @end menu |
405 | |
9b2fe824 |
406 | @node Starting the Bot, Concepts, Using the Bot, Using the Bot |
6b59e728 |
407 | @section Starting the Bot |
408 | |
409 | The bot is usually installed with the binary name @file{bobotpp}. It |
e45daca1 |
410 | accepts the following command line arguments. |
6b59e728 |
411 | |
412 | @itemize |
6b59e728 |
413 | @item @code{[--help][-h]} - Shows detailed help and exits |
6b59e728 |
414 | @item @code{[--version][-v]} - Shows version information and exits |
6b59e728 |
415 | @item @code{[--no-background][-b]} - Run bobot++ in the foreground |
9efc3706 |
416 | @item @code{[--config-file file][-f]} - Use file instead of @file{bot.conf} |
417 | @item @code{[--config-dir dir][-d]} - Use dir as dir to load config file from |
6b59e728 |
418 | @item @code{[--config dir][-c]} - Search your config path (defaults to |
419 | @file{@var{$HOME}/.bobotpp/config/} and then @file{/etc/bobotpp/}) for |
420 | dir and then loads your config data using dir |
6b59e728 |
421 | @item @code{[--sys-config dir][-s]} - Looks for config in |
422 | @file{/etc/bobotpp/dir}. Note that the user dir is still searched |
423 | first |
6b59e728 |
424 | @item @code{[--user-config dir][-u]} - Looks for config in |
425 | @file{@var{$HOME}/.bobotpp/config/dir/}. Note that the system dir is |
426 | still searched after this if dir is not found. |
6b59e728 |
427 | @item @code{[--debug][-D]} Makes Bobot++ print debugging info and run |
428 | in the foreground |
528799bd |
429 | @item @code{[--debug-scripts][-S]} Enables the Guile debugging |
4da877a5 |
430 | evaluator for verbose script errors and backtraces while still running |
431 | the bot in the background. |
6b59e728 |
432 | @end itemize |
433 | |
434 | The default configuration is read from |
435 | @file{@var{$HOME}/.bobotpp/config/default/} and then |
436 | @file{/etc/bobotpp/default/} if the user config is not found. |
437 | |
438 | The bot defaults to running in the background as a daemon. |
439 | |
9b2fe824 |
440 | @node Concepts, Built-In Commands, Starting the Bot, Using the Bot |
441 | @section Concepts |
442 | |
443 | There are a few general concepts that a user of Bobot++ should know |
444 | about. |
445 | |
446 | @menu |
447 | * User Levels:: |
448 | * Protection:: |
449 | * Automatic Op:: |
450 | * Shit Levels:: |
451 | @end menu |
452 | |
453 | @node User Levels, Protection, Concepts, Concepts |
454 | @subsection User Levels |
e07b6b46 |
455 | |
c8f13c06 |
456 | There are several user levels available in Bobot++ to provide gradated |
457 | access to commands. @command{!adduser} and @file{bot.users} use the |
458 | numeric code; Scheme uses the textual name for the level. By default |
e45daca1 |
459 | (if the user is not found in the userlist) a user has access to |
460 | commands with the level @code{bot:user-none}. |
c8f13c06 |
461 | |
462 | @enumerate 0 |
463 | |
464 | @item @code{bot:user-none} - No @strong{built-in} commands may be |
465 | executed @emph{by default} (commands may be added from Scheme that can |
466 | be executed by users of level none and the level required to execute a |
467 | command may be changed from Scheme). |
468 | |
469 | @item @code{bot:user-user} - Will be able to execute most commands but |
470 | not all and cannot use masks on kicks and bans. |
471 | |
472 | @item @code{bot:user-trusted} - For built-ins with a default |
473 | configuration this user has access to the same set of commands as an |
474 | @code{user} but may use masks on kicks and bans. Scheme commands may |
475 | be added which require a user to be of this level. |
476 | |
477 | @item @code{bot:user-friend} - In the default configuration a user who |
478 | is a friend will be able to do everything short of stopping the |
479 | bot. Again, there may be user added commands that require a higher |
480 | user level. |
481 | |
482 | @item @code{bot:user-master} - This is the highest user level and has |
483 | access to every feature of the bot. |
484 | |
485 | @end enumerate |
486 | |
9b2fe824 |
487 | @node Protection, Automatic Op, User Levels, Concepts |
488 | @subsection Protection |
c8f13c06 |
489 | |
490 | A user added via Scheme, the @file{bot.users} file, or |
491 | @command{!adduser} may be protected from being deoped, kicked, or |
e45daca1 |
492 | banned. The user list and IRC commands use the numeric codes, Scheme |
493 | uses the symbolic names. |
c8f13c06 |
494 | |
495 | @enumerate 0 |
e45daca1 |
496 | @item @code{bot:protection/none} No protection |
497 | @item @code{bot:protection/no-ban} No ban. If a user is banned the bot will unban him.. |
498 | @item @code{bot:protection/no-kick} No kick. The user may still be kicked but the bot will kickban |
c8f13c06 |
499 | the user who kicked the protected user. |
e45daca1 |
500 | @item @code{bot:protection/no-deop} No deop. The bot will ensure that the user always maintains |
c8f13c06 |
501 | operator status. |
c8f13c06 |
502 | @end enumerate |
503 | |
9b2fe824 |
504 | @node Automatic Op, Shit Levels, Protection, Concepts |
505 | @subsection Automatic Op |
c8f13c06 |
506 | |
507 | A user may be automatically given operator status upon entering a |
e45daca1 |
508 | channel. Scheme uses the symbolic name, the user list |
509 | (@file{bot.users}) and IRC commands use the numeric value. |
510 | |
511 | @enumerate 0 |
512 | @item @code{bot:aop/no} Do not automatically op the user |
513 | @item @code{bot:aop/yes} Do automatically op the user |
514 | @end enumerate |
e07b6b46 |
515 | |
9b2fe824 |
516 | @node Shit Levels, , Automatic Op, Concepts |
517 | @subsection Shit Levels |
528799bd |
518 | |
519 | The shit list and shit list related commands use different levels to |
520 | define how much the bot hates a user. Scheme uses the symbolic names, |
521 | the shit list and IRC commands use the numbers. |
522 | |
523 | @enumerate 0 |
524 | @item @code{bot:shit/none} The bot doesn't hate the user (this is the |
525 | normal level) |
526 | @item @code{bot:shit/no-op} The bot will deop the user any time he |
527 | gains operator priviliges in the channel |
528 | @item @code{bot:shit/no-join} The bot will kick and ban the user when he |
529 | joins the channel |
530 | @item @code{bot:shit/no-deban} The bot will kick and ban usre when he |
531 | joins the channel, and will prevent other users from debanning him. |
532 | @end enumerate |
533 | |
9b2fe824 |
534 | @node Built-In Commands, , Concepts, Using the Bot |
6b59e728 |
535 | @section Built-In Commands |
536 | |
537 | Bobot++ has many built-in commands that make it useful without |
9efc3706 |
538 | scripting support. The reference leaves off the command char; remember |
539 | to use whatever you defined the command char to be in |
6b59e728 |
540 | @file{bot.conf}. If a command needs the channel name then you must |
541 | specify the channel as the first argument to the command when private |
542 | messaging the bot a command. |
543 | |
3fed2165 |
544 | @menu |
545 | * Message Commands:: |
546 | * User List Commands:: |
547 | @end menu |
548 | |
549 | @node Message Commands, User List Commands, Built-In Commands, Built-In Commands |
550 | @subsection Message Commands |
551 | |
9efc3706 |
552 | @multitable @columnfractions 0.20 0.15 0.15 0.50 |
3fed2165 |
553 | @item @sc{command} @tab @sc{Needs Channel} @tab @sc{Min Level to Use} |
554 | @tab @sc{Description} |
6b59e728 |
555 | |
556 | @item @command{action} @option{do} @tab Yes @tab @var{USER} @tab |
557 | Causes the bot to perform the action @option{do} in the current |
558 | channel. |
559 | |
3fed2165 |
560 | @item @command{do} @tab @tab @tab |
561 | |
562 | @item @command{msg} @tab @tab @tab |
563 | |
564 | @item @command{say} @tab Yes @tab @tab Makes the bot say @var{message} |
565 | on @var{channel}. |
566 | |
567 | @end multitable |
568 | |
569 | |
570 | @node User List Commands, , Message Commands, Built-In Commands |
571 | @subsection User List Commands |
572 | |
573 | @multitable @columnfractions 0.20 0.15 0.15 0.50 |
574 | @item @sc{command} @tab @sc{Needs Channel} @tab @sc{Min Level to Use} @tab @sc{Description} |
575 | |
576 | |
9efc3706 |
577 | @item @command{adduser} @tab @tab @tab |
6b59e728 |
578 | |
9efc3706 |
579 | @item @command{addserver} @tab @tab @tab Adds the server specified by |
580 | @var{host name} or @var{ip address} to the server list. |
6b59e728 |
581 | |
9efc3706 |
582 | @item @command{addshit} @tab @tab @tab |
6b59e728 |
583 | |
9efc3706 |
584 | @item @command{alias} @tab @tab @tab Makes an alias, and adds the |
585 | function @var{new name}, that will do exactly the same command as |
586 | @var{old name}. |
6b59e728 |
587 | |
9efc3706 |
588 | @item @command{ban} @tab @tab @tab Bans @var{mask} or @var{nick} from |
589 | @var{channel}. You need to be a trusted user to ban with a |
590 | @var{mask}. |
6b59e728 |
591 | |
9efc3706 |
592 | @item @command{banlist} @tab @tab @tab |
6b59e728 |
593 | |
9efc3706 |
594 | @item @command{channels} @tab @tab @tab Prints the channel(s) where |
595 | the bot is currently. |
6b59e728 |
596 | |
9efc3706 |
597 | @item @command{cycle} @tab Yes @tab @tab Makes the bot leave and join |
598 | @var{channel}. |
6b59e728 |
599 | |
9efc3706 |
600 | @item @command{dcclist} @tab @tab @tab Gives the list of all DCC Chat |
601 | connections. |
6b59e728 |
602 | |
9efc3706 |
603 | @item @command{deban} @tab Yes @tab @tab Debans @var{mask} or |
604 | @var{nick} from @var{channel}. You need to be a trusted user to deban |
605 | with a @var{mask}. |
6b59e728 |
606 | |
9efc3706 |
607 | @item @command{delserver} @tab @tab @tab Deletes server from server |
608 | list whose number in the server list is @var{server number}. |
6b59e728 |
609 | |
9efc3706 |
610 | @item @command{deluser} @tab @tab @tab Removes @var{nick} or |
611 | @var{mask} from the userlist. |
6b59e728 |
612 | |
9efc3706 |
613 | @item @command{delshit} @tab @tab @tab Removes @var{nick} or |
614 | @var{mask} from the shitlist. |
6b59e728 |
615 | |
9efc3706 |
616 | @item @command{deop} @tab Yes @tab @tab Deops @var{mask} or @var{nick} |
617 | on @var{channel}. |
6b59e728 |
618 | |
9efc3706 |
619 | @item @command{die} @tab @tab @tab Makes the bot stop immediately. |
6b59e728 |
620 | |
3fed2165 |
621 | |
6b59e728 |
622 | |
9efc3706 |
623 | @item @command{execute} @tab @tab @tab @strong{Only available if |
624 | scripting support is enabled} |
6b59e728 |
625 | |
9efc3706 |
626 | @item @command{help} @tab @tab @tab |
6b59e728 |
627 | |
9efc3706 |
628 | @item @command{ident} @tab @tab @tab Identifies you on the bot. Note |
629 | that you should not use this command in public @dots{} |
6b59e728 |
630 | |
9efc3706 |
631 | @item @command{invite} @tab Yes @tab @tab Invites @var{nick} on |
632 | @var{channel}. |
6b59e728 |
633 | |
9efc3706 |
634 | @item @command{join} @tab @tab @tab Makes the bot join @var{channel}. |
6b59e728 |
635 | |
9efc3706 |
636 | @item @command{keep} @tab Yes @tab @tab Sets the @var{modes} that the |
637 | bot will keep for @var{channel}. |
6b59e728 |
638 | |
9efc3706 |
639 | @item @command{kick} @tab Yes @tab @tab Kicks @var{mask} or @var{nick} |
640 | out of @var{channel}, because of @var{reason}. You need to be a |
641 | trusted user to use a @var{mask}. |
6b59e728 |
642 | |
9efc3706 |
643 | @item @command{kickban} @tab Yes @tab @tab Bans then kicks @var{mask} |
644 | or @var{nick} out of @var{channel}, because of @var{reason}. You need |
645 | to be a trusted user to use a @var{mask}. |
6b59e728 |
646 | |
9efc3706 |
647 | @item @command{load} @tab @tab @tab Reloads the userlist from disk. |
6b59e728 |
648 | |
9efc3706 |
649 | @item @command{loadscript} @tab @tab @tab @strong{Only available if |
650 | scripting support is enabled} |
6b59e728 |
651 | |
9efc3706 |
652 | @item @command{lock} @tab @tab @tab Locks topic on @var{channel}. |
6b59e728 |
653 | |
9efc3706 |
654 | @item @command{mode} @tab Yes @tab @tab Sends @var{mode string} as |
655 | mode for @var{channel}. |
6b59e728 |
656 | |
3fed2165 |
657 | |
6b59e728 |
658 | |
9efc3706 |
659 | @item @command{names} @tab Yes @tab @tab Shows the nicknames and |
660 | status of users on @var{channel}. |
6b59e728 |
661 | |
9efc3706 |
662 | @item @command{nextserver} @tab @tab @tab Makes the bot connect to the |
663 | next server in its server list. |
6b59e728 |
664 | |
9efc3706 |
665 | @item @command{nick} @tab @tab @tab Makes the bot use nickname @var{nick}. |
6b59e728 |
666 | |
9efc3706 |
667 | @item @command{nslookup} @tab @tab @tab Does a nameserver query about |
668 | @var{nick} host, @var{host} or @var{ip address}. |
6b59e728 |
669 | |
9efc3706 |
670 | @item @command{op} @tab Yes @tab @tab Ops @var{nick} on @var{channel}. |
6b59e728 |
671 | |
9efc3706 |
672 | @item @command{part} @tab Yes @tab @tab Makes the bot leave @var{channel}. |
6b59e728 |
673 | |
9efc3706 |
674 | @item @command{password} @tab @tab @tab Changes your password on the |
675 | bot. Use @code{NONE} as password if you want to clear it. Do not use this |
676 | command in public! |
6b59e728 |
677 | |
9efc3706 |
678 | @item @command{reconnect} @tab @tab @tab Makes the bot reconnect to |
679 | its current server. |
6b59e728 |
680 | |
9efc3706 |
681 | @item @command{rspymessage} @tab @tab @tab Removes you from the spy |
682 | list. |
6b59e728 |
683 | |
9efc3706 |
684 | @item @command{save} @tab @tab @tab Saves the userlist. |
6b59e728 |
685 | |
3fed2165 |
686 | |
6b59e728 |
687 | |
9efc3706 |
688 | @item @command{server} @tab @tab @tab Select the server to connect |
689 | to. @var{server number} is the number of the server in the serverlist. |
6b59e728 |
690 | |
9efc3706 |
691 | @item @command{serverlist} @tab @tab @tab Shows the bot's serverlist. |
6b59e728 |
692 | |
9efc3706 |
693 | @item @command{setfloodrate} @tab @tab @tab |
6b59e728 |
694 | |
9efc3706 |
695 | @item @command{setversion} @tab @tab @tab |
6b59e728 |
696 | |
9efc3706 |
697 | @item @command{shitlist} @tab @tab @tab Shows the bot's shitlist. |
6b59e728 |
698 | |
9efc3706 |
699 | @item @command{spylist} @tab @tab @tab Shows the bot's spylist. |
6b59e728 |
700 | |
9efc3706 |
701 | @item @command{spymessage} @tab @tab @tab Adds you to the spylist |
6b59e728 |
702 | |
9efc3706 |
703 | @item @command{stats} @tab Yes @tab @tab Gives @var{channel}'s statistics. |
6b59e728 |
704 | |
9efc3706 |
705 | @item @command{tban} @tab Yes @tab @tab Bans @var{nick} or @var{mask} |
706 | from @var{channel} for @var{time} seconds. |
6b59e728 |
707 | |
9efc3706 |
708 | @item @command{tkban} @tab Yes @tab @tab Bans @var{nick} or @var{mask} |
709 | from @var{channel} for @var{time} seconds, then kicks him/them because |
710 | of @var{reason}. |
6b59e728 |
711 | |
9efc3706 |
712 | @item @command{topic} @tab Yes @tab @tab If no @var{topic}is given, |
713 | prints @var{channel}'s topic. Otherwise, the bot will change |
714 | @var{channel}'s topic to @var{topic}. |
6b59e728 |
715 | |
9efc3706 |
716 | @item @command{unlock} @tab Yes @tab @tab Makes the bot unlock topic |
717 | on @var{channel} |
6b59e728 |
718 | |
9efc3706 |
719 | @item @command{userlist} @tab @tab @tab Shows the bot's userlist |
6b59e728 |
720 | |
9efc3706 |
721 | @item @command{who} @tab Yes @tab @tab Show your level on @var{channel} |
6b59e728 |
722 | |
9efc3706 |
723 | @item @command{whois} @tab Yes @tab @tab Shows information about |
724 | @var{nick} on @var{channel} |
6b59e728 |
725 | |
726 | @end multitable |
727 | |
e07b6b46 |
728 | @node Scripting, Concept Index, Using the Bot, Top |
31433d27 |
729 | @chapter Scripting |
730 | |
731 | Bobot++'s most powerful feature is its scripting system. You write |
732 | scripts using Guile Scheme. This manual does not cover how to use |
ad529fde |
733 | Guile or how to learn Scheme. @xref{Top, , Guile Reference Manual, |
734 | guile, The Guile Reference Manual}, for the Guile reference manual and |
31433d27 |
735 | @url{http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html} for |
736 | a good tutorial on Scheme. |
737 | |
439869bf |
738 | Note that in previous versions the scripting commands where in the |
739 | form @code{bot-@var{function}}. They are now in the form |
740 | @code{bot:@var{function}}. The old names are still available, but are |
c8f13c06 |
741 | deprecated and will be removed in Bobot++ 3.0. New commands are only |
742 | available with the @code{bot:} prefix. The command @command{perl -pi |
743 | -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to convert |
744 | your code to use the new functions. |
439869bf |
745 | |
ae97d6ec |
746 | @strong{NOTE}: All arguments to functions and hooks called by the bot |
747 | are strings unless otherwise specified. |
748 | |
439869bf |
749 | @menu |
750 | * Adding New Commands:: |
751 | * Hooks:: |
e07b6b46 |
752 | * Sending Messages:: |
91dddabd |
753 | * Misc Scripting Stuff:: |
3fed2165 |
754 | * Scheme Commands:: |
755 | * Query Functions:: |
439869bf |
756 | @end menu |
757 | |
758 | @node Adding New Commands, Hooks, Scripting, Scripting |
759 | @section Adding New Commands |
760 | |
02341ea9 |
761 | Adding a new command is simple. To register a new command use |
762 | @code{bot:addcommand}. |
9efc3706 |
763 | |
764 | @defun bot:addcommand name func needs-channel? num-of-args min-level |
765 | |
766 | The @var{name} is a string representing the name of the command being |
767 | added. @var{func} is a function accepting @var{num-of-args} |
768 | arguments. @var{needs-channel?} is a bool that is true if the function |
769 | needs the channel name as its first arg, and false otherwise. |
770 | @var{num-of-args} is the number of args @var{func} will take and must |
771 | be within zero (0) and twenty (20). @var{min-level} is one of the |
528799bd |
772 | @ref{User Levels}. A user must be at least a @var{min-level} user to |
773 | use the new command. None of the arguments are guaranteed to be |
774 | passed; if they aren't they are set to the empty string @code{""}. An |
775 | example of a new command would be: |
fed59248 |
776 | |
777 | @example |
e07b6b46 |
778 | (define (hello channel name) |
fed59248 |
779 | (if (string=? name "") |
e07b6b46 |
780 | (bot:say channel "Hello world!") |
781 | (bot:say channel (string-append "Hello " name "!"))) |
782 | |
783 | (bot:addcommand "hello" hello #t 2 0) |
fed59248 |
784 | @end example |
785 | |
e07b6b46 |
786 | This will display ``Hello World!'' if called as @kbd{!hello} and |
ae97d6ec |
787 | ``Hello World @var{USER}'' if called as @kbd{!hello @var{USER}}. |
9efc3706 |
788 | @end defun |
e07b6b46 |
789 | |
528799bd |
790 | @node Hooks, Sending Messages, Adding New Commands, Scripting |
439869bf |
791 | @section Hooks |
792 | |
e07b6b46 |
793 | @cindex Background on Hooks |
439869bf |
794 | Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII |
fed59248 |
795 | and tiny fugue (a MUD bot) hooks with a little bit of extra stuff |
02341ea9 |
796 | added in. A hook is called when a regular expression is matched |
797 | against a message sent to or by the bot. |
798 | |
799 | Bobot++ uses different hook types for each IRC message type, and also |
800 | includes a hook for accessing raw irc messages. Hooks are tagged with |
801 | a priority and a flag that specifies whether to call the next hook |
802 | that matches after calling the current one or to stop |
803 | processing. |
804 | |
805 | Hooks are processed from the highest to lowest priority, with |
806 | fallthrough hooks of equal priority to non-fallthrough hooks being |
807 | executed first. |
439869bf |
808 | |
809 | @menu |
810 | * Creating a Hook:: |
811 | * Hook Types:: |
812 | @end menu |
813 | |
814 | @node Creating a Hook, Hook Types, Hooks, Hooks |
815 | @subsection Creating a Hook |
816 | |
9efc3706 |
817 | To add a new hook you use the function @code{bot:addhook}. |
818 | |
819 | @defun bot:addhook type regex function [pri fall name] |
820 | @var{type} specifies the type of hook (the types of hooks are listed |
ae97d6ec |
821 | in @ref{Hook Types}). |
822 | |
823 | @var{regex} is a standard regular expression. If |
824 | @var{regex} is matched, @var{function} will be called. |
825 | |
826 | @var{function} will take a different number of args depending on the |
827 | hook type. |
828 | |
829 | @var{pri} specifies the priority of the hook---higher priority hooks |
830 | are executed first. This argument is optional and defaults to |
831 | @code{0}. |
832 | |
833 | @var{fall} is @code{#t} if the hook is a fallthrough hook and |
834 | @code{#f} is the hook is not a fallthrough hook. This arg is also |
835 | optional and defaults to @code{#t}. |
836 | |
837 | @var{name} is the optional name of the hook that defaults to |
838 | @code{"DEFAULT"}. If you set the name then you can have more than |
839 | one hook that matches the same regexp, as long as they have the same |
840 | name. E.g. in a log script you could have the regexps for the log |
841 | function all be @code{".*"} and set their names to @code{"log"} to |
842 | avoid a conflict with other hooks. |
9efc3706 |
843 | @end defun |
439869bf |
844 | |
845 | @node Hook Types, , Creating a Hook, Hooks |
846 | @subsection Hook Types |
847 | |
ae97d6ec |
848 | The following sections document the different hooks Bobot++ exposes. |
849 | |
850 | The general format of each hook description is as if it were a |
c99c411a |
851 | function to be defined, but these describe the function to be passed |
9efc3706 |
852 | to @code{bot:add-hook}. Do @emph{not} name your functions these |
853 | names. |
439869bf |
854 | |
9efc3706 |
855 | That said, here is the list of available hooks functions. |
856 | FIXME: write docs |
857 | |
ae97d6ec |
858 | @menu |
859 | * Received Message Hooks:: |
860 | * Sent Message Hooks:: |
861 | * DCC CHAT Hooks:: |
862 | * Miscellaneous Hooks:: |
863 | @end menu |
864 | |
865 | @node Received Message Hooks, Sent Message Hooks, Hook Types, Hook Types |
866 | @subsubsection Receieved Message Hooks |
867 | |
868 | The following hooks are triggered when a mesage is received by the bot. |
869 | |
9efc3706 |
870 | @defun hooks/action from to action |
ae97d6ec |
871 | This hook is triggered when someone performs an action. |
872 | |
873 | @var{from} is the nickname the person that performed the |
874 | action. |
875 | |
9efc3706 |
876 | @var{to} is the target of the action, which is either a channel or the |
ae97d6ec |
877 | Bot's nick if the user private messages the bot. |
439869bf |
878 | |
ae97d6ec |
879 | @var{action} is the text of the action. E.g. if someone did @samp{* |
880 | foobar does baz}, then @var{action} would be the string @code{"does |
881 | baz"}. |
882 | @end defun |
439869bf |
883 | |
9efc3706 |
884 | @defun hooks/nickname old-nick new-nick |
ae97d6ec |
885 | This hook is called when someone changes his nickname from |
9efc3706 |
886 | @var{old-nick} to @var{new-nick}. |
887 | @end defun |
439869bf |
888 | |
ae97d6ec |
889 | @defun hooks/signoff nick message |
890 | This hook is called when someone signs off of IRC. |
891 | |
892 | @var{nick} is the nickname of the person signing off. |
893 | |
894 | @var{message} is his quit message |
9efc3706 |
895 | @end defun |
439869bf |
896 | |
9efc3706 |
897 | @defun hooks/ctcp nick to command rest |
ae97d6ec |
898 | This hook is called when a CTCP request is received by the bot. |
899 | |
900 | @var{nick} is the nickname of the sender. |
901 | |
902 | @var{to} is the target of the CTCP request. This will either be a |
903 | channel the bot is in, or the nickname of the bot. |
904 | |
905 | @var{command} is the CTCP command issued. |
906 | |
907 | @var{rest} contains the arguments to the CTCP command. |
9efc3706 |
908 | @end defun |
439869bf |
909 | |
9efc3706 |
910 | @defun hooks/ctcp-reply nick command rest |
ae97d6ec |
911 | This hook is called when a CTCP REPLY is received. This occurs when |
912 | the bot has sent a CTCP request to another client. The CTCP REPLY is |
913 | always addressed to the bot directly. |
914 | |
915 | @var{nick} is the nickname of the person who replied. |
916 | |
917 | @var{command} is the command to which @var{nick} is replying. |
439869bf |
918 | |
ae97d6ec |
919 | @var{rest} contains the body of the reply. |
9efc3706 |
920 | @end defun |
439869bf |
921 | |
ae97d6ec |
922 | @defun hooks/disconnect server intentional |
923 | This is called when the bot is disconnected from a server. |
924 | |
925 | @var{server} is the hostname of the server from which the bot was |
926 | disconnected. |
927 | |
928 | @var{intentional} is a flag set to @code{#t} when the bot disonnected |
929 | from the server as the result of a command (issued by a user from IRC, |
930 | SIGHUP, or from a script), or @code{#f} when the bot disconnected from |
931 | the server unintentionally.. |
9efc3706 |
932 | @end defun |
439869bf |
933 | |
9efc3706 |
934 | @defun hooks/invite nick channel |
ae97d6ec |
935 | This hook is called when a user invited the bot to join a channel. |
936 | |
937 | @var{nick} is the nickname of the user who sent the invite. |
938 | |
939 | @var{channel} is the channel to which the bot was invited. |
9efc3706 |
940 | @end defun |
439869bf |
941 | |
9efc3706 |
942 | @defun hooks/join nick channel |
ae97d6ec |
943 | This is called when a user or the bot joins a channel. |
944 | |
945 | @var{nick} is the nickname of the user who joined @var{channel}. This |
946 | may be the bot's nickname (the IRC server sends the JOIN command back |
947 | to the the bot after it joins a channel). |
948 | |
949 | @var{channel} is the channel that was joined |
9efc3706 |
950 | @end defun |
439869bf |
951 | |
9efc3706 |
952 | @defun hooks/kick target from channel reason |
ae97d6ec |
953 | This hook is called when a user, including the bot, is kicked out of a |
954 | channel. |
955 | |
956 | @var{target} is the nick of the user who was kicked. This may be the |
957 | bot's nick. |
958 | |
959 | @var{from} is the nick of the user who issued the kick. This may also |
960 | be the bot's nick. |
961 | |
962 | @var{channel} is the channel the kick was issued in. |
963 | |
964 | @var{reason} is the reason the user was kicked. |
9efc3706 |
965 | @end defun |
439869bf |
966 | |
ae97d6ec |
967 | @defun hooks/part nick channel |
968 | This hook is called when a user parts a channel. |
969 | |
970 | @var{nick} is the user who parted the channel. This may be the bot. |
971 | |
972 | @var{channel} is the channel from which the user parted. |
9efc3706 |
973 | @end defun |
439869bf |
974 | |
ae97d6ec |
975 | @defun hooks/mode nick target modes |
976 | This hook is called when someone sets the modes of @var{target}. |
977 | |
978 | @var{nick} is the user who set the modes. This may be the bot. |
979 | |
980 | @var{target} is the target of the MODE command. This may be a |
981 | channel or a user. If it is a user, it may be the bot. |
982 | |
983 | @var{modes} is the MODE string. |
9efc3706 |
984 | @end defun |
439869bf |
985 | |
ae97d6ec |
986 | @defun hooks/message nick message |
987 | This hook is called when someone sends a private message to the bot. |
988 | |
989 | @var{nick} is the nickname of the user who sent the message. |
990 | |
991 | @var{message} is the message the user sent. |
9efc3706 |
992 | @end defun |
439869bf |
993 | |
9efc3706 |
994 | @defun hooks/notice nick message |
ae97d6ec |
995 | This hook is called when a user send a private notice to the bot. |
996 | |
997 | @var{nick} is the user who sent the notice. |
998 | |
999 | @var{message} is the message the user sent. |
9efc3706 |
1000 | @end defun |
439869bf |
1001 | |
ae97d6ec |
1002 | @defun hooks/public nick channel message |
1003 | This hook is called when a user sends a normal message to a channel. |
1004 | |
1005 | @var{nick} is the user who sent the message. |
1006 | |
1007 | @var{channel} is the channel to which the message was sent. |
1008 | |
1009 | @var{message} is the message that was sent. |
9efc3706 |
1010 | @end defun |
439869bf |
1011 | |
ae97d6ec |
1012 | @defun hooks/public-notice nick channel message |
1013 | This hook is called when a user send a notice to a channel. |
1014 | |
1015 | @var{nick} is the user who sent the notice. |
1016 | |
1017 | @var{channel} is the channel to which the notice was sent. |
1018 | |
1019 | @var{message} is the message that was sent. |
9efc3706 |
1020 | @end defun |
439869bf |
1021 | |
9efc3706 |
1022 | @defun hooks/raw raw-message |
ae97d6ec |
1023 | This hook is called every time a message is received. This matches on |
1024 | the raw message text and passes the hook function the raw IRC message. |
439869bf |
1025 | |
ae97d6ec |
1026 | @var{raw-message} is the raw IRC message. |
9efc3706 |
1027 | @end defun |
439869bf |
1028 | |
9efc3706 |
1029 | @defun hooks/topic nick channel new-topic |
ae97d6ec |
1030 | This hook is called when a user changes the topic in a channel. |
1031 | |
1032 | @var{nick} is the user who set the topic. This may be the bot. |
1033 | |
1034 | @var{channel} is the channel that's topic was changed. |
1035 | |
1036 | @var{new-topic} is the new topic. |
9efc3706 |
1037 | @end defun |
0b7a49e2 |
1038 | |
ae97d6ec |
1039 | @node Sent Message Hooks, DCC CHAT Hooks, Received Message Hooks, Hook Types |
1040 | @subsubsection Sent Message Hooks |
1041 | |
1042 | These hooks are called when the bot sends a message. @var{mynick} is |
1043 | always the bot's nick and will not be documented in each hook |
1044 | description. |
1045 | |
1046 | @defun hooks/send/public mynick channel message |
1047 | This hook is called when the bot sends a normal message to a channel. |
1048 | |
1049 | @var{channel} is the channel to which the bot sent the message. |
1050 | |
1051 | @var{message} is the message the bot sent. |
9efc3706 |
1052 | @end defun |
1053 | |
ae97d6ec |
1054 | @defun hooks/send/message mynick to message |
1055 | This hook is called when the bot sends a private message to a user. |
1056 | |
1057 | @var{to} is the nick of the user to whom the message was sent. |
1058 | |
1059 | @var{message} is the message that was sent. |
9efc3706 |
1060 | @end defun |
439869bf |
1061 | |
9efc3706 |
1062 | @defun hooks/send/action mynick to message |
ae97d6ec |
1063 | This hook is called when the bot sents an action to a channel or a |
1064 | user. |
1065 | |
1066 | @var{to} is the channel or nick of the user to which the action was |
1067 | sent. |
1068 | |
1069 | @var{message} is the text of the action. |
9efc3706 |
1070 | @end defun |
1071 | |
1072 | @defun hooks/send/ctcp mynick to command message |
ae97d6ec |
1073 | This hook is called when the bot sends a CTCP message @emph{other |
1074 | than} an ACTION to a channel or user. |
1075 | |
1076 | @var{to} is the channel or nick of the user to which the CTCP was |
1077 | sent. |
1078 | |
1079 | @var{command} is the CTCP command that was sent. |
1080 | |
1081 | @var{message} is a string containing the arguments to the CTCP command. |
9efc3706 |
1082 | @end defun |
1083 | |
528799bd |
1084 | @defun hooks/send/who who |
1085 | This is called when the bot sends a WHO message. The regex is matched |
1086 | on @var{who}, which is also passed as the only argument to your |
1087 | function. |
1088 | |
1089 | @var{who} is the channel or nick that was WHOed. |
1090 | @end defun |
1091 | |
1092 | @defun hooks/send/whois nick |
1093 | This is called when the bot sends a WHOIS message. The regex is |
1094 | matched on @var{nick}, which is also passed as the only argument to |
1095 | your function. |
1096 | |
1097 | @var{nick} is the nickname of the person who was WHOISed. |
1098 | @end defun |
1099 | |
ae97d6ec |
1100 | @node DCC CHAT Hooks, Miscellaneous Hooks, Sent Message Hooks, Hook Types |
1101 | @subsubsection DCC CHAT Hooks |
1102 | |
1103 | These hooks are called when a user initializes a DCC CHAT and when the |
1104 | bot receives messages from the user in a DCC CHAT. |
1105 | |
9efc3706 |
1106 | @defun hooks/dcc/chat-begin from |
ae97d6ec |
1107 | This hook is called when a user begins a DCC CHAT with the bot. |
9efc3706 |
1108 | @var{from} is the user's address in the form @samp{nick!user@@host}. |
1109 | @end defun |
1110 | |
133eff7a |
1111 | @defun hooks/dcc/chat-end address |
1112 | This hook is called when a DCC CHAT is purged after being idle for a |
1113 | while, or when the user closes the DCC CHAT. As such, you cannot write |
1114 | any more data to the DCC CHAT. |
1115 | |
1116 | @var{address} is the address (nick!user@@host) of the person on the |
1117 | other side of the DCC. |
1118 | @end defun |
1119 | |
9efc3706 |
1120 | @defun hooks/dcc/chat-message from message |
ae97d6ec |
1121 | This hook is called when a user sends a message to the bot through |
1122 | a DCC CHAT. |
1123 | |
1124 | @var{from} is the user's address in the form @samp{nick!user@@host}. |
1125 | |
1126 | @var{message} is the message the user sent to the bot. |
1127 | @end defun |
1128 | |
1129 | @node Miscellaneous Hooks, , DCC CHAT Hooks, Hook Types |
1130 | @subsubsection Miscellaneous Hooks |
1131 | |
1132 | @defun hooks/flood nick |
1133 | This hook is called when a user is detected flooding the bot. |
1134 | |
1135 | @var{nick} is the nickname of the user flooding the bot. |
1136 | @end defun |
1137 | |
1138 | @defun hooks/timer time |
1139 | This hook is called once a minute. The regex is @strong{not} used. |
1140 | |
1141 | @var{time} is the in zero-padded @code{hh:mm} format. |
9efc3706 |
1142 | @end defun |
439869bf |
1143 | |
528799bd |
1144 | |
1145 | @node Sending Messages, Misc Scripting Stuff, Hooks, Scripting |
e07b6b46 |
1146 | @section Sending Messages |
1147 | |
1148 | There are several types of messages you can send with Bobot++ from |
528799bd |
1149 | scripts. They are split into High and Low level message sending |
1150 | functions. Most bots will only use the high level functions, but the |
1151 | low level ones are provided for when a bot needs to do things like |
1152 | send raw IRC messages or CTCP commands. |
e07b6b46 |
1153 | |
1154 | @menu |
1155 | * High Level Message Functions:: |
1156 | * Low Level Message Functions:: |
1157 | @end menu |
1158 | |
1159 | @node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages |
1160 | @subsection ``High Level'' Message Functions |
1161 | |
9efc3706 |
1162 | @defun bot:say channel message |
1163 | Send a public or private @var{message} to @var{channel}. |
1164 | |
1165 | Sends a normal text message, as if a user had typed it in. The |
1166 | @var{dest} can be a nickname or a channel. |
1167 | @end defun |
1168 | |
1169 | @defun bot:action channel message |
1170 | Send an ``action'' type @var{message} to @var{channel} |
1171 | @end defun |
1172 | |
528799bd |
1173 | |
1174 | @defun bot:msg target message |
1175 | @defunx bot:say target message |
1176 | Send a public or private message to @var{target}. |
1177 | |
1178 | @var{target} may be a channel or a nickname. |
1179 | |
1180 | In versions of Bobot++ prior to 2.1.8 @code{bot:say} could only send |
1181 | to channels, and @code{bot:msg} could only send private messages to |
1182 | users. They are aliases of the same command now, but it may be worth |
1183 | using them as they used to for clarity. |
9efc3706 |
1184 | @end defun |
e07b6b46 |
1185 | |
5aec4622 |
1186 | @defun bot:notice target message |
1187 | Sends @var{message} as a NOTICE to @var{target}. @var{target} may be a |
528799bd |
1188 | user (nick) or a channel. |
5aec4622 |
1189 | @end defun |
1190 | |
e07b6b46 |
1191 | @node Low Level Message Functions, , High Level Message Functions, Sending Messages |
1192 | @subsection ``Low Level'' Message Functions |
1193 | |
9efc3706 |
1194 | @c Add a url for rfc2812 |
e07b6b46 |
1195 | The ``Low Level'' messaging functions allow you to do things like send |
1196 | CTCP messages. You probably want to read rfc 2812 and the CTCP spec |
1197 | before using these. If you have no idea what these do, read rfc 2812 |
1198 | (IRC Client Protocol) and CTCP spec. These functions all return |
9efc3706 |
1199 | @code{*unspecified*} always, so don't use the return value for |
1200 | anything. |
e07b6b46 |
1201 | |
c99c411a |
1202 | @defun bot:ctcp to command message |
1085f47c |
1203 | @var{to} is the target of your CTCP message, @var{command} is the |
1204 | CTCP command, and @var{message} is the message (or arguments) of the |
e07b6b46 |
1205 | command. Make sure to @code{bot:ctcp-quote} the message! |
9efc3706 |
1206 | @end defun |
e07b6b46 |
1207 | |
c99c411a |
1208 | @defun bot:ctcp-reply to command message |
1085f47c |
1209 | @var{to} is the target of your CTCP reply, @var{command} is the |
1210 | CTCP command, and @var{message} is the message (or arguments) of the |
672b7d4e |
1211 | command. Make sure to @code{bot:ctcp-quote} the message! |
1212 | |
1213 | This is used to reply to a ctcp that the bot has received. |
1214 | @end defun |
1215 | |
3fed2165 |
1216 | @node Misc Scripting Stuff, Scheme Commands, Sending Messages, Scripting |
91dddabd |
1217 | @section Misc. Scripting Stuff |
1218 | |
1219 | These are a few useful things that I thought people writing scripts |
1220 | might want to know. |
1221 | |
fed59248 |
1222 | @vindex exit-hook |
91dddabd |
1223 | If you want to execute code when the bot exits, just do |
1224 | @code{add-hook! bot:exit-hook @var{thunk}} where @var{thunk} is an |
1225 | argumentless procedure (a thunk). When the bot exits your thunk will |
1226 | be called. |
1227 | |
9efc3706 |
1228 | |
3fed2165 |
1229 | @menu |
1230 | * Scheme Commands:: |
1231 | * Query Functions:: |
1232 | @end menu |
1233 | |
1234 | @node Scheme Commands, Query Functions, Misc Scripting Stuff, Scripting |
1235 | @section Scheme Commands |
9efc3706 |
1236 | |
3fed2165 |
1237 | These scheme functions are the same as the commands. |
1238 | They allow you to execute bot commands from scheme scripts. |
9efc3706 |
1239 | |
1240 | @defun bot:adduser nick-or-mask cbannel-mask level prot auto-op |
1241 | Adds an user to the userlist, for a @code{nick!user@@host} matching the |
1242 | one given, on a channel matching the @var{channelMask} given. |
1243 | |
1244 | @multitable @columnfractions 0.33 0.33 0.33 |
1245 | @item The @var{level} can be: @tab The @var{prot} can be: @tab The @var{auto-op} can be: |
1246 | @item 0 - No level @tab 0 - No protection @tab 0 - No auto-op |
1247 | @item 1 - User @tab 1 - No ban @tab 1 - Op on join |
1248 | @item 2 - Trusted User @tab 2 - No kick @tab |
1249 | @item 3 - Friend @tab 3 - No deop @tab |
1250 | @item 4 - Master @tab @tab |
1251 | @end multitable |
1252 | |
1253 | @end defun |
1254 | |
1255 | @c (3, 4, 0) |
1256 | @defun bot:addserver hostname ip-address [portnumber] |
1257 | Adds the server specified by @var{hostname} or @var{ip-address} to |
1258 | the server list. |
1259 | @end defun |
1260 | |
1261 | @c (3, 2, 0) |
1262 | @defun bot:addshit nick-or-mask channel-mask level [time reason] |
1263 | Adds an user to the shitlist, for a nick!user@@host matching the |
1264 | one given, on a channel matching the @var{channelMask} given. |
1265 | |
1266 | @display |
1267 | The @var{level} can be: |
1268 | 0 - No shit |
1269 | 1 - No op |
1270 | 2 - Kick and Ban on join |
1271 | 3 - Kick and Ban on join, no deban |
1272 | @end display |
1273 | |
1274 | @end defun |
1275 | |
1276 | @c (2, 0, 0) |
1277 | @defun bot:ban channel mask-or-nick |
1278 | Bans @var{mask} or @var{nick} from @var{channel}. You need to be a trusted |
1279 | user to ban with a @var{mask}. |
1280 | @end defun |
1281 | |
1282 | @c (2, 0, 0) |
1283 | @defun bot:change-command-level nick-or-mask channel-mask new-level |
1284 | Gives @var{nick} or @var{mask} level @var{new-level} on channel(s) |
1285 | @var{channel-mask}. Note that you can not change level for someone |
1286 | whose level is greater than yours, and that you can not give a |
1287 | level greater than yours. |
1288 | @end defun |
1289 | |
1290 | @c (1, 0, 0) |
1291 | @defun bot:cycle channel |
1292 | Makes the bot leave and join @var{channel}. |
1293 | @end defun |
1294 | |
1295 | @c (2, 0, 0) |
1296 | @defun bot:deban channel mask-or-nick |
1297 | Debans @var{mask} or @var{nick} from @var{channel}. You need to be a trusted |
1298 | user to deban with a @var{mask}. |
1299 | @end defun |
1300 | |
1301 | @c (1, 0, 0) |
1302 | @defun bot:delserver server-number |
1303 | Deletes server from server list whose number in the server list |
1304 | is @var{server-number} |
1305 | @end defun |
1306 | |
1307 | @c (2, 0, 0) |
1308 | @defun bot:deluser nick-or-mask channel-mask |
1309 | Removes @var{nick} or @var{mask} from the userlist. |
1310 | @end defun |
1311 | |
1312 | @c (2, 0, 0) |
1313 | @defun bot:delshit nick-or-mask channel-mask |
1314 | Removes @var{nick} or @var{mask} from the shitlist. |
1315 | @end defun |
1316 | |
1317 | @c (2, 0, 0) |
1318 | @defun bot:deop channel mask-or-nick |
1319 | Deops @var{mask} or @var{nick} on @var{channel}. |
1320 | @end defun |
1321 | |
1322 | @c (1, 0, 0) |
1323 | @defun bot:die reason |
1324 | Makes the bot stop immediately. |
1325 | @end defun |
1326 | |
1327 | @c (1, 0, 0) |
1328 | @defun bot:do ? |
1329 | @end defun |
1330 | |
1331 | @c (2, 0, 0) |
1332 | @defun bot:invite channel nick |
1333 | Invites @var{nick} on @var{channel}. |
1334 | @end defun |
1335 | |
1336 | @c (1, 1, 0) |
1337 | @defun bot:join channel |
1338 | Makes the bot join @var{channel}. |
1339 | @end defun |
1340 | |
1341 | @c (2, 0, 0) |
1342 | @defun bot:keep channel modes |
1343 | Sets the @var{modes} that the bot will keep for @var{channel}. |
1344 | See also STATS. |
1345 | @end defun |
1346 | |
1347 | @c (2, 1, 0) |
1348 | @defun bot:kick channel mask-or-nick [reason] |
1349 | Kicks @var{mask} or @var{nick} out of @var{channel}, because of @var{reason}. |
1350 | You need to be a trusted user to use a @var{mask}. |
1351 | @end defun |
1352 | |
1353 | @c (2, 1, 0) |
1354 | @defun bot:kickban channel mask-or-nick [reason] |
1355 | Bans then kicks @var{mask} or @var{nick} out of @var{channel}, |
1356 | because of @var{reason}. |
1357 | You need to be a trusted user to use a @var{mask}. |
1358 | @end defun |
1359 | |
1360 | @c (1, 0, 0) |
1361 | @defun bot:lock channel |
1362 | Locks topic on @var{channel}. |
1363 | @end defun |
1364 | |
9efc3706 |
1365 | @c (2, 0, 0) |
1366 | @defun bot:mode channel mode-string |
1367 | Sends @var{mode-string} as mode for @var{channel}. |
1368 | @end defun |
1369 | |
1370 | @c (0, 0, 0) |
1371 | @defun bot:nextserver |
1372 | Makes the bot connect to the next server in its server list. |
1373 | @end defun |
1374 | |
1375 | @c (1, 0, 0) |
1376 | @defun bot:nick nick |
1377 | Makes the bot use nickname @var{nick}. |
1378 | @end defun |
1379 | |
1380 | @c (2, 0, 0) |
1381 | @defun bot:op channel nick |
1382 | Ops @var{nick} on @var{channel}. |
1383 | @end defun |
1384 | |
1385 | @c (1, 0, 0) |
1386 | @defun bot:part channel |
1387 | Makes the bot leave @var{channel}. |
1388 | @end defun |
1389 | |
1390 | @c (0, 0, 0) |
1391 | @defun bot:reconnect |
1392 | Makes the bot reconnect to its current server. |
1393 | @end defun |
1394 | |
1395 | @c (1, 0, 0) |
1396 | @defun bot:server server-number |
1397 | Select the server to connect to. @var{server-number} is the number of |
1398 | the server in the serverlist. |
1399 | @end defun |
1400 | |
1401 | @c (1, 0, 0) |
1402 | @defun bot:setfloodrate ? |
1403 | @end defun |
1404 | |
1405 | @c (1, 0, 0) |
1406 | @defun bot:setversion ? |
1407 | @end defun |
1408 | |
1409 | @c (3, 0, 0) |
1410 | @defun bot:tban channel nick-or-mask time |
1411 | Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds. |
1412 | @end defun |
1413 | |
1414 | @c (3, 1, 0) |
1415 | @defun bot:tkban channel nick-or-mask time [reason] |
1416 | Bans @var{nick} or @var{mask} from @var{channel} for @var{time} seconds, |
1417 | then kicks him/them because of @var{reason}. |
1418 | @end defun |
1419 | |
1420 | @c (2, 0, 0) |
1421 | @defun bot:topic channel topic |
1422 | If no @var{topic} is given, prints @var{channel}'s topic. Otherwise, |
1423 | the bot will change @var{channel}'s topic to @var{topic}. |
1424 | @end defun |
1425 | |
1426 | @defun bot:unlock channel |
1427 | Makes the bot unlock topic on @var{channel}. |
1428 | @end defun |
1429 | |
c6e7af05 |
1430 | @defun bot:who target |
1431 | Sends a WHO command to @var{target}. @var{target} may be either a |
1432 | channel or a user. |
1433 | @end defun |
1434 | |
1435 | @defun bot:whois nick |
1436 | Sends a WHOIS command to @var{nick}. @var{nick} @strong{must} be a |
1437 | nickname, you cannot send a WHOIS to a channel. |
1438 | @end defun |
1439 | |
3fed2165 |
1440 | |
1441 | |
1442 | @c (1, 0, 0) |
1443 | @defun bot:delcommand |
1444 | [ Probably deletes a command added with @code{bot:addcommand} ? ] |
1445 | @end defun |
1446 | |
1447 | |
1448 | |
1449 | @node Query Functions, , Scheme Commands, Scripting |
1450 | @section Query Functions |
1451 | |
1452 | @quotation |
1453 | [ I didn't know where to put any of these, so I just stuck them in |
1454 | here. |
1455 | |
1456 | There probably needs to be several sections added, like dealing with |
1457 | users (kicking, added, etc), dealing with the bot (channels, nickname |
1458 | of the bot, etc), server issues (serverlist), useful tools (nslookup, |
1459 | whois), and do on. ] |
1460 | @end quotation |
1461 | |
1462 | These functions allow scripts to get various bits of information. |
1463 | |
1464 | @c (0, 0, 0) |
1465 | @defun bot:logport |
1466 | [ Probably returns the log port? ] |
1467 | @end defun |
1468 | |
9efc3706 |
1469 | @c (0, 0, 0) |
1470 | @defun bot:getnickname |
1471 | [ Gets the bot's nickname? ] |
1472 | @end defun |
1473 | |
1474 | @c (0, 0, 0) |
1475 | @defun bot:getserver |
1476 | @end defun |
1477 | |
1478 | @c (0, 0, 0) |
1479 | @defun bot:getserverlist |
1480 | @end defun |
1481 | |
1482 | @c (0, 0, 0) |
1483 | @defun bot:flush |
1484 | [ Flushes the socket to the server? ] |
1485 | @end defun |
1486 | |
1487 | @c (0, 0, 0) |
1488 | @defun bot:flushport |
1489 | [ Flushes the log port? ] |
1490 | @end defun |
1491 | |
1492 | @c (1, 0, 0) |
1493 | @defun bot:random ? |
1494 | [ Returns a random number? What range? Why? ] |
1495 | @end defun |
1496 | |
9efc3706 |
1497 | @c (2, 0, 0) |
1498 | @defun bot:addtimer ? ? |
1499 | @end defun |
1500 | |
1501 | @c (1, 0, 0) |
1502 | @defun bot:deltimer ? |
1503 | @end defun |
1504 | |
1505 | @c (2, 0, 0) |
1506 | @defun bot:dcc-chat-send ? ? |
1507 | @end defun |
1508 | |
1509 | @quotation |
1510 | [ And what about the stuff defined in @file{bobot-utils.scm} ? I just |
1511 | added it here so it could be somewhere. There should also be a |
1512 | section dealing with modules. How to use them. What module scripts |
1513 | are in. What module bobot++ provided primites are in. And so on. ] |
1514 | @end quotation |
1515 | |
1516 | @defun bot:log . messages |
1517 | Write as many @var{messages} as you want to the log. If the arg is a |
1518 | thunk it will be executed and it's output will be written to the log. |
1519 | @end defun |
1520 | |
1521 | @defun bot:load file |
1522 | @end defun |
1523 | |
1524 | @defun bot:load-module module-spec |
1525 | @end defun |
1526 | |
1527 | @defun bot:use-module module-spec |
1528 | @end defun |
1529 | |
1530 | @defun bot:match-not-channel regex |
3fed2165 |
1531 | @code{bot:match-not-channel} adds a prefix regex to your @var{regex} so it |
9efc3706 |
1532 | doesn't match the sender or channel in a PUBLIC message |
1533 | @end defun |
1534 | |
1535 | @defun bot:match-to-me regex |
3fed2165 |
1536 | @code{bot:match-to-me} matches text that was addressed to the bot with a |
9efc3706 |
1537 | ':', ',', or nothing after the bot name. |
1538 | @end defun |
1539 | |
1540 | @defun bot:sent-to-me? message |
1541 | @end defun |
1542 | |
1543 | @defun bot:ctcp-quote message |
1544 | Returns the CTCP quoted message |
1545 | Input @emph{MUST NOT} contain the trailing @code{\r\n} |
1546 | (it is added by the message sending code). |
1547 | @end defun |
1548 | |
1549 | |
1550 | @defvar %bot:loadpath |
1551 | @end defvar |
1552 | |
1553 | @defun %bot:load-extensions |
1554 | @end defun |
1555 | |
1556 | |
1557 | |
31433d27 |
1558 | @node Concept Index, Function Index, Scripting, Top |
1559 | @unnumbered Concept Index |
1560 | @printindex cp |
1561 | |
1562 | @node Function Index, Variable Index, Concept Index, Top |
1563 | @unnumbered Function Index |
1564 | @printindex fn |
1565 | |
1566 | @node Variable Index, , Function Index, Top |
1567 | @unnumbered Variable Index |
1568 | @printindex vr |
91dddabd |
1569 | |
1570 | @bye |