Controlling when the bot replies.
[supybook.git] / index.txt
blob9b146af005f7055707da09717e18d2cc594400e5
1 Supybook
2 ========
3 Heikki Hokkanen <hoxu@users.sf.net>
4 {date}
5 {revision}
7 == Preface ==
9 NOTE: At the time of this writing, Supybot version is 0.83.3. If you are using a newer (or even older) version, keep that in mind.
11 === What is this document? ===
13 This document is a handbook for http://supybot.com/[Supybot], the IRC (http://en.wikipedia.org/wiki/Internet_Relay_Chat[Internet Relay Chat]) bot written in Python.
15 === Motivation behind this document ===
17 Some time ago I started needing a bot for various purposes. The bot would have to be able to take care of auto-opping and similar "traditional" channel duties. This made me think of http://oer.equnet.org/[Oer], an old but very nice bot. However, I also wanted to have factoid functionality similar to blootbot/infobot, without having to run multiple bots. That was when I arrived at Supybot once again. This time I decided to give it a closer look.
19 My experience of the documentation was lacking though. I longed for something similar to http://oer.equnet.org/um.php[Oer's User Manual] that provides a quick references for basic administrator tasks and so forth. Alas, I could not find such document.
21 I figured I could as well wrap up such a handbook while learning to use the bot myself. Hopefully someone finds reading this document as useful as writing it was.
23 === Conventions used in this document ===
25 `command <name> [value]`::
26         A command that takes `name` as a required parameter and `value` as an optional parameter.
28 `command <nick...>`::
29         A command that takes one or more parameters.
31 [green]#Plugin#::
32         A plugin name
34 === This document is Free ===
36 This document is Free (TM) as defined by the http://www.fsf.org/[Free Software Foundation], more specifically, this document is available under the terms of http://www.gnu.org/licenses/gpl-3.0.txt[GNU General Public License version 3 (GPLv3)].
38 === How to give feedback ===
40 If you spot an error, have suggestions or just want to tell me how much you love/hate the document, send e-mail to mailto:hoxu@users.sf.net[]. Prefix the Subject with `[supybook]`.
42 == Getting started ==
44 === Identifying to the bot ===
46 After running supybot-wizard and starting the bot, connect to the same IRC network it is on, and /query it. You can identify with the `identify <name> <password>` command. You can check the bot's idea of who you are with the `whoami` command.
48 === Accessing the online help ===
50 Most commands on the bot have a short online help available. You can use `list` to list loaded plugins, and `list <plugin>` to list commands in those plugins. `help [plugin] <command>` can be used to access the command help. Use `more` to read long messages from the bot.
52 Help for configuration items can be accessed with the `config help <key>` command.
54 == Understanding supybot's peculiarities ==
56 Supybot has a couple of features that sets it apart from more traditional bots. More specifically, nested commands, plugin framework (even the basic functionality is implemented using plugins), and capabilities. This section covers some basic information about Supybot. Feel free to skip it, but come back later if you run into something you don't understand.
58 === Nested commands ===
60 Supybot allows nested commands, in other words, you can pass the result of a command to another command as a parameter. What does this allow then, though, apart from the obvious bragging rights? For example, if you want to restore a configuration entry to the default value, you can type:
62 `config reply.withNickPrefix [config default reply.withNickPrefix]`
64 Obviously, that wasn't very neat. They could've included a `config reset <key>` command instead, for example. But I'm sure you can figure out *something* useful to do with this.
66 === Plugins ===
68 Pretty much everything in Supybot is a plugin. Most commands you use belong to a plugin. If two plugins provide the same command, then you need to prefix the command with the plugin name. For example, the `ignore list` command yields the following output:
70 .output
71 ----
72 Error: The command "ignore list" is available in the Admin and Channel plugins.
73 Please specify the plugin whose command you wish to call by using its name as a command before "ignore list".
74 ----
76 Thus, you need to either use `admin ignore list` or `channel ignore list` command. That is, unless you define which plugin is the default one using the `defaultplugin [\--remove] <command> [plugin]` command provided in the [green]#Owner# plugin.
78 The `list` command ([green]#Plugin#) can be used to list loaded plugins. You can prevent some plugins from showing in the list with the command:
80 `config plugins.<plugin>.public False`
82 `list`::
83         List currently loaded plugins, excluding the ones set non-public.
85 `list \--private`::
86         List loaded plugins that are set to non-public.
88 `list <plugin>`::
89         List commands provided by the given plugin.
91 `load [\--deprecated] <plugin>`::
92         Load a plugin. Supybot looks for plugins in directories listed in `config conf.supybot.directories.plugins`.
94 `unload <plugin>`::
95         Unloads a plugin. The [green]#Owner# plugin cannot be unloaded.
97 === Configuration ===
99 Most of Supybot configuration is done online using the [green]#Config# plugin. This excludes things such as granting the owner capability (must be done by modifying the files).
101 There are two types of configuration items: global and channel-specific. The latter are actually no different from the global ones, except that they can be set for channels as well. This means you can have a global default which is overridden for specific channels.
103 Configuration items are hierarchical. The "root" item is `supybot`, which can be omitted. Configs for plugins live under their own key, `supybot.plugins`, or shortly, `plugins`.
105 `config <name> [value]`::
106         Get the current value of `name`, or set it to `value` if provided.
108 `config channel [channel] <name> [value]`::
109         Ditto, but for channel configs.
111 `config default <name>`::
112         Get the default value of `name`. This does not change the value. No, there is no command to reset an item to default value. You need to use `config <name> [config default <name>]` for that.
114 `config export <filename>`::
115         Export non-confidential parts of configuration to a file for debugging purposes.
117 `config help <name>`::
118         Show help for a configuration item.
120 `config list <group>`::
121         List configuration items in `group`. Subgroups are prefixed with '@', channel-specific items with '#'.
123 `config reload`::
124         Reloads configuration. Mostly useful if you've had to modify the files by hand.
126 `config search <word>`::
127         Show configuration items matching `word`.
129 === Capabilities ===
131 Many traditional IRC bots manage permissions of users using flags. Some network services in fact, do, too. Each user can have various flags on each channel. The flags can mean auto-op, op, use of !ban command and so forth. On side of those, there are often global user flags that entitle the user to full access, global auto-op, etc. Some bots also support channel flags that determine what bot functionality is available on the channel.
133 Supybot does not have any flags. Instead, the permissions are managed using 'capabilities'. There are two kinds of capabilities: `user capabilities` and `channel capabilities`.
135 'User capabilities' are checked first when a user tries to run a command. If the user has an 'anticapability' for the command (eg. `-command`, `-Plugin.command`) or the Plugin (`-Plugin`), it won't be run.
137 Next, if the command was run on the channel, the 'channel capabilities' are checked. The logic is same as above, but the checked capabilities are prefixed with `#channel,`, for example `#channel,-Plugin.command`.
139 There are some special capabilities recognized by Supybot:
141 `owner`::
142         For bot owners: the people who have "physical" access to the bot and its files. This cannot be granted online; the 'conf/users.conf' file must be edited by hand followed by `reload`.
144 `admin`::
145         For bot administrators. Users with this capability can manage global bot properties, make the bot join new channels and so forth. However, they can't do channel administration which is reserved for ops.
147 `#channel,op`::
148         Channel ops can execute channel-related commands.
150 `trusted`::
151         Allow user to run commands that can potentially crash the bot, or cause denial of service on the system it's running on.
153 == Administrative tasks ==
155 === Networks ===
157 Related plugins: [green]#Network, Services#.
159 ==== Adding a network ====
161 `network connect <network> [<host[:port]>]`
163 ==== Reconnecting ====
165 `reconnect [network] [quit message]`.
167 ==== Disconnecting ====
169 `network disconnect [network] [message]`
171 ==== Listing networks ====
173 `networks`
175 .output
176 ----
177 freenode: wolfe.freenode.net and ircnet: irc.elisa.fi
178 ----
180 ==== Adding more servers ====
182 Once you've added a network with the initial server, you can add more servers:
184 `config networks.<network>.servers [config networks.<network>.servers] server:6667`
186 ==== Listing network servers ====
188 `config networks.<network>.servers`
190 .output
191 ----
192 chat.freenode.net:6667
193 ----
195 ==== Services: NickServ ====
197 You can make Supybot identify itself to the network NickServ after it has connected.
199 `config plugins.Services.noJoinsUntilIdentified True`::
200         Settings this is useful on Freenode and other networks who change the user mask after identifying to NickServ. In my experience this seems to be a tad buggy, so I don't recommend enabling it unless really needed.
202 `config plugins.Services.NickServ NickServ`::
203         Tell the bot what name NickServ can be found under.
205 `services password <nick> [password]`::
206         Can be used to set or remove NickServ password.
208         NOTE: Password removal did not work for me on Supybot 0.83.3
209         
210 `services identify`::
211         Identifies the bot to NickServ with the current nick. You don't need to give this command after the bot has been set up; it will identify when connecting to the network automatically.
213 ==== Services: ChanServ ====
215 You can make Supybot request op after joining a channel on a network with ChanServ.
217 `config plugins.Services.ChanServ ChanServ`::
218         Tell the bot what name ChanServ can be found under.
220 `config plugins.Services.ChanServ.op <on|off>`::
221         Set the default for all channels. This will be used unless a channel-specific config overrides it.
223 `config channel [channel] plugins.services.ChanServ.op <on|off>`::
224         Set to request op on the given `channel`.
226 Voice and half-op (on networks supporting it) can be used similarly.
228 === Channels ===
230 Related plugins: [green]#Channel#.
232 NOTE: Commands in this section (such as adding/removing channels) work in the current network, eg. the one you are messaging the bot in. The commands also accept a `[channel]` parameter which is needed only when the command is written in private.
234 NOTE: If you want to /msg the bot in one network, while having the command apply in another network, you can use the `network command <network> <command> [params]` command. The reply comes in the other network if you are there as well.
236 ==== Adding a new channel ====
238 A new channel is added by messaging the bot in the same network with `join <channel> [key]` command.
240 ==== Listing channels ====
242 `channels`
244 NOTE: This only works in private, to prevent knowledge of top secret channels from falling to wrong hands.
246 You can list channels in another network with `config networks.<network>.channels`.
248 ==== Removing a channel ====
250 `part [channel] [reason]`
252 ==== Modifying channel config ====
254 `config channel [channel] <name> <value>`
256 ==== Setting the key ====
258 `channel key [channel] [key]` can be used to set or clear the channel key.
260 ==== Setting the limit ====
262 `channel limit [channel] [limit]` sets or clears the channel limit.
264 ==== Channel commands ====
266 Channel ops can use the following commands to control the channel via the bot, assuming it is opped.
268 `op [channel] [nick...]`::
269         Ops the given nicks (or you if none) on the channel.
271 `deop [channel] [nick...]`::
272         Ditto, but deops.
274 `voice [channel] [nick...]`::
275         Voices the given nicks (or you if none) on the channel.
277 `devoice [channel] [nick...]`::
278         Ditto, but devoices.
280 `kban [channel] [\--{exact,nick,user,host}] <nick> [seconds] [reason]`::
281         Bans and kicks the given nick from the channel. If `seconds` is specified and is not 0, the ban will expire after that time.
283 `mode [channel] <mode> [params]`::
284         Set channel mode. This can be used to change any channel modes, making the commands below redundant aliases.
286 `moderate [channel]`::
287         Set +m. This is not enforced by the bot, so any channel op can remove it.
289 `unmoderate [channel]`::
290         Set -m.
292 `topic lock [channel]`::
293         Set +t. Not enforced, so any channel op can remove it.
295 `topic unlock [channel]`::
296         Set -t.
298 `alert [channel] <text>`::
299         Sends `text` to all users on the channel with op capability.
301 `cycle [channel]`::
302         Make the bot part and join the channel. Mostly useful to test whether auto-ops from other bots/users work for the bot.
304 ==== Maintaining the ban list ====
306 `ban add [channel] <nick|hostmask> [expires]`::
307         Add ban for given nick or hostmask on the channel. If nick is given, the full hostmask is banned. `expires` when gives, expires the ban after so many seconds.
309 `ban list [channel]`::
310         List bans with their expire times.
312 `ban remove [channel] <hostmask>`::
313         Removes the ban on given `hostmask`.
315 NOTE: Users matching the ban list are not automatically kicked off the channel. See the `kban` command in the previous section to kick and ban a user.
317 ==== Maintaining the ignore list ====
319 `channel ignore add [channel] <nick|hostmask> [expires]`
321 `channel ignore list [channel]`
323 `channel ignore remove [channel] <hostmask>`
325 NOTE: There is also a global ignore list.
327 ==== Listing channel nicks ====
329 `channel nicks [channel]`
331 ==== Topic operations ====
333 Related plugins: [green]#Topic#.
335 Supybot allows elaborate manipulation of the channel topic.
337 http://supybot.com/documentation/plugins/topic
339 ==== Logging ====
341 Logging of channels is provided by the [green]#ChannelLogger# plugin. Various channel-specific configuration items are provided, see `config list plugins.ChannelLogger`.
343 By default logs will go into logs/ChannelLogger/<network>/<channel>/<channel>.log and will be rotated when the default "%d-%a-%Y" (eg. 06-Sat-2008) timestamp rotates. See http://docs.python.org/lib/module-time.html[the python documentation for strftime] for the formatting characters.
345 NOTE: The logs of [green]#ChannelLogger# cannot be searched online. However, other plugins provide some searching functionality. See <<searching-history,Searching the history>>.
347 ==== Auto-ops & voices ====
349 Auto-opping is provided by the [green]#AutoMode# plugin.
351 ==== Seen ====
353 The [green]#Seen# plugin keeps track of last channel/nick/user activity. Most typical use is asking the bot when a given user was last seen chatting on a channel.
355 `seen any [channel] [\--user <user>] [nick]`::
356         Lists any activity given `nick` or `user` was doing on the channel. If no `nick` or `user` is given, returns the last activity on the channel, regardless of who it was from.
358 `seen last [channel]`:
359         Last line said on the channel.
361 `seen [channel] <nick>`::
362         Last time a `nick` was seen on a channel and what it said.
364 `seen user [channel] <user>`:
365         Ditto, except use a user name, disregarding what nick the said user had.
367 === Users ===
369 Related plugins: [green]#Users#.
371 Supybot users are global: they are visible across networks. This means the same username/password and hostmasks will work in all networks the bot is on.
373 Users are recognized either by matching hostmasks, or after manually identifying to the bot. In secure mode, the user must both match a hostmask and identify to the bot (`uset set secure [password] <True|False>`).
375 NOTE: If users knowing each others' nicks is an issue, they could come up with different aliases when registering to the bot. The bot username does not have to match the nick of the user.
377 ==== Adding a new user ====
379 `user register <name> <password>`
381 ==== Manipulating hostmasks ====
383 `user hostmask add` - add your current hostmask. Obviously this makes only sense after identify.
385 `user hostmask add [name] [hostmask] [password]` - add hostmask for another user. If not owner, password must be given.
387 `user hostmask remove <name> <hostmask> [password]`
389 NOTE: There is no way to add network-specific hostmasks.
391 ==== Listing users ====
393 `user list [glob]` - list registered users. Note that the list of users is global across networks.
395 ==== Deleting users ====
397 `user unregister <name> [password]`
399 ==== Changing password ====
401 `user set password <user> <old password> <new password>`.
403 ==== Renaming a user ====
405 `user changename <name> <new name> [password]`
407 Users can change their name themselves.
409 ==== Manipulating user capabilities ====
411 TODO
413 === General bot maintenance ===
415 Related plugins: [green]#Admin, Config#.
417 ==== Setting nickname & alternative nick ====
419 `admin nick <newnick>`::
420         Change nick to `newnick`.
422 `config nick`::
423         Default nick.
425 `config nick.alternates`::
426         Space-separated list of alternate nicks, %s refers to nick.
428 NOTE: It is not possible to have a different nick in different networks.
430 ==== Setting ident ====
432 `config ident <newident>`::
433         Sets the bot's ident (`nick!ident@host`).
435 ==== Setting ircname ====
437 `config user [ircname]`::
438         Sets the bot's ircname/realname to `ircname`. If left empty, defaults to 'Supybot 0.83.3' for example.
440 ==== Setting command prefix / controlling when the bot replies ====
442 Like most other bots, the bot can be addressed by its nickname, or a command prefix character (any or many of `~!@#$%^&*()_-+=[{}]\|'";:,<.>/?`). For special (braindead?) purposes the bot can also be made assume that all lines are addressed to it.
444 `config reply.whenAddressedBy.chars`::
445         List of characters the bot will recognize as addressing, besides the nick of the bot.
447 `config channel [channel] reply.whenAddressedBy.chars`::
448         Ditto, but for a specific channel.
450 `config reply.whenNotAddressed`::
451         Assume everyone wants to talk to the bot, eg. treat all messages as if addressed to the bot. This does not imply `reply.WhenNotCommand False` which you should set as well.
453 `config reply.whenNotCommand`::
454         Whether to reply when addressed with an invalid command.
456 ==== Listing and searching settings ====
458 `config search <word>` - list config items containing word.
460 `config <name>` - show config value for name.
462 `config <name> <value>` - set config value for name.
464 === Owner commands ===
466 `owner announce <text>` - send `text` to all channels the bot is on.
468 `owner ircquote <raw>` - send `raw` as-is to the server. You need to know your way around http://www.faqs.org/rfcs/rfc1459.html[RFC1459] pretty well to use this.
470 == User commands ==
472 [[searching-history]]
473 === Searching the history ===
475 `url last [channel] [\--{from,with,without,near,proto} value] [\--nolimit]`::
476         Find last URL (or all with `\--nolimit`) matching given criteria. From matches nick, with(out) part of the URL, near rest of the line where the URL was, and proto matches the protocol (https, ftp, etc). In case of multiple URLs, the newest is listed first. Multiple criterias can be given.
478         NOTE: This command lists only the URLs, not nick or what message the URLs were part of. No date is shown either.
480 `last [\--from,in,on,with,without,regexp} value] [\--nolimit]`::
481         Find messages matching given criteria. From matches nick, in matches channel, on matches network, with(out) matches part of the message, regexp matches messages that are included by the regular expression. Also see `config protocols.irc.maxHistoryLength`.
483 === Useful plugins ===
485 ==== Dict ====
487 [green]#Dict# provides dictionary functionality using dict.org. You can also use a local dictd server.
489 `dict [dictionary] <word>`::
490         Show dictionary entry for `word`, from `dictionary` if provided. If `plugins.Dict.default` is set, use the specified dictionary instead of all.
492 `dictionaries`::
493         List dictionaries available on the used server.
495 `dict random`::
496         Show a random dictionary from available dictionaries.
498 `config plugins.Dict.server [server]`::
499         The dictd server to be used, default is dict.org.
501 `config plugins.Dict.default [dictionary]`::
502         Channel-specific default dictionary for `dict` command. `*` means to use all dictionaries. `wn` is a good default if english words are mostly looked up.
504 ==== Later ====
506 This is a nick-based replacement for NoteServ and the likes. Simply put, you give the bot a note to deliver to a nick (or wildcard) the next time it sees a matching nick. In other words, this can be used to deliver messages to people who are not registered to the bot. Naturally that is not a very safe method of communicating.
508 `notes [nick]`::
509         List nicks that have notes queued, or the notes queued for `nick` if given.
511 `later tell <nick> <text>`::
512         Queues `text` to be sent to first matching `nick` when seen. Nick can contain wildcards, eg. `foo*`.
514 `config plugins.Later.maximum`::
515         How many messages can be queued per nick at maximum, default is 0 = no limit.
517 `config plugins.Later.private`::
518         Whether to send notes in private or on the channel where the recipient is seen.
520 === Games ===
522 Plugins: [green]#Games, Nickometer, Quote, QuoteGrabs#.
524 == Caveats ==
526 This is a list of issues I have not yet figured out how to do, or there simply isn't a way.
528 - How to enforce channel modes (eg. force +ns-t for example)
529 - How to delete config items
530 - How to delete channels / networks
531 - Ban add does not seem to work on Freenode
532 - No global ban list
533 - No way to delete a network
534 - Incomplete multi-network support
535         * Capabilities are not network/channel -specific, but channel-specific. If channel by same name exists in two networks, the users have same capabilities on both
536         * No way to add network-specific hostmasks
537         * Not possible for the bot to have different nick in different networks
538 - There is no command to reboot the bot; it must be done from the shell
540 == Tips ==
542 === How to emulate blootbot CMDs using MoobotFactoids ===
544 [,yellow]#Thanks to Tobias Rosenqvist for the tip!#
546 We try to make a command factoid, like we are used to with blootbot:
548 ----
549 <user> cmdtest is <action> gives $1 "(an apple|a pear)"
550 <bot> Ok.
551 ----
553 Then we test it:
555 ----
556 <user> cmdtest someone
557 ----
559 But it doesn't work.
560 However, the factoid works:
562 ----
563 <user> cmdtest
564   * bot gives $1 an apple
565 ----
567 The Moobotfactoids plugin in supybot doesn't handle arguments, (yet)
568 unfortunately, so you need to do it another way.
569 Use the Moobotfactoids to do the random part(s):
571 ----
572 <user> fruits is <reply> "(an apple|an orange|a banana|a pear)"
573 <bot> Ok.
574 ----
576 Then use an alias to do the command, with arguments (the "action" command
577 is found in the Reply plugin), here you also see a use of a nested command:
579 ----
580 <user> alias add givefruit action gives [fruits] to $1
581 <bot> Ok.
582 <user> givefruit someone
583  * bot gives a pear to someone
584 ----
586 === Tidier bot replies ===
588 I don't personally like the default Supybot replies: I hate the nick prefix and the way too verbose 'The operation succeeded.'.
590 Fortunately there are plenty of settings to configure how Supybot replies. These can be listed with `config reply` and `config replies`.
592 The `reply` items determine how Supybot acts, and `replies` contains some messages it uses. I prefer `config reply.withNickPrefix False` and `config replies.success OK` myself.
594 .reply
595 *#inPrivate*:: Whether to reply in private to commands given on channel.
597 *#requireChannelCommandsToBeSentInChannel*:: -
599 *#showSimpleSyntax*:: Whether to be extra helpful when a user fails syntax of a command.
601 *#whenNotAddressed*:: Assume everyone wants to talk to the bot, eg. treat all messages as if addressed to the bot. This does not imply `reply.WhenNotCommand False` which you should set as well.
603 *#whenNotCommand*:: Whether to reply when addressed with an invalid command.
605 *#withNickPrefix*:: Whether to prefix the reply with the nick of the user who gave the command.
607 *#withNotice*:: Whether to use notices instead of regular messages.
609 @#mores
611 @error
613 @format
615 @whenAddressedBy
617 maximumLength
619 oneToOne
621 #withNoticeWhenPrivate