2         m o z i l l a |.| o r g   | | 
 
   3     _ __ ___   ___ ___| |__   ___ | |_ 
 
   4    | '_ ` _ \ / _ \_  / '_ \ / _ \| __|
 
   5    | | | | | | (_) / /| |_) | (_) | |_ 
 
   6    |_| |_| |_|\___/___|_.__/ \___/ \__|
 
   7    ====================================
 
  13 You will need the following programs and libraries to run mozbot2:
 
  22 These packages may have additional requirements of their own.
 
  24 In order to do anything useful with mozbot2, you will need some Bot
 
  25 Modules. Several are included in this distribution, and they may have
 
  26 requirements above and beyond those given above.
 
  28 Once you have set up all the packages on which mozbot2 depends, make
 
  33 This is needed since mozbot2 will occasionally attempt to restart
 
  34 itself (e.g. if its source code is changed).
 
  36 Then, simply run mozbot.pl:
 
  40 Currently, you MUST run mozbot from the directory in which mozbot.pl
 
  41 is placed. This may be changed in a future version.
 
  47 Since mozbot interacts with the outside world, do not run it as a
 
  50 In addition, since mozbot calls external programs (currently perl and
 
  51 wget, possibly others in future versions) make sure that none of the
 
  52 directories on your path are writable by untrusted users! (e.g., do
 
  53 not put /tmp into your path!)
 
  55 Make sure that '.' is not in your path! This is a security risk in a
 
  56 situation like this, and perl will rightly refuse to execute external
 
  57 programs (like wget, used to get remote URIs for many functions) if
 
  60 Do not run the bot straight into a public channel on the first run!
 
  62 One important reason not to load the bot straight into a public
 
  63 channel on the first run is that until it has been properly
 
  64 configured, it will have a well defined username and password to
 
  65 access all its admin functions. Thus a malicious user could hijack the
 
  66 bot the moment it joined the channel.
 
  68 If this is a serious problem for you (e.g., your users are of a
 
  69 particularly high calibre and are doing regular polls of the /who
 
  70 command to see if any bots join) then use another server, such as one
 
  71 that you control, on localhost!
 
  73 See the "Administration" section for instructions on how to change the
 
  74 administration password (important!).
 
  76 Note: Passwords are printed in clear text on the console and in the
 
  77 log files. Secure them accordingly. Of course, IRC is an inherently
 
  78 insecure protocol anyway, and any machine between your IRC client's
 
  79 and your bot's, going through the IRC network's servers, will have
 
  80 access to the passwords. For this reason, change them often, and don't
 
  81 use passwords that you use for important things here.
 
  83 The default setting is for mozbot to run with taint checking
 
  84 enabled. I *STRONGLY* recommend not changing this.
 
  90 When you start up mozbot for the first time, it will prompt you for
 
  91 the following information:
 
  94       What machine you want the bot to connect to. At the moment,
 
  95       mozbot only supports connecting to a single server at a time. It
 
  96       would require a *significant* amount of work to change this.
 
  99       What port to connect to on the IRC server. Typically, this will
 
 100       be 6667 or therabouts.
 
 103       If your server has a password, enter it here. If there isn't one
 
 104       (and this is almost certainly the case) then just hit enter.
 
 107       What channels the bot should initially connect to. It is
 
 108       recommended that this just be a bot channel or a test channel,
 
 109       for example #mozbot, since running a bot for the first time
 
 110       before it is known to be ready is a bad idea. You can enter more
 
 111       than one channel, just hit enter after each one (leave a blank
 
 112       line when you have finished). (To make mozbot join a keyed
 
 113       channel, you must first add the channel's key to the
 
 114       'channelKeys' variable. To do this, the bot will have to be on
 
 115       IRC first, so don't worry about it for now.)
 
 117    5. Your e-mail address.
 
 118       In case of great difficulties, mozbot may try to e-mail you. If
 
 119       this happens, it will use the e-mail address you gave here. This
 
 120       only happens if (a) it absolutely cannot connect to the server
 
 121       you gave it, or (b) it cannot find a nick that is not in use.
 
 124       The name of the SMTP server it should try to talk with in order
 
 125       to send you mail. If you type in an invalid server name, it will
 
 126       just fail to send mail and instead will complain bitterly to its
 
 130       Some nicks for IRC. For example, 'mozbot'. It is customary to
 
 131       clearly mark the bot as being non-human, for example by putting
 
 132       'bot' in the name. You should enter several possibilities
 
 133       here. Hit enter after each one. Leave a blank line to finish.
 
 135 Once the bot is running, there are many other things that can be
 
 136 configured with it. See "variables".
 
 138 Note. The bot will treat all channel names as lowercase to avoid case
 
 145 Normally, mozbot will output its complaints to the console
 
 146 (stdout). If you run mozbot in an xterm or screen session, you can
 
 147 therefore easily keep track of what is going on.
 
 149 It will also continuously log output to ~/logs/$0.$$.log, where $0 is
 
 150 the file name and $$ is the PID. You may wish to set up a cron job to
 
 151 prune this file on a regular basis, it gets LARGE. However, it can
 
 152 sometimes be the only way to track down how your system was
 
 153 compromised if it turns out that mozbot has a security flaw.
 
 155 Control over the logging is currently not available. This may change
 
 158 Note that when the bot forks and then outputs a message, which happens
 
 159 occasionally, it will therefore use a new log file for the forked
 
 160 process. This should only happen when something bad happens,
 
 161 e.g. something forces the bot to restart or the bot forks and then the
 
 162 child enters a bad state.
 
 164 Note. Authentication passwords will be displayed in cleartext on the
 
 165 console and in the log files.
 
 171 Once the bot is active and on the IRC server, it starts to listen to
 
 172 all messages seen on any channels on which it is present, and all
 
 173 messages sent to it using /msg.
 
 175 Your first task should be to change the admin password. To do this,
 
 176 authenticate yourself using the "auth" command. The default username
 
 177 is "admin", and the default password is "password". If the bot is
 
 178 called "mozbot", then the command to authenticate would be as follows:
 
 180    /msg mozbot auth admin password
 
 182 The bot should respond with "Hi admin!".
 
 184 Now create yourself an account by adding a username/password pair to
 
 185 the bot. You do this with the "newuser" command. Next, you should
 
 186 bless this new user, making it a bot administrator. This is done using
 
 189    /msg mozbot newuser <username> <password> <password>
 
 190    /msg mozbot bless <username>
 
 192 Now authenticate yourself again, as the new user:
 
 194    /msg mozbot auth <username> <password>
 
 196 The moment you authenticate as the new admin, the default admin
 
 199 You are now in a position to add the modules you want and to put the
 
 200 bot in the channels you want it in.
 
 202 To load modules is easy.
 
 204    /msg mozbot load module
 
 206 ...where "module" is a module name, such as "HelloWorld" (note that
 
 207 the ".bm" extension is not included). By default, the General,
 
 208 Greeting, Infobot and Parrot modules are loaded. The General module
 
 209 provides the 'help' command and responds to CTCP VERSION messages. The
 
 210 Greeting module responds to greetings and generally tries to be
 
 211 friendly. The Infobot module provides information storage and
 
 212 retrieval functions. The Parrot module lets an admin control the bot
 
 215 By default, modules will be enabled in all channels. See the
 
 216 "variables" section below to change this.
 
 222 If the bot goes mad and starts flooding a channel -- e.g., if someone
 
 223 keeps asking it for information -- then authenticate and then send it
 
 224 the following message:
 
 226    /msg mozbot shutup please
 
 228 It should respond within a few seconds. You can authenticate while it
 
 229 is speaking, that's not a problem.
 
 235 For information on changing variables on the fly, use the "vars"
 
 240 Each module has several variables that you can change. You can see
 
 241 what they are by typing:
 
 243    /msg mozbot vars module
 
 245 ...where module is the module in question. These always include
 
 246 "Admin" and "General". Admin provides the commands such as "auth",
 
 247 "newuser", "password", and provides additional commands to admins,
 
 248 such as "shutdown", "cycle", "leave", "restart", and so on. "General"
 
 249 provides the "help" command to everyone.
 
 251 The main variables are:
 
 253    channels -- which channels the module should listen in, and which
 
 254    channels the module should send announcements to. Must be in
 
 257    channelKeys -- a mapping of (lowercase) channel names to keys. It
 
 258    is assumed that any channel without an entry in this variable has
 
 259    no key. For example, to tell mozbot that the key for channel
 
 260    #channel is 'password', you would use:
 
 262       /msg mozbot vars Admin channelKeys '+|#channel|password'
 
 264    autojoin -- whether (1) or not (0) the module should automatically
 
 265    add a new channel to its "channels" list when the bot joins a new
 
 266    channel. If this is not enabled, then you will have to add new
 
 267    channels to the "channels" list of this module each time.
 
 269    channelsBlocked -- channels that will not be autojoined, so if a
 
 270    module has been disabled, it won't rejoin the channel if the bot is
 
 271    kicked then reinvited.
 
 273    denyusers -- user@host regexp masks of users that should be
 
 274    completely ignored (for this module). The regexp will be placed
 
 275    between "^" and "$" modifiers, so do not include them, and *do*
 
 276    include everything required to make the whole user@host mask match.
 
 278    allowusers -- identical in usage to denyusers, but checked first to
 
 279    override it. So to give access to everyone but a few people, leave
 
 280    allowusers blank and add some masks to denyusers, but to give
 
 281    access to only a few people, add their user@host masks to
 
 282    allowusers, and add ".*" to denyusers.
 
 284 In addition, other modules may have extra variables.
 
 286 The admin variable has quite a few variables, including all those that
 
 287 are prompted for during initial startup. The interesting ones are:
 
 289    currentnick -- the nick. This can be changed on the fly.
 
 291    server, port, password -- the server and port to connect to, and
 
 292    the server password to use. If you change these and then cycle the
 
 293    bot (/msg mozbot cycle) then the bot will change servers without
 
 296    localAddr -- if you don't seem to be able to establish a
 
 297    connection, but it works fine with other software, then you should
 
 298    try setting the localAddr variable to your IP address. Technically,
 
 299    this variable sets which interface to use to form the outgoing
 
 300    connection. (This is to work around a limitation of Net::IRC.) 
 
 301    Typically you would set this variable directly in the configuration
 
 302    file, by adding a line that says "localAddr=10.11.12.13" or
 
 303    whatever your IP address is.
 
 305    simpleIRCNameServer -- if the value of this variable equals the
 
 306    name of the server, then the IRC Name sent to the server will be
 
 307    simplified so that it doesn't include the URI of the mozbot help
 
 308    files. This is usually dealt with automatically, but if you are
 
 309    having troubles connecting, you could try setting it. (It is set to
 
 310    the name of the server so that if you change servers, by default
 
 311    mozbot will use a complete IRC Name again.)
 
 313    username -- if this variable has a true value, then the bot will
 
 314    use its value as its IRC username. By default, the bot uses
 
 315    "pid-1234" as the username, where "1234" is the bot's process ID. 
 
 316    This can cause problems on networks or with BNCs that require a
 
 317    valid and accurate ident, in which case this variable can provide a
 
 318    solution. (You can also set this variable by entering
 
 319    "username=blah" into the configuration file, where blah is the
 
 320    username you want to use.)
 
 322    channels -- unlike other modules, the channels variable for the
 
 323    Admin module actually controls which channels the bot itself
 
 324    appears in. The preferred method for controlling this is using
 
 325    /invite and /kick or "join" and "part", though (since editing the
 
 326    list directly will probably require a cycle of the bot to take
 
 329    admins -- the administrators. See "Administration" above.
 
 331    allowInviting -- this controls whether the /invite IRC command will
 
 334    allowChannelAdmin -- this controls whether or not the bot will
 
 335    accept admin commands that are given in a channel or not. In any
 
 336    case, the "auth" command is never accepted in a channel.
 
 338    files -- this is a list of files whose timestamps are monitored to
 
 339    decide if the source code has changed. If it is established that
 
 340    any of these files have changed while the bot is running, then the
 
 341    bot will shutdown and restart itself. Modules are dealt with
 
 342    separately, and need not be listed here. (And when modules change,
 
 343    the whole bot is not restarted, only the module.)
 
 345    sourceCodeCheckDelay -- number of seconds between checks of the bot
 
 346    and module sources. Note that changes will only take effect after
 
 347    the previous timer has passed, so changing it from 3600 (an hour)
 
 348    to 10 (10 seconds) may not be of much immediate use. In these
 
 349    cases, setting the variable to the new value then cycling the bot
 
 352    ignoredUsers -- a list of regular expressions that are matched
 
 353    against the user@host strings of everything that is said. If a user
 
 354    matches one of the entires in this list, then that user will be
 
 355    completely ignored. (^ and $ symbols are implied at the start and
 
 356    end of this regular expression.) Use this sparingly. It will stop
 
 357    the user's statements from having _any_ effect on the bot,
 
 358    including in any statistic-collecting modules, etc. If you just
 
 359    want to block a user from certain modules, add a regular expression
 
 360    to the 'denyusers' variable of those modules.
 
 362       >mozbot< vars Admin ignoredUsers '+root@.*'
 
 363       *** moron (root@example.org) has joined #mozbot
 
 365       * you watch the tumbleweed roll on by
 
 367    ignoredTargets -- when someone says something to someone who
 
 368    matches one of the regular expressions in this list, the line will
 
 369    be ignored as if the person saying it was banned with ignoreUsers. 
 
 370    This is useful when you have other bots in the channel, and don't
 
 371    want the mozbot to respond in place of the other bots (e.g. with an
 
 372    auto-helping Infobot module). Note: It is safe to user a regular
 
 373    expression that matches the mozbot bot's name; it will always
 
 374    respond to messages to itself (as well as messages that are sent
 
 375    via /msg) irrespective of this setting.
 
 377       <user> foobot: what is green?
 
 378       <foobot> user: green is good.
 
 379       <mozbot> user: green is good.
 
 380       <user> mozbot: vars Admin ignoredTargets '+.*bot[0-9]*'
 
 381       <mozbot> Variable 'ignoredTargets' in module 'Admin' has changed.
 
 382       <user> foobot: what is green?
 
 383       <foobot> user: green is good.
 
 384       * user patpats mozbot
 
 386 Changes to variables are usually immediately recorded in the
 
 387 configuration file and will be saved for the next time the bot is
 
 390 There are three types of editable variables: scalars, arrays of
 
 391 scalars, and hashes of scalars.
 
 393 Scalars are easy, and lists are explained by the bot quite well, just
 
 394 try to set a list and it will tell you if you are doing something
 
 397 To add a value to a hash, there is a more complex syntax. For example,
 
 398 to add a new site to the list of sites that the RDF module monitors,
 
 399 use the following command:
 
 401    /msg mozbot vars RDF sites '+|slashdot|http://slashdot.org/slashdot.rdf'
 
 403 First, note that the value is surrounded by quotes.  You can nest
 
 404 quotes without any problems, the quotes are just needed to
 
 405 differentiate significant trailing whitespace from mistakes.
 
 407 The "+" means you want to add a value to the hash (as you'll see in a
 
 408 minute, to remove an item you use "-"). Then, since a hash is a
 
 409 key/value pair, you have to delimit the two. In this case, we have
 
 410 used "|" as a delimiter. However, you could use anything.  The first
 
 411 occurance tells mozbot what delimiter you have picked.  The second
 
 412 separates the key (in this case the site nickname) from the value (in
 
 413 this case the URI). For example:
 
 415    /msg mozbot vars RDF sites '+*key*value'
 
 417 You could even use a letter as a delimiter, but since that is usually
 
 418 a sign that you have forgotten to declare which delimiter you are
 
 419 using, mozbot will warn you about this. For example (the 'users' hash,
 
 420 BTW, is the hash in which all the username/password pairs are kept):
 
 422    /msg mozbot vars Admin users '+sarah|lisa'
 
 424 ...will be treated the same as:
 
 426    /msg mozbot vars Admin users '+*arah|li*a'
 
 428 ..., i.e. the username added would be "arah|li" and the password would
 
 429 be "a". This is not a bug, it's a feature. It means you can include
 
 430 any character, including "'", "|", and so on, in the key, without fear
 
 431 of it being interpreted as a delimiter.
 
 433 To remove a user, or any key/value pair in a hash, you use this
 
 436    /msg mozbot vars Admin users '-admin'
 
 438 That's it. No need to say what the value is, since each key in a hash
 
 439 has to be unique. (Although, in this particular case, it should be
 
 440 noted that the preferred way to remove users is actually the
 
 441 'deleteuser' command.)