-This is bobot++.info, produced by makeinfo version 4.6 from
+This is bobot++.info, produced by makeinfo version 4.7 from
bobot++.texinfo.
This file documents Bobot++ by Clinton Ebadi and Etienne Bernard
Using Bobot++
+* Starting the Bot::
* User Levels::
* Protection::
* Automatic Op::
+* Built-In Commands::
Scripting
\1f
File: bobot++.info, Node: Introduction, Next: Configuration, Prev: Top, Up: Top
-Introduction
-************
+1 Introduction
+**************
This manual feels abused and neglected because it has almost no content.
\1f
File: bobot++.info, Node: Configuration, Next: Using the Bot, Prev: Introduction, Up: Top
-Configuration
-*************
+2 Configuration
+***************
Bobot++ is easy to configure. See the `examples' directory for an
example configuration.
\1f
File: bobot++.info, Node: Configuration Files, Next: Configuration File Placement, Prev: Configuration, Up: Configuration
-Configuration Files
-===================
+2.1 Configuration Files
+=======================
* Menu:
\1f
File: bobot++.info, Node: bot.conf, Next: bot.users, Prev: Configuration Files, Up: Configuration Files
-bot.conf
---------
+2.1.1 bot.conf
+--------------
* Menu:
\1f
File: bobot++.info, Node: server syntax, Next: channel syntax, Prev: bot.conf, Up: bot.conf
-server syntax
-.............
+2.1.1.1 server syntax
+.....................
SERVER = SERVER_NAME [PORT [PASSWORD]]
\1f
File: bobot++.info, Node: channel syntax, Prev: server syntax, Up: bot.conf
-channel syntax
-..............
+2.1.1.2 channel syntax
+......................
CHANNEL = NAME:INITIAL_MODES:MODES_TO_KEEP:CHANNEL_KEY
\1f
File: bobot++.info, Node: bot.users, Prev: bot.conf, Up: Configuration Files
-bot.users
----------
+2.1.2 bot.users
+---------------
`bot.users' is the default file name of the userlist. It may be changed
in `bot.conf'. The file contains lines with the format:
\1f
File: bobot++.info, Node: Configuration File Placement, Prev: Configuration Files, Up: Configuration
-Configuration File Placement
-============================
+2.2 Configuration File Placement
+================================
Bobot++ will look in `/etc/bobotpp/default/' for its default config if
none is specified on the command line. Put the configuration files you
\1f
File: bobot++.info, Node: Using the Bot, Next: Scripting, Prev: Configuration, Up: Top
-Using Bobot++
-*************
+3 Using Bobot++
+***************
FIXME: stuff here...
* Menu:
+* Starting the Bot::
* User Levels::
* Protection::
* Automatic Op::
+* Built-In Commands::
\1f
-File: bobot++.info, Node: User Levels, Next: Protection, Prev: Using the Bot, Up: Using the Bot
+File: bobot++.info, Node: Starting the Bot, Next: User Levels, Prev: Using the Bot, Up: Using the Bot
+
+3.1 Starting the Bot
+====================
+
+The bot is usually installed with the binary name `bobotpp'. It accepts
+the following command line arguments:
+
+ * `[--help][-h]' - Shows detailed help and exits
+
+ * `[--version][-v]' - Shows version information and exits
+
+ * `[--no-background][-b]' - Run bobot++ in the foreground
+
+ * `[--config-file file][-f]' - Use file instead of `bot.conf'
+
+ * `[--config-dir dir][-d]' - Use dir as dir to load config file from
+
+ * `[--config dir][-c]' - Search your config path (defaults to
+ `$HOME/.bobotpp/config/' and then `/etc/bobotpp/') for dir and
+ then loads your config data using dir
+
+ * `[--sys-config dir][-s]' - Looks for config in `/etc/bobotpp/dir'.
+ Note that the user dir is still searched first
+
+ * `[--user-config dir][-u]' - Looks for config in
+ `$HOME/.bobotpp/config/dir/'. Note that the system dir is still
+ searched after this if dir is not found.
+
+ * `[--debug][-D]' Makes Bobot++ print debugging info and run in the
+ foreground
-User Levels
-===========
+
+ The default configuration is read from
+`$HOME/.bobotpp/config/default/' and then `/etc/bobotpp/default/' if
+the user config is not found.
+
+ The bot defaults to running in the background as a daemon.
+
+\1f
+File: bobot++.info, Node: User Levels, Next: Protection, Prev: Starting the Bot, Up: Using the Bot
+
+3.2 User Levels
+===============
There are several user levels available in Bobot++ to provide gradated
access to commands. `!adduser' and `bot.users' use the numeric code;
\1f
File: bobot++.info, Node: Protection, Next: Automatic Op, Prev: User Levels, Up: Using the Bot
-Protection
-==========
+3.3 Protection
+==============
A user added via Scheme, the `bot.users' file, or `!adduser' may be
protected from being deoped, kicked, or banned. There are currently no
\1f
-File: bobot++.info, Node: Automatic Op, Prev: Protection, Up: Using the Bot
+File: bobot++.info, Node: Automatic Op, Next: Built-In Commands, Prev: Protection, Up: Using the Bot
-Automatic Op
-============
+3.4 Automatic Op
+================
A user may be automatically given operator status upon entering a
channel. Set the AOP field to "0" to disable auto-op or "1" to enable
auto-op.
+\1f
+File: bobot++.info, Node: Built-In Commands, Prev: Automatic Op, Up: Using the Bot
+
+3.5 Built-In Commands
+=====================
+
+Bobot++ has many built-in commands that make it useful without
+scripting support. The reference leaves off the command char; remember
+to use whatever you defined the command char to be in `bot.conf'. If a
+command needs the channel name then you must specify the channel as the
+first argument to the command when private messaging the bot a command.
+
+COMMAND NEEDS CHANNEL MIN LEVEL TO USE DESCRIPTION
+`action' `do' Yes USER Causes the bot
+ to perform the
+ action `do' in
+ the current
+ channel.
+`adduser'
+`addserver'
+`addshit'
+`alias'
+`ban'
+`banlist'
+`channels'
+`cycle'
+`dcclist'
+`deban'
+`delserver'
+`deluser'
+`delshit'
+`deop'
+`die'
+`do'
+`execute' *Only available
+ if scripting
+ support is
+ enabled*
+`help'
+`ident'
+`invite'
+`join'
+`keep'
+`kick'
+`kickban'
+`load'
+`loadscript' *Only available
+ if scripting
+ support is
+ enabled*
+`lock'
+`mode'
+`msg'
+`names'
+`nextserver'
+`nick'
+`nslookup'
+`op'
+`part'
+`password'
+`reconnect'
+`rspymessage'
+`save'
+`say'
+`server'
+`serverlist'
+`setfloodrate'
+`setversion'
+`shitlist'
+`spylist'
+`spymessage'
+`stats'
+`tban'
+`tkban'
+`topic'
+`unlock'
+`userlist'
+`who'
+`whois'
+
\1f
File: bobot++.info, Node: Scripting, Next: Concept Index, Prev: Using the Bot, Up: Top
-Scripting
-*********
+4 Scripting
+***********
Bobot++'s most powerful feature is its scripting system. You write
scripts using Guile Scheme. This manual does not cover how to use Guile
or how to learn Scheme. *Note Guile Reference Manual: (guile)Top, for
the Guile reference manual and
-<http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html> for a
+`http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html' for a
good tutorial on Scheme.
Note that in previous versions the scripting commands where in the
\1f
File: bobot++.info, Node: Adding New Commands, Next: Hooks, Prev: Scripting, Up: Scripting
-Adding New Commands
-===================
+4.1 Adding New Commands
+=======================
Adding a new command is simple. To register a new command use
`bot:addcommand'. The prototype for `bot:addcommand' is
(if (string=? name "")
(bot:say channel "Hello world!")
(bot:say channel (string-append "Hello " name "!")))
-
+
(bot:addcommand "hello" hello #t 2 0)
This will display "Hello World!" if called as `!hello' and "Hello
\1f
File: bobot++.info, Node: Hooks, Next: Scheme User Levels, Prev: Adding New Commands, Up: Scripting
-Hooks
-=====
+4.2 Hooks
+=========
Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
and tiny fugue (a MUD bot) hooks with a little bit of extra stuff added
\1f
File: bobot++.info, Node: Creating a Hook, Next: Hook Types, Prev: Hooks, Up: Hooks
-Creating a Hook
----------------
+4.2.1 Creating a Hook
+---------------------
To add a new hook you use the function `bot:addhook'. `bot:addhook' is
prototyped as `(bot:addhook type regex function pri fall name)'. `type'
\1f
File: bobot++.info, Node: Hook Types, Prev: Creating a Hook, Up: Hooks
-Hook Types
-----------
+4.2.2 Hook Types
+----------------
Here is a list of the various hooks are notes on each one. The general
format of a hook is:
\1f
File: bobot++.info, Node: Scheme User Levels, Next: Sending Messages, Prev: Hooks, Up: Scripting
-Scheme User Levels
-==================
+4.3 Scheme User Levels
+======================
There are five levels that a user may be when interfacing with a bot:
NONE, USER, TRUSTED_USER, FRIEND, MASTER. The Scheme variables for the
\1f
File: bobot++.info, Node: Sending Messages, Next: Misc Scripting Stuff, Prev: Scheme User Levels, Up: Scripting
-Sending Messages
-================
+4.4 Sending Messages
+====================
There are several types of messages you can send with Bobot++ from
scripts. There is the simple, but rather limited, `bot:say',
\1f
File: bobot++.info, Node: High Level Message Functions, Next: Low Level Message Functions, Prev: Sending Messages, Up: Sending Messages
-"High Level" Message Functions
-------------------------------
+4.4.1 "High Level" Message Functions
+------------------------------------
...
\1f
File: bobot++.info, Node: Low Level Message Functions, Prev: High Level Message Functions, Up: Sending Messages
-"Low Level" Message Functions
------------------------------
+4.4.2 "Low Level" Message Functions
+-----------------------------------
The "Low Level" messaging functions allow you to do things like send
CTCP messages. You probably want to read rfc 2812 and the CTCP spec
\1f
File: bobot++.info, Node: Misc Scripting Stuff, Prev: Sending Messages, Up: Scripting
-Misc. Scripting Stuff
-=====================
+4.5 Misc. Scripting Stuff
+=========================
These are a few useful things that I thought people writing scripts
might want to know.
Concept Index
*************
+\0\b[index\0\b]
* Menu:
-* Background on Hooks: Hooks.
+* Background on Hooks: Hooks. (line 6)
\1f
File: bobot++.info, Node: Function Index, Next: Variable Index, Prev: Concept Index, Up: Top
Function Index
**************
+\0\b[index\0\b]
* Menu:
-* addcommand: Adding New Commands.
-* addhook: Creating a Hook.
+* addcommand: Adding New Commands. (line 6)
+* addhook: Creating a Hook. (line 6)
\1f
File: bobot++.info, Node: Variable Index, Prev: Function Index, Up: Top
Variable Index
**************
+\0\b[index\0\b]
* Menu:
* exit-hook: Misc Scripting Stuff.
-* hooks/action: Hook Types.
-* hooks/ctcp: Hook Types.
-* hooks/ctcp-reply: Hook Types.
-* hooks/dcc/begin: Hook Types.
-* hooks/dcc/message: Hook Types.
-* hooks/disconnect: Hook Types.
-* hooks/flood: Hook Types.
-* hooks/invite: Hook Types.
-* hooks/join: Hook Types.
-* hooks/kick: Hook Types.
-* hooks/message: Hook Types.
-* hooks/mode: Hook Types.
-* hooks/nickname: Hook Types.
-* hooks/notice: Hook Types.
-* hooks/part: Hook Types.
-* hooks/public: Hook Types.
-* hooks/public-notice: Hook Types.
-* hooks/raw: Hook Types.
-* hooks/signoff: Hook Types.
-* hooks/timer: Hook Types.
-* hooks/topic: Hook Types.
-* user-friend: Scheme User Levels.
-* user-master: Scheme User Levels.
-* user-none: Scheme User Levels.
-* user-trusted: Scheme User Levels.
-* user-user: Scheme User Levels.
+ (line 9)
+* hooks/action: Hook Types. (line 23)
+* hooks/ctcp: Hook Types. (line 50)
+* hooks/ctcp-reply: Hook Types. (line 56)
+* hooks/dcc/begin: Hook Types. (line 146)
+* hooks/dcc/message: Hook Types. (line 154)
+* hooks/disconnect: Hook Types. (line 62)
+* hooks/flood: Hook Types. (line 68)
+* hooks/invite: Hook Types. (line 74)
+* hooks/join: Hook Types. (line 80)
+* hooks/kick: Hook Types. (line 86)
+* hooks/message: Hook Types. (line 104)
+* hooks/mode: Hook Types. (line 98)
+* hooks/nickname: Hook Types. (line 38)
+* hooks/notice: Hook Types. (line 110)
+* hooks/part: Hook Types. (line 92)
+* hooks/public: Hook Types. (line 116)
+* hooks/public-notice: Hook Types. (line 122)
+* hooks/raw: Hook Types. (line 128)
+* hooks/signoff: Hook Types. (line 44)
+* hooks/timer: Hook Types. (line 134)
+* hooks/topic: Hook Types. (line 140)
+* user-friend: Scheme User Levels. (line 6)
+* user-master: Scheme User Levels. (line 6)
+* user-none: Scheme User Levels. (line 6)
+* user-trusted: Scheme User Levels. (line 6)
+* user-user: Scheme User Levels. (line 6)
\1f
Tag Table:
Node: Top\7f522
-Node: Introduction\7f1768
-Node: Configuration\7f1956
-Node: Configuration Files\7f2239
-Node: bot.conf\7f2446
-Node: server syntax\7f3872
-Node: channel syntax\7f4720
-Node: bot.users\7f5547
-Node: Configuration File Placement\7f6438
-Node: Using the Bot\7f6908
-Node: User Levels\7f7111
-Node: Protection\7f8556
-Node: Automatic Op\7f9157
-Node: Scripting\7f9412
-Node: Adding New Commands\7f10373
-Node: Hooks\7f11637
-Node: Creating a Hook\7f12608
-Node: Hook Types\7f13744
-Node: Scheme User Levels\7f17215
-Node: Sending Messages\7f18341
-Node: High Level Message Functions\7f18949
-Node: Low Level Message Functions\7f19160
-Node: Misc Scripting Stuff\7f19910
-Node: Concept Index\7f20326
-Node: Function Index\7f20508
-Node: Variable Index\7f20769
+Node: Introduction\7f1811
+Node: Configuration\7f2003
+Node: Configuration Files\7f2290
+Node: bot.conf\7f2505
+Node: server syntax\7f3943
+Node: channel syntax\7f4807
+Node: bot.users\7f5650
+Node: Configuration File Placement\7f6553
+Node: Using the Bot\7f7031
+Node: Starting the Bot\7f7281
+Node: User Levels\7f8625
+Node: Protection\7f10081
+Node: Automatic Op\7f10690
+Node: Built-In Commands\7f10979
+Node: Scripting\7f15513
+Node: Adding New Commands\7f16478
+Node: Hooks\7f17745
+Node: Creating a Hook\7f18724
+Node: Hook Types\7f19872
+Node: Scheme User Levels\7f23355
+Node: Sending Messages\7f24489
+Node: High Level Message Functions\7f25105
+Node: Low Level Message Functions\7f25328
+Node: Misc Scripting Stuff\7f26090
+Node: Concept Index\7f26514
+Node: Function Index\7f26733
+Node: Variable Index\7f27032
\1f
End Tag Table
Using Bobot++
+* Starting the Bot::
* User Levels::
* Protection::
* Automatic Op::
+* Built-In Commands::
Scripting
FIXME: stuff here...
@menu
+* Starting the Bot::
* User Levels::
* Protection::
* Automatic Op::
+* Built-In Commands::
@end menu
-@node User Levels, Protection, Using the Bot, Using the Bot
+@node Starting the Bot, User Levels, Using the Bot, Using the Bot
+@section Starting the Bot
+
+The bot is usually installed with the binary name @file{bobotpp}. It
+accepts the following command line arguments:
+
+@itemize
+
+@item @code{[--help][-h]} - Shows detailed help and exits
+
+@item @code{[--version][-v]} - Shows version information and exits
+
+@item @code{[--no-background][-b]} - Run bobot++ in the foreground
+
+@item @code{[--config-file file][-f]} - Use file instead of
+@file{bot.conf}
+
+@item @code{[--config-dir dir][-d]} - Use dir as dir to load config
+file from
+
+@item @code{[--config dir][-c]} - Search your config path (defaults to
+@file{@var{$HOME}/.bobotpp/config/} and then @file{/etc/bobotpp/}) for
+dir and then loads your config data using dir
+
+@item @code{[--sys-config dir][-s]} - Looks for config in
+@file{/etc/bobotpp/dir}. Note that the user dir is still searched
+first
+
+@item @code{[--user-config dir][-u]} - Looks for config in
+@file{@var{$HOME}/.bobotpp/config/dir/}. Note that the system dir is
+still searched after this if dir is not found.
+
+@item @code{[--debug][-D]} Makes Bobot++ print debugging info and run
+in the foreground
+
+@end itemize
+
+The default configuration is read from
+@file{@var{$HOME}/.bobotpp/config/default/} and then
+@file{/etc/bobotpp/default/} if the user config is not found.
+
+The bot defaults to running in the background as a daemon.
+
+@node User Levels, Protection, Starting the Bot, Using the Bot
@section User Levels
There are several user levels available in Bobot++ to provide gradated
@end enumerate
-@node Automatic Op, , Protection, Using the Bot
+@node Automatic Op, Built-In Commands, Protection, Using the Bot
@section Automatic Op
A user may be automatically given operator status upon entering a
channel. Set the @var{aop} field to ``0'' to disable auto-op or ``1''
to enable auto-op.
+@node Built-In Commands, , Automatic Op, Using the Bot
+@section Built-In Commands
+
+Bobot++ has many built-in commands that make it useful without
+scripting support. The reference leaves off the command char;
+remember to use whatever you defined the command char to be in
+@file{bot.conf}. If a command needs the channel name then you must
+specify the channel as the first argument to the command when private
+messaging the bot a command.
+
+@multitable @columnfractions 0.25 0.25 0.25 0.25
+@item @sc{command} @tab @sc{Needs Channel} @tab @sc{Min Level to Use} @tab @sc{Description}
+
+@item @command{action} @option{do} @tab Yes @tab @var{USER} @tab
+Causes the bot to perform the action @option{do} in the current
+channel.
+
+@item @command{adduser}
+
+@item @command{addserver}
+
+@item @command{addshit}
+
+@item @command{alias}
+
+@item @command{ban}
+
+@item @command{banlist}
+
+@item @command{channels}
+
+@item @command{cycle}
+
+@item @command{dcclist}
+
+@item @command{deban}
+
+@item @command{delserver}
+
+@item @command{deluser}
+
+@item @command{delshit}
+
+@item @command{deop}
+
+@item @command{die}
+
+@item @command{do}
+
+@item @command{execute} @tab @tab @tab @strong{Only available if scripting
+support is enabled}
+
+@item @command{help}
+
+@item @command{ident}
+
+@item @command{invite}
+
+@item @command{join}
+
+@item @command{keep}
+
+@item @command{kick}
+
+@item @command{kickban}
+
+@item @command{load}
+
+@item @command{loadscript} @tab @tab @tab @strong{Only available if scripting
+support is enabled}
+
+@item @command{lock}
+
+@item @command{mode}
+
+@item @command{msg}
+
+@item @command{names}
+
+@item @command{nextserver}
+
+@item @command{nick}
+
+@item @command{nslookup}
+
+@item @command{op}
+
+@item @command{part}
+
+@item @command{password}
+
+@item @command{reconnect}
+
+@item @command{rspymessage}
+
+@item @command{save}
+
+@item @command{say}
+
+@item @command{server}
+
+@item @command{serverlist}
+
+@item @command{setfloodrate}
+
+@item @command{setversion}
+
+@item @command{shitlist}
+
+@item @command{spylist}
+
+@item @command{spymessage}
+
+@item @command{stats}
+
+@item @command{tban}
+
+@item @command{tkban}
+
+@item @command{topic}
+
+@item @command{unlock}
+
+@item @command{userlist}
+
+@item @command{who}
+
+@item @command{whois}
+
+@end multitable
+
@node Scripting, Concept Index, Using the Bot, Top
@chapter Scripting
--- /dev/null
+// BotConfig.C -*- C++ -*-
+// Copyright (C) 2004 Clinton Ebadi
+
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+
+#include "BotConfig.H"
+#include "Bot.H"
+#include "StringTokenizer.H"
+#include <iostream>
+#include <string>
+#include <list>
+#include <algorithm>
+
+BotConfig::BotConfig (std::string cf)
+ : config_filename (cf)
+{ }
+
+bool BotConfig::read_config ()
+{
+ std::ifstream config_file (config_filename.c_str ());
+ std::string current_line;
+ unsigned int line_number = 1;
+
+ options_db.clear ();
+
+ if (!config_file)
+ {
+ // FIXME: log lines (needs local bot object, probably a
+ // redesign. UGH).
+
+ // Bot::logLine ("Error: Config File Not Found `" +
+ // config_filename + "'");
+ return false;
+ }
+
+ while (!config_file.eof ())
+ {
+ std::getline (config_file, current_line);
+ if (current_line.length () == 0 || current_line[0] == '#')
+ {
+ line_number++;
+ continue;
+ }
+
+ StringTokenizer st (current_line);
+ std::string command = st.nextToken('=').trim().toUpper();
+ StringTokenizer params (st.nextToken('=').trim());
+
+ options_db[command] = t_option_values (t_value_list (),
+ t_watcher_list ());
+ while (params.hasMoreTokens (','))
+ {
+ options_db[command].first.push_back (params.nextToken (',').trim());
+ }
+ }
+ return true;
+}
+
+
+BotConfig::t_option_values BotConfig::get_option_values (std::string key)
+{
+ t_options_db::const_iterator cf_iter =
+ options_db.find (key);
+
+ if (cf_iter != options_db.end ())
+ return cf_iter->second;
+ else
+ return t_option_values (); // Empty vector
+}
+
+std::string BotConfig::set_config_file (std::string fname)
+{
+ std::string old_config_filename = config_filename;
+ config_filename = fname;
+ options_db.clear ();
+ read_config ();
+ return old_config_filename;
+}
+
+namespace
+{
+ struct push_back_
+ {
+ BotConfig::t_value_list* lst;
+
+ push_back_ (BotConfig::t_value_list* l)
+ : lst (l)
+ {}
+
+ void operator()(BotConfig::t_value val)
+ {
+ lst->push_back (val);
+ }
+ };
+}
+
+void BotConfig::set_option_value (std::string key, t_value_list values,
+ bool append)
+{
+ t_options_db::iterator cf_iter = options_db.find (key);
+ if (cf_iter != options_db.end ())
+ {
+ if (append)
+ {
+ // FIXME: Potentially slow (make this push_front in 3.0)
+ std::for_each (values.begin (), values.end (),
+ push_back_ (&cf_iter->second.first));
+ }
+ else
+ cf_iter->second.first = values;
+ }
+}
+
+