Include revision if provided.
[supybook.git] / index.txt
blobba422ceced8161d6f20fa5fac53c6a28eca80f16
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 === Motivation behind this document ===
13 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.
15 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.
17 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.
19 === Conventions used in this document ===
21 `command <name> [value]`::
22         A command that takes `name` as a required parameter and `value` as an optional parameter.
24 `command <nick...>`::
25         A command that takes one or more parameters.
27 [green]#Plugin#::
28         A plugin name
30 === This document is Free ===
32 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)].
34 === How to give feedback ===
36 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]`.
38 == Getting started ==
40 === Identifying to the bot ===
42 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.
44 === Accessing the online help ===
46 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.
48 Help for configuration items can be accessed with the `config help <key>` command.
50 == Understanding supybot's peculiarities ==
52 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.
54 === Nested commands ===
56 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:
58 `config reply.withNickPrefix [config default reply.withNickPrefix]`
60 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.
62 === Plugins ===
64 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:
66 .output
67 ----
68 Error: The command "ignore list" is available in the Admin and Channel plugins.
69 Please specify the plugin whose command you wish to call by using its name as a command before "ignore list".
70 ----
72 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.
74 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:
76 `config plugins.<plugin>.public False`
78 `list`::
79         List currently loaded plugins, excluding the ones set non-public.
81 `list \--private`::
82         List loaded plugins that are set to non-public.
84 `list <plugin>`::
85         List commands provided by the given plugin.
87 `load [\--deprecated] <plugin>`::
88         Load a plugin. Supybot looks for plugins in directories listed in `config conf.supybot.directories.plugins`.
90 `unload <plugin>`::
91         Unloads a plugin. The [green]#Owner# plugin cannot be unloaded.
93 === Configuration ===
95 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).
97 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.
99 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`.
101 `config <name> [value]`::
102         Get the current value of `name`, or set it to `value` if provided.
104 `config channel [channel] <name> [value]`::
105         Ditto, but for channel configs.
107 `config default <name>`::
108         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.
110 `config export <filename>`::
111         Export non-confidential parts of configuration to a file for debugging purposes.
113 `config help <name>`::
114         Show help for a configuration item.
116 `config list <group>`::
117         List configuration items in `group`. Subgroups are prefixed with '@', channel-specific items with '#'.
119 `config reload`::
120         Reloads configuration. Mostly useful if you've had to modify the files by hand.
122 `config search <word>`::
123         Show configuration items matching `word`.
125 === Capabilities ===
127 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.
129 Supybot does not have any flags. Instead, the permissions are managed using 'capabilities'. There are two kinds of capabilities: `user capabilities` and `channel capabilities`.
131 '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.
133 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`.
135 There are some special capabilities recognized by Supybot:
137 `owner`::
138         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`.
140 `admin`::
141         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.
143 `#channel,op`::
144         Channel ops can execute channel-related commands.
146 `trusted`::
147         Allow user to run commands that can potentially crash the bot, or cause denial of service on the system it's running on.
149 == Administrative tasks ==
151 === Networks ===
153 Related plugins: [green]#Network, Services#.
155 ==== Adding a network ====
157 `network connect <network> [<host[:port]>]` ?
159 ==== Reconnecting ====
161 `reconnect [network] [quit message]`.
163 ==== Disconnecting ====
165 `network disconnect [network] [message]`
167 ==== Listing networks ====
169 `networks`
171 .output
172 ----
173 freenode: wolfe.freenode.net and ircnet: irc.elisa.fi
174 ----
176 ==== Adding more servers ====
178 Once you've added a network with the initial server, you can add more servers:
180 `config networks.<network>.servers [config networks.<network>.servers] server:6667`
182 ==== Listing network servers ====
184 `config networks.<network>.servers`
186 .output
187 ----
188 chat.freenode.net:6667
189 ----
191 ==== Services: NickServ ====
193 You can make Supybot identify itself to the network NickServ after it has connected.
195 `config plugins.Services.noJoinsUntilIdentified True`::
196         Settings this is useful on Freenode and other networks who change the user mask after identifying to NickServ.
198 `config plugins.Services.NickServ NickServ`::
199         Tell the bot what name NickServ can be found under.
201 `services password <nick> [password]`::
202         Can be used to set or remove NickServ password.
204         NOTE: Password removal did not work for me on Supybot 0.83.3
205         
206 `services identify`::
207         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.
209 ==== Services: ChanServ ====
211 You can make Supybot request op after joining a channel on a network with ChanServ.
213 `config plugins.Services.ChanServ ChanServ`::
214         Tell the bot what name ChanServ can be found under.
216 `config plugins.Services.ChanServ.op <on|off>`::
217         Set the default for all channels. This will be used unless a channel-specific config overrides it.
219 `config channel [channel] plugins.services.ChanServ.op <on|off>`::
220         Set to request op on the given `channel`.
222 Voice and half-op (on networks supporting it) can be used similarly.
224 === Channels ===
226 Related plugins: [green]#Channel#.
228 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.
230 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.
232 ==== Adding a new channel ====
234 A new channel is added by messaging the bot in the same network with `join <channel> [key]` command.
236 ==== Listing channels ====
238 `channels`
240 NOTE: This only works in private, to prevent knowledge of top secret channels from falling to wrong hands.
242 You can list channels in another network with `config networks.<network>.channels`.
244 ==== Removing a channel ====
246 `part [channel] [reason]`
248 ==== Modifying channel config ====
250 `config channel [channel] <name> <value>`
252 ==== Setting the key ====
254 `channel key [channel] [key]` can be used to set or clear the channel key.
256 ==== Setting the limit ====
258 `channel limit [channel] [limit]` sets or clears the channel limit.
260 ==== Channel commands ====
262 Channel ops can use the following commands to control the channel via the bot, assuming it is opped.
264 `op [channel] [nick...]`::
265         Ops the given nicks (or you if none) on the channel.
267 `deop [channel] [nick...]`::
268         Ditto, but deops.
270 `voice [channel] [nick...]`::
271         Voices the given nicks (or you if none) on the channel.
273 `devoice [channel] [nick...]`::
274         Ditto, but devoices.
276 `kban [channel] [\--{exact,nick,user,host}] <nick> [seconds] [reason]`::
277         Bans and kicks the given nick from the channel. If `seconds` is specified and is not 0, the ban will expire after that time.
279 `mode [channel] <mode> [params]`::
280         Set channel mode. This can be used to change any channel modes, making the commands below redundant aliases.
282 `moderate [channel]`::
283         Set +m. This is not enforced by the bot, so any channel op can remove it.
285 `unmoderate [channel]`::
286         Set -m.
288 `topic lock [channel]`::
289         Set +t. Not enforced, so any channel op can remove it.
291 `topic unlock [channel]`::
292         Set -t.
294 `alert [channel] <text>`::
295         Sends `text` to all users on the channel with op capability.
297 `cycle [channel]`::
298         Make the bot part and join the channel. Mostly useful to test whether auto-ops from other bots/users work for the bot.
300 ==== Maintaining the ban list ====
302 `ban add [channel] <nick|hostmask> [expires]`::
303         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.
305 `ban list [channel]`::
306         List bans with their expire times.
308 `ban remove [channel] <hostmask>`::
309         Removes the ban on given `hostmask`.
311 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.
313 ==== Maintaining the ignore list ====
315 `channel ignore add [channel] <nick|hostmask> [expires]`
317 `channel ignore list [channel]`
319 `channel ignore remove [channel] <hostmask>`
321 NOTE: There is also a global ignore list.
323 ==== Listing channel nicks ====
325 `channel nicks [channel]`
327 ==== Topic operations ====
329 Related plugins: [green]#Topic#.
331 Supybot allows elaborate manipulation of the channel topic.
333 http://supybot.com/documentation/plugins/topic
335 ==== Logging ====
337 Logging of channels is provided by the [green]#ChannelLogger# plugin. Various channel-specific configuration items are provided, see `config list plugins.ChannelLogger`.
339 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.
341 ===== Searching the log =====
343 The logs of [green]#ChannelLogger# cannot be searched online. However, other plugins provide some searching functionality.
345 `url last [channel] [\--{from,with,without,near,proto} value] [\--nolimit]`::
346         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.
348         NOTE: This command lists only the URLs, not nick or what message the URLs were part of. No date is shown either.
350 `last [\--from,in,on,with,without,regexp} value] [\--nolimit]`::
351         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`.
353 ==== Auto-ops & voices ====
355 Auto-opping is provided by the [green]#AutoMode# plugin.
357 ==== Seen ====
359 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.
361 `seen any [channel] [\--user <user>] [nick]`::
362         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.
364 `seen last [channel]`:
365         Last line said on the channel.
367 `seen [channel] <nick>`::
368         Last time a `nick` was seen on a channel and what it said.
370 `seen user [channel] <user>`:
371         Ditto, except use a user name, disregarding what nick the said user had.
373 === Users ===
375 Related plugins: [green]#Users#.
377 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.
379 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>`).
381 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.
383 ==== Adding a new user ====
385 `user register <name> <password>`
387 ==== Manipulating hostmasks ====
389 `user hostmask add` - add your current hostmask. Obviously this makes only sense after identify.
391 `user hostmask add [name] [hostmask] [password]` - add hostmask for another user. If not owner, password must be given.
393 `user hostmask remove <name> <hostmask> [password]`
395 NOTE: There is no way to add network-specific hostmasks.
397 ==== Listing users ====
399 `user list [glob]` - list registered users. Note that the list of users is global across networks.
401 ==== Deleting users ====
403 `user unregister <name> [password]`
405 ==== Changing password ====
407 `user set password <user> <old password> <new password>`.
409 ==== Renaming a user ====
411 `user changename <name> <new name> [password]`
413 Users can change their name themselves.
415 ==== Manipulating user capabilities ====
417 TODO
419 === General bot maintenance ===
421 Related plugins: [green]#Admin, Config#.
423 ==== Setting nickname & alternative nick ====
425 `admin nick <newnick>`
427 `config nick`
429 `config nick.alternates` - space-separated list of alternate nicks, %s refers to nick.
431 TODO: different nick in different networks?
433 ==== Setting ident ====
435 `config ident <newident>`::
436         Sets the bot's ident (`nick!ident@host`).
438 ==== Setting ircname ====
440 `config user [ircname]`::
441         Sets the bot's ircname/realname to `ircname`. If left empty, defaults to 'Supybot 0.83.3' for example.
443 ==== Setting command prefix / controlling when the bot replies ====
445 TODO: config search nick & config search prefix contain related stuff.
447 ==== Listing and searching settings ====
449 `config search <word>` - list config items containing word.
451 `config <name>` - show config value for name.
453 `config <name> <value>` - set config value for name.
455 === Owner commands ===
457 `owner announce <text>` - send `text` to all channels the bot is on.
459 `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.
461 == User commands ==
463 === Useful plugins ===
465 ==== Dict ====
467 [green]#Dict# provides dictionary functionality using dict.org. You can also use a local dictd server.
469 `dict [dictionary] <word>`::
470         Show dictionary entry for `word`, from `dictionary` if provided. If `plugins.Dict.default` is set, use the specified dictionary instead of all.
472 `dictionaries`::
473         List dictionaries available on the used server.
475 `dict random`::
476         Show a random dictionary from available dictionaries.
478 `config plugins.Dict.server [server]`::
479         The dictd server to be used, default is dict.org.
481 `config plugins.Dict.default [dictionary]`::
482         Channel-specific default dictionary for `dict` command. `*` means to use all dictionaries. `wn` is a good default if english words are mostly looked up.
484 === Games ===
486 Plugins: [green]#Games, Nickometer, Quote, QuoteGrabs#.
488 == Caveats ==
490 This is a list of issues I have not yet figured out how to do, or there simply isn't a way.
492 - How to enforce channel modes (eg. force +ns-t for example)
493 - How to delete config items
494 - How to delete channels / networks
495 - Ban add does not seem to work on Freenode
496 - No global ban list
497 - No way to delete a network
498 - Incomplete multi-network support
499         * 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
500         * No way to add network-specific hostmasks
502 == Tips ==
504 === How to emulate blootbot CMDs using MoobotFactoids ===
506 [,yellow]#Thanks to Tobias Rosenqvist for the tip!#
508 We try to make a command factoid, like we are used to with blootbot:
510 ----
511 <user> cmdtest is <action> gives $1 "(an apple|a pear)"
512 <bot> Ok.
513 ----
515 Then we test it:
517 ----
518 <user> cmdtest someone
519 ----
521 But it doesn't work.
522 However, the factoid works:
524 ----
525 <user> cmdtest
526   * bot gives $1 an apple
527 ----
529 The Moobotfactoids plugin in supybot doesn't handle arguments, (yet)
530 unfortunately, so you need to do it another way.
531 Use the Moobotfactoids to do the random part(s):
533 ----
534 <user> fruits is <reply> "(an apple|an orange|a banana|a pear)"
535 <bot> Ok.
536 ----
538 Then use an alias to do the command, with arguments (the "action" command
539 is found in the Reply plugin), here you also see a use of a nested command:
541 ----
542 <user> alias add givefruit action gives [fruits] to $1
543 <bot> Ok.
544 <user> givefruit someone
545  * bot gives a pear to someone
546 ----
548 === Tidier bot replies ===
550 I don't personally like the default Supybot replies: I hate the nick prefix and the way too verbose 'The operation succeeded.'.
552 Fortunately there are plenty of settings to configure how Supybot replies. These can be listed with `config reply` and `config replies`.
554 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.
556 .reply
557 *#inPrivate*:: Whether to reply in private to commands given on channel.
559 *#requireChannelCommandsToBeSentInChannel*:: -
561 *#showSimpleSyntax*:: Whether to be extra helpful when a user fails syntax of a command.
563 *#whenNotAddressed*:: Assume everyone wants to talk to the bot, eg. treat all messages as if addressed to the bot. This does not imply `replyWhenNotCommand False` which you should set as well.
565 *#whenNotCommand*:: Whether to reply when addressed with an invalid command.
567 *#withNickPrefix*:: Whether to prefix the reply with the nick of the user who gave the command.
569 *#withNotice*:: Whether to use notices instead of regular messages.
571 @#mores
573 @error
575 @format
577 @whenAddressedBy
579 maximumLength
581 oneToOne
583 #withNoticeWhenPrivate