[project @ 2002-07-12 03:27:05 by unknown_lamer]
authorunknown_lamer <unknown>
Fri, 12 Jul 2002 03:27:05 +0000 (03:27 +0000)
committerunknown_lamer <unknown>
Fri, 12 Jul 2002 03:27:05 +0000 (03:27 +0000)
2002-07-11  Clinton Ebadi  <clinton@unknownlamer.org>

* source/ServerQueue.C (sendUser): Changed . . in USER command to
0 * (which is the Right Way to because <mode> must be a number...)

* source/Parser.C (init): New method of Parse. This initalizes the
functions map. functions replaces the old functions array, and
should yield better performance (since the functions array had to
be scanned for every incoming message)

* source/Parser.H: New member, functions (private)

2002-07-10  Clinton Ebadi  <clinton@unknownlamer.org>

* source/Interp.C (Startup): New symbols: bot:user-*
[none|user|trusted|friend|master] are defined in Scheme as the
different levels of the users.
(Startup): All bot-* variables are now bot:*

2002-07-09  Clinton Ebadi  <clinton@unknownlamer.org>

* source/Bot.H: Made some variables private because they shouldn't
be changed at runtime

* source/Parser.C (parseCTCP): Reneabled DCC CHAT (I want to test
this out to see if it works and make it work)

* source/Bot.C (Bot::Bot): New var: logs_dir. Set to the log file
dir.

* scripts/bobot-utils.scm: Fixed a typo (I forgot the / after
scripts in the user scripts dir) that made bobot++ not able to
load scripts from the user scripts dir

27 files changed:
ChangeLog
NEWS
TODO
bobot++.info
bobot++.texinfo
configure
configure.ac
scripts/bobot-utils.scm
scripts/boulet
scripts/country
scripts/eval
scripts/hello
scripts/scheme_add_user
scripts/stupid_stuff/stupid_stuff
scripts/tamere
scripts/uname
scripts/uptime
source/Bot.C
source/Bot.H
source/Interp.C
source/Main.C
source/Parser.C
source/Parser.H
source/ScriptCommands.C
source/ServerQueue.C
source/Socket.C
source/Socket.H

index f7153db..fb38f4c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,37 @@
+2002-07-11  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/ServerQueue.C (sendUser): Changed . . in USER command to
+       0 * (which is the Right Way to because <mode> must be a number...)
+
+       * source/Parser.C (init): New method of Parse. This initalizes the
+       functions map. functions replaces the old functions array, and
+       should yield better performance (since the functions array had to
+       be scanned for every incoming message)
+
+       * source/Parser.H: New member, functions (private)
+
+2002-07-10  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Interp.C (Startup): New symbols: bot:user-*
+       [none|user|trusted|friend|master] are defined in Scheme as the
+       different levels of the users. 
+       (Startup): All bot-* variables are now bot:*
+
+2002-07-09  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Bot.H: Made some variables private because they shouldn't
+       be changed at runtime
+
+       * source/Parser.C (parseCTCP): Reneabled DCC CHAT (I want to test
+       this out to see if it works and make it work)
+
+       * source/Bot.C (Bot::Bot): New var: logs_dir. Set to the log file
+       dir. 
+
+       * scripts/bobot-utils.scm: Fixed a typo (I forgot the / after
+       scripts in the user scripts dir) that made bobot++ not able to
+       load scripts from the user scripts dir
+
 2002-07-08  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * source/BotInterp.C (RunHooks): Changed iterators to
diff --git a/NEWS b/NEWS
index 6362dca..6cd8fec 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,13 +18,16 @@ Version 2.1.0: Hook!
   bobotpp --help for the full list of commands you may use and how to
   use them).
 - Scripts are now stored in ~/.bobotpp/scripts/ or
-  PREFIX/bobotpp/scripts (where PREFIX is /usr/local unless you
+  PREFIX/bobotpp/scripts/ (where PREFIX is /usr/local unless you
   changed it with the --prefix arg to configure). The new function
   bot-load will take a filename and load it from these dirs, returning
   #t if the file was loaded and #f if it wasn't. You can modify the
   search list by appending to %bot-loadpath.
 - bobot-utils.scm is now autoloaded, so you don't need to
   load it if you want to use its functions.
+- Logs are now in ~/.bobotpp/logs/
+- bot-* procedures in Scheme are now bot:*. The onl bot-* functions
+  are defined as aliases in bobot-utils.scm
 
 
 Version 2.0: Stable release / CVS merges
diff --git a/TODO b/TODO
index 8129528..382d3df 100644 (file)
--- a/TODO
+++ b/TODO
@@ -27,6 +27,7 @@ General:
 * Audit code and see what data in classes should be made private and
    have getters/setters added (e.g. logFileName in Bot--if this is
    changed the log file doesn't change after the Bot is started).
+* Fix logging stuff
 
 Networking:
 * Add a networked interface to guile repl
@@ -35,8 +36,12 @@ Networking:
    - Access to repl will require use to authenticate
    - Allow the load & reloading of scripts w/o restarting bot
    - Allow server to be disabled at run because of security...
-* Enable DCC support (I have to find docs on DCC first!)
+* Enable DCC support (maybe not, you can always intercept CTCP from
+   Scheme)
 * Add Channel logging (log full text of channel if enabled)
+   - maybe not, you can do this from Scheme (it would probably be
+     really slow though)
+* Make connecting to irc.oftc.net work...I wonder if their ircd is b0rked
 
 Config:
 * Change bot.conf syntax (just load it with guile)
@@ -60,10 +65,6 @@ Config:
 (server-set-name trollaxor.com "TrollBot")
 
   - Support per-server channels, logfiles, cmdchars, everything...
-* Move default config location to PREFIX/Bobot++/default/ and allow
-  users to specify a config folder under PREFIX/Bobot++ to use with
-   -c. E.g. To use PREFIX/Bobot++/foo/, call bobotpp -c foo. Keep -f
-   and -d.
 
 Documentation:
 - Texinfo manual (including scripting section)
\ No newline at end of file
index f3cac49..73eb09b 100644 (file)
@@ -20,6 +20,14 @@ File: bobot++.info,  Node: Top,  Next: Introduction,  Prev: (dir),  Up: (dir)
 
    This document applies to version 2.1.0 of the program named Bobot++
 
+   Copyright 2002 Clinton Ebadi
+
+   Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.1 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+Texts.
+
 * Menu:
 
 * Introduction::
@@ -86,6 +94,221 @@ the Guile reference manual and
 <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
+form `bot-FUNCTION'. They are now in the form `bot:FUNCTION'. The old
+names are still available, but are deprecated and will be removed in
+Bobot++ 2.4. The command `perl -pi -e ``s/bot-/bot:/g'' YOUR-FILES'
+should be enough to convert your code to use the new functions.
+
+* Menu:
+
+* Adding New Commands::
+* Hooks::
+
+\1f
+File: bobot++.info,  Node: Adding New Commands,  Next: Hooks,  Prev: Scripting,  Up: Scripting
+
+Adding New Commands
+===================
+
+   Not here yet.
+
+\1f
+File: bobot++.info,  Node: Hooks,  Prev: Adding New Commands,  Up: Scripting
+
+Hooks
+=====
+
+   Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
+hooks and tiny fugue (a MUD bot) hooks. The basic idea of a hook if
+that you match a text against regular expression and call a function if
+text in a message matches that regex. The different types of hooks
+provided by Bobot++ correspond to the different classes of messages
+that Bobot++ can recieve. A Hook also has several properties, including
+its priority and whether or not it is a fallthrough hook. Higher
+priority hooks are executed before lower priority hooks and fallthrough
+hooks are executed before non-fallthrough hooks. A fallthrough hook can
+match and processing of hooks will continue; as soon as the first
+non-fallthrough hooks matches processing of hooks stops.
+
+* Menu:
+
+* Creating a Hook::
+* Hook Types::
+
+\1f
+File: bobot++.info,  Node: Creating a Hook,  Next: Hook Types,  Prev: Hooks,  Up: Hooks
+
+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)'. `type'
+specifies the type of hook (the types of hooks are listed in *Note Hook
+Types::). `regex' is a standard regular expression. If `regex' is
+matched, `function' will be called. `function' will take a different
+number of args depending on the hook type. `pri' specifies the priority
+of the hook-higher priority hooks are executed first. This argument is
+optional and defaults to `0'. `fall' is `#t' if the hook is a
+fallthrough hook and `#f' is the hook is not a fallthrough hook. This
+arg is also optional and default to `#t'.
+
+\1f
+File: bobot++.info,  Node: Hook Types,  Prev: Creating a Hook,  Up: Hooks
+
+Hook Types
+----------
+
+   Here is a list of the various hooks are notes on each one. The
+general format of a hook is:
+
+   * `hooks/name' (this is the Scheme variable name of the hook)
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+             - `arg2': desc
+
+             - ...
+
+             - `argN': desc
+
+   That said, here is the list of available hooks:
+
+   * `hooks/action'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/nickname'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/signoff'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/ctcp'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/ctcp-reply'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/disconnect'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/flood'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/invite'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/join'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/kick'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/part'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/mode'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/message'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/notice'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/public'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/public-notice'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/raw'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/timer'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
+   * `hooks/topic'
+        - Description of the hook
+
+        - # of args
+             - `arg1': desc
+
+
 \1f
 File: bobot++.info,  Node: Concept Index,  Next: Function Index,  Prev: Scripting,  Up: Top
 
@@ -111,13 +334,17 @@ Variable Index
 \1f
 Tag Table:
 Node: Top\7f517
-Node: Introduction\7f905
-Node: Configuration\7f1096
-Node: Configuration File Syntax\7f1478
-Node: Configure File Placement\7f1680
-Node: Scripting\7f2154
-Node: Concept Index\7f2607
-Node: Function Index\7f2739
-Node: Variable Index\7f2878
+Node: Introduction\7f1228
+Node: Configuration\7f1419
+Node: Configuration File Syntax\7f1801
+Node: Configure File Placement\7f2003
+Node: Scripting\7f2477
+Node: Adding New Commands\7f3316
+Node: Hooks\7f3473
+Node: Creating a Hook\7f4363
+Node: Hook Types\7f5153
+Node: Concept Index\7f7626
+Node: Function Index\7f7758
+Node: Variable Index\7f7897
 \1f
 End Tag Table
index db4ee89..f32b98c 100644 (file)
@@ -44,6 +44,14 @@ This document describes Bobot++ by Clinton Ebadi and Etienne Bernard
 
 This document applies to version 2.1.0 of the program named
 Bobot++
+
+Copyright 2002 Clinton Ebadi
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.1 or
+any later version published by the Free Software Foundation; with no
+Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
+Texts.
 @end ifinfo
 
 @menu
@@ -97,6 +105,376 @@ guile, The Guile Reference Manual}, for the Guile reference manual and
 @url{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
+form @code{bot-@var{function}}. They are now in the form
+@code{bot:@var{function}}. The old names are still available, but are
+deprecated and will be removed in Bobot++ 2.4. The command
+@command{perl -pi -e ``s/bot-/bot:/g'' @var{your-files}} should be enough to
+convert your code to use the new functions. 
+
+@menu
+* Adding New Commands::         
+* Hooks::                       
+@end menu
+
+@node Adding New Commands, Hooks, Scripting, Scripting
+@section Adding New Commands
+
+Not here yet.
+
+@node Hooks,  , Adding New Commands, Scripting
+@section Hooks
+
+Hooks are a powerful feature of Bobot++. Hooks are a hybrid of ircII
+hooks and tiny fugue (a MUD bot) hooks. The basic idea of a hook if
+that you match a text against regular expression and call a function
+if text in a message matches that regex. The different types of hooks
+provided by Bobot++ correspond to the different classes of messages
+that Bobot++ can recieve. A Hook also has several properties,
+including its priority and whether or not it is a fallthrough
+hook. Higher priority hooks are executed before lower priority hooks
+and fallthrough hooks are executed before non-fallthrough hooks. A
+fallthrough hook can match and processing of hooks will continue; as
+soon as the first non-fallthrough hooks matches processing of hooks
+stops. 
+
+@menu
+* Creating a Hook::             
+* Hook Types::                  
+@end menu
+
+@node Creating a Hook, Hook Types, Hooks, Hooks
+@subsection Creating a Hook
+
+To add a new hook you use the function
+@code{bot:addhook}. @code{bot:addhook} is prototyped as
+@code{(bot:addhook type regex function pri fall)}. @code{type}
+specifies the type of hook (the types of hooks are listed in @ref{Hook
+Types}). @code{regex} is a standard regular expression. If
+@code{regex} is matched, @code{function} will be
+called. @code{function} will take a different number of args depending
+on the hook type. @code{pri} specifies the priority of the
+hook--higher priority hooks are executed first. This argument is
+optional and defaults to @code{0}. @code{fall} is @code{#t} if the
+hook is a fallthrough hook and @code{#f} is the hook is not a
+fallthrough hook. This arg is also optional and default to @code{#t}. 
+
+@node Hook Types,  , Creating a Hook, Hooks
+@subsection Hook Types
+
+Here is a list of the various hooks are notes on each one. The general
+format of a hook is:
+
+@itemize @bullet
+@item
+@code{hooks/name} (this is the Scheme variable name of the hook)
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@item
+@code{arg2}: desc
+@item
+...
+@item
+@code{argN}: desc
+@end itemize
+@end itemize
+@end itemize
+
+That said, here is the list of available hooks:
+
+@itemize @bullet
+@item
+@code{hooks/action}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/nickname}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/signoff}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/ctcp}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/ctcp-reply}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/disconnect}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/flood}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/invite}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/join}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/kick}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/part}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/mode}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/message}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/notice}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/public}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/public-notice}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/raw}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/timer}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+@itemize @bullet
+@item
+@code{hooks/topic}
+@itemize @minus
+@item
+Description of the hook
+@item
+# of args
+@itemize @minus
+@item
+@code{arg1}: desc
+@end itemize
+@end itemize
+
+@end itemize
+
+
 @node Concept Index, Function Index, Scripting, Top
 @unnumbered Concept Index
 @printindex cp
index 4612738..8277d04 100644 (file)
--- a/configure
+++ b/configure
@@ -1,6 +1,8 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.53.
+# Generated by GNU Autoconf 2.53 for Bobot++ 2.1CVS.
+#
+# Report bugs to <clinton@unknownlamer.org>.
 #
 # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
@@ -252,13 +254,12 @@ SHELL=${CONFIG_SHELL-/bin/sh}
 : ${ac_max_here_lines=38}
 
 # Identity of this package.
-PACKAGE_NAME=
-PACKAGE_TARNAME=
-PACKAGE_VERSION=
-PACKAGE_STRING=
-PACKAGE_BUGREPORT=
+PACKAGE_NAME='Bobot++'
+PACKAGE_TARNAME='bobot--'
+PACKAGE_VERSION='2.1CVS'
+PACKAGE_STRING='Bobot++ 2.1CVS'
+PACKAGE_BUGREPORT='clinton@unknownlamer.org'
 
-ac_unique_file="source/Makefile.in"
 # Factoring default headers for most tests.
 ac_includes_default="\
 #include <stdio.h>
@@ -768,7 +769,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures this package to adapt to many kinds of systems.
+\`configure' configures Bobot++ 2.1CVS to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -829,7 +830,9 @@ _ACEOF
 fi
 
 if test -n "$ac_init_help"; then
-
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of Bobot++ 2.1CVS:";;
+   esac
   cat <<\_ACEOF
 
 Optional Features:
@@ -854,6 +857,7 @@ Some influential environment variables:
 Use these variables to override the choices made by `configure' or to help
 it to find libraries and programs with nonstandard names/locations.
 
+Report bugs to <clinton@unknownlamer.org>.
 _ACEOF
 fi
 
@@ -916,6 +920,8 @@ fi
 test -n "$ac_init_help" && exit 0
 if $ac_init_version; then
   cat <<\_ACEOF
+Bobot++ configure 2.1CVS
+generated by GNU Autoconf 2.53
 
 Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002
 Free Software Foundation, Inc.
@@ -929,7 +935,7 @@ cat >&5 <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by $as_me, which was
+It was created by Bobot++ $as_me 2.1CVS, which was
 generated by GNU Autoconf 2.53.  Invocation command line was
 
   $ $0 $@
@@ -1193,6 +1199,14 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+
+
 
 
 
@@ -1555,7 +1569,6 @@ _ACEOF
 
 fi;
 
-
 # Check whether --enable-scripting or --disable-scripting was given.
 if test "${enable_scripting+set}" = set; then
   enableval="$enable_scripting"
@@ -4765,7 +4778,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by $as_me, which was
+This file was extended by Bobot++ $as_me 2.1CVS, which was
 generated by GNU Autoconf 2.53.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -4827,7 +4840,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-config.status
+Bobot++ config.status 2.1CVS
 configured by $0, generated by GNU Autoconf 2.53,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -5920,7 +5933,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by $as_me, which was
+This file was extended by Bobot++ $as_me 2.1CVS, which was
 generated by GNU Autoconf 2.53.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -5982,7 +5995,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-config.status
+Bobot++ config.status 2.1CVS
 configured by $0, generated by GNU Autoconf 2.53,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
@@ -7076,7 +7089,7 @@ _ASBOX
 } >&5
 cat >&5 <<_CSEOF
 
-This file was extended by $as_me, which was
+This file was extended by Bobot++ $as_me 2.1CVS, which was
 generated by GNU Autoconf 2.53.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -7138,7 +7151,7 @@ _ACEOF
 
 cat >>$CONFIG_STATUS <<_ACEOF
 ac_cs_version="\\
-config.status
+Bobot++ config.status 2.1CVS
 configured by $0, generated by GNU Autoconf 2.53,
   with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
 
index 9f550ba..47585d6 100644 (file)
@@ -1,6 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PRERQ(2.50)
-AC_INIT(source/Makefile.in)
+dnl AC_INIT(source/Makefile.in)
+AC_INIT([Bobot++], [2.1CVS], [clinton@unknownlamer.org])
 AM_INIT_AUTOMAKE([Bobot++], [2.1.0CVS])
 AM_CONFIG_HEADER(config.h)
 
@@ -13,7 +14,6 @@ AC_ARG_ENABLE(crypt,
   fi
 ])
 
-
 AC_ARG_ENABLE(scripting,
 [AC_HELP_STRING(--disable-scripting, Do not use Guile scripts)],
 [
index 89cd34b..133982a 100644 (file)
@@ -8,15 +8,15 @@
 ;;; must be GPLed, so all of your scripts have to be GPLed anyway
 ;;; because you are really linking with Bobot++, a GPLed program!
 
-;;; Bot load (loads a file from %bot-loadpath)
+;;; Bot load (loads a file from %bot:loadpath)
 
-(define %bot-loadpath (list
+(define %bot:loadpath (list
                       (string-append (getenv "HOME")
-                                     "/.bobotpp/scripts")
-                      bot-sys-scripts-dir))
+                                     "/.bobotpp/scripts/")
+                      bot:sys-scripts-dir))
 
-(define (bot-load file)
-  (let loop ((load-path %bot-loadpath))
+(define (bot:load file)
+  (let loop ((load-path %bot:loadpath))
     (if (not (null? load-path))
       (if (catch 'system-error
             (lambda ()
               #f ))
         #t
         (loop (cdr load-path)))
-      #f )))
-
+      (begin (bot:log "ERROR: File " file " Not Found!\n") #f))))
 
 ;;; REGEX UTILS
 
 ;;; match-not-channel adds a prefix regex to your regex so it doesn't
 ;;; match the sender or channel in a PUBLIC message
 (define (match-not-channel regex)
-  (string-append "[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*" regex))
+  (string-append "^[[:graph:]]* [&#+!][^ ,\a]+ [[:graph:][:space:]]*" regex))
 
 ;;; match-to-me matches text that was addressed to the bot with a
 ;;; ':',',', or nothing after the bot name
 (define (match-to-me regex)
-  (string-append (match-not-channel (bot-getnickname))
+  (string-append (match-not-channel (bot:getnickname))
                 "[:,]*[[:space:][:graph:]]*" regex))
 
 
 ;;; bot-log: Write as many messages as you want to the log.  If the
 ;;; arg is a thunk it will be executed and it's output will be
 ;;; written to the log
-(define (bot-log . messages)
+(define (bot:log . messages)
   (map 
    (lambda (x)
      (if (thunk? x)
        (display (x) (bot-logport))
        (display x (bot-logport))))
    messages )
-  (bot-flushport))
\ No newline at end of file
+  (bot:flushport))
+
+;;; DEPRECATED FUNCTION NAMED
+;;; These are provided for backwards compatibility
+;;; and will be removed in the 2.3 dev tree
+
+(define bot-load bot:load)
+(define bot-action bot:action)
+(define bot-adduser bot:adduser)
+(define bot-addserver bot:addserver)
+(define bot-addshit bot:addshit)
+(define bot-ban bot:ban)
+(define bot-cycle bot:cycle)
+(define bot-deban bot:deban)
+(define bot-delserver bot:delserver)
+(define bot-deluser bot:deluser)
+(define bot-delshit bot:delshit)
+(define bot-deop bot:deop)
+(define bot-die bot:die)
+(define bot-do bot:do)
+(define bot-invite bot:invite)
+(define bot-join bot:join)
+(define bot-keep bot:keep)
+(define bot-kick bot:kick)
+(define bot-kickban bot:kickban)
+(define bot-lock bot:lock)
+(define bot-logport bot:logport)
+(define bot-mode bot:mode)
+(define bot-msg bot:msg)
+(define bot-nextserver bot:nextserver)
+(define bot-nick bot:nick)
+(define bot-op bot:op)
+(define bot-part bot:part)
+(define bot-reconnect bot:reconnect)
+(define bot-say bot:say)
+(define bot-server bot:server)
+(define bot-setversion bot:setversion)
+(define bot-tban bot:tban)
+(define bot-tkban bot:tkban)
+(define bot-topic bot:topic)
+(define bot-unlock bot:unlock)
+(define bot-getnickname bot:getnickname)
+(define bot-getserver bot:getserver)
+(define bot-getserverlist bot:getserverlist)
+(define bot-flush bot:flush)
+(define bot-flushport bot:flushport)
+(define bot-random bot:random)
+(define bot-addcommand bot:addcommand)
+(define bot-delcommand bot:delcommand)
+(define bot-addhook bot:addhook)
+(define bot-addtimer bot:addtimer)
+(define bot-deltimer bot:deltimer)
\ No newline at end of file
index 47b5a4a..4172b70 100644 (file)
@@ -3,11 +3,11 @@
 (define (shutup)
   (set! talk 0)
   )
-(bot-addcommand "shutup" shutup #f 0 2)
+(bot:addcommand "shutup" shutup #f 0 2)
 (define (dotalk)
   (set! talk 1)
   )
-(bot-addcommand "talk" dotalk #f 0 2)
+(bot:addcommand "talk" dotalk #f 0 2)
 
 ;;; Miscellaneous list functions
 (define (removeChannel c l)
 ;;; When someone joins a channel
 (define dumbTimer (list))
 (define (joinLourd n c)
-  (if (string-ci=? n (bot-getnickname))
+  (if (string-ci=? n (bot:getnickname))
       (begin
-        (if (= 1 talk) (bot-say c "salut les gars, vous parlez de quoi ?"))
-        (set! dumbTimer (addChannel c (bot-addtimer (+ 600 (bot-random 3000)) (dumbLourd c)) dumbTimer))
+        (if (= 1 talk) (bot:say c "salut les gars, vous parlez de quoi ?"))
+        (set! dumbTimer (addChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer))
         )
-      (if (= 1 talk) (bot-say c (string-append "euh humm euh..., " n "... une ptite question...")))
+      (if (= 1 talk) (bot:say c (string-append "euh humm euh..., " n "... une ptite question...")))
       )
   )
-(bot-addhook hooks/join ".*" joinLourd)
+(bot:addhook hooks/join ".*" joinLourd)
 
 ;;; When someone leaves the channel
 (define (partLourd n c)
-  (bot-flushport)
-  (if (not (string-ci=? n (bot-getnickname)))
-      (if (= 1 talk) (bot-msg n "hey, reviens, on s'amusait bien"))
+  (bot:flushport)
+  (if (not (string-ci=? n (bot:getnickname)))
+      (if (= 1 talk) (bot:msg n "hey, reviens, on s'amusait bien"))
       (let* ((timer (assoc c dumbTimer)))
-        (bot-deltimer (cadr timer))
+        (bot:deltimer (cadr timer))
         (set! dumbTimer (removeChannel c dumbTimer))
         )
       )
   )
-(bot-addhook hooks/part ".*" partLourd)
+(bot:addhook hooks/part ".*" partLourd)
 
 ;;; Random action to say something dumb
 (define dumbList
   )
 (define (dumbLourd c)
   (lambda ()
-    (if (= 1 talk) (bot-say c (list-ref dumbList (bot-random (length dumbList)))))
-    (set! dumbTimer (changeChannel c (bot-addtimer (+ 600 (bot-random 3000)) (dumbLourd c)) dumbTimer))
+    (if (= 1 talk) (bot:say c (list-ref dumbList (bot:random (length dumbList)))))
+    (set! dumbTimer (changeChannel c (bot:addtimer (+ 600 (bot:random 3000)) (dumbLourd c)) dumbTimer))
     )
   )
 
 ;;; Misc
-(bot-addhook hooks/public "oracle" (lambda (f t p) (if (= 1 talk) (bot-say t "oracle ! Un truc de dinosaures, Ã§a !"))))
-(bot-addhook hooks/public "linux" (lambda (f t p) (if (= 1 talk) (bot-say t (string-append f ", j'ai installé une Mandrake chez moi ce week-end, et j'ai réussi Ã  faire marcher l'imprimante")))))
-(bot-addhook hooks/public "boulet" (lambda (f t p) (if (= 1 talk) (bot-say t "on parle de moi ?"))))
-(bot-addhook hooks/public "lourd" (lambda (f t p) (if (= 1 talk) (bot-say t "vous le dites si je suis lourd !"))))
-(bot-addhook hooks/public "csn" (lambda (f t p) (if (= 1 talk) (bot-say t "ahahah, je ne partirai jamais !"))))
-(bot-addhook hooks/public "manger|pizza|pasta" (lambda (f t p) (if (= 1 talk) (bot-say t "je peux venir manger avec vous ?"))))
-(bot-addhook hooks/public "regarde" (lambda (f t p) (if (= 1 talk) (bot-action t "se lève pour regarder..."))))
+(bot:addhook hooks/public "oracle" (lambda (f t p) (if (= 1 talk) (bot:say t "oracle ! Un truc de dinosaures, Ã§a !"))))
+(bot:addhook hooks/public "linux" (lambda (f t p) (if (= 1 talk) (bot:say t (string-append f ", j'ai installé une Mandrake chez moi ce week-end, et j'ai réussi Ã  faire marcher l'imprimante")))))
+(bot:addhook hooks/public "boulet" (lambda (f t p) (if (= 1 talk) (bot:say t "on parle de moi ?"))))
+(bot:addhook hooks/public "lourd" (lambda (f t p) (if (= 1 talk) (bot:say t "vous le dites si je suis lourd !"))))
+(bot:addhook hooks/public "csn" (lambda (f t p) (if (= 1 talk) (bot:say t "ahahah, je ne partirai jamais !"))))
+(bot:addhook hooks/public "manger|pizza|pasta" (lambda (f t p) (if (= 1 talk) (bot:say t "je peux venir manger avec vous ?"))))
+(bot:addhook hooks/public "regarde" (lambda (f t p) (if (= 1 talk) (bot:action t "se lève pour regarder..."))))
 
 ;;; 9h00, on arrive au boulot
 (define (newDay l)
   (if (not (null? l))
       (begin
-        (bot-say (caar l) "Bonjour les gars")
+        (bot:say (caar l) "Bonjour les gars")
         (newDay (cdr l))
         )
       )
 )
-(bot-addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
+(bot:addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
 
 ;;; 18h00, il est temps de rentrer
 (define (timeToGo l)
   (if (not (null? l))
       (begin
-        (bot-say (caar l) "à demain !")
-        (bot-action (caar l) "rentre chez lui...")
+        (bot:say (caar l) "à demain !")
+        (bot:action (caar l) "rentre chez lui...")
         (timeToGo (cdr l))
         )
       )
 )
-(bot-addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))
\ No newline at end of file
+(bot:addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))
\ No newline at end of file
index 3f6df7b..6241c01 100644 (file)
 (define (get-country channel ext)
   (let ((t (assoc (string-upcase! ext) countries)))
     (if t
-        (bot-say channel (string-append ext " is " (cadr t)))
-        (bot-say channel (string-append "I don't know which country stands for " ext)))))
+        (bot:say channel (string-append ext " is " (cadr t)))
+        (bot:say channel (string-append "I don't know which country stands for " ext)))))
 
-(bot-addcommand "country" get-country #t 2 1)
+(bot:addcommand "country" get-country #t 2 1)
index c191153..6a9e6f8 100644 (file)
@@ -3,9 +3,9 @@
 
 (require 'coerce)
 
-(define (bot-eval channel str)
-  (bot-say channel
+(define (bot:eval channel str)
+  (bot:say channel
           (coerce 
           (eval-string str) 'string)))
 
-(bot-addcommand "eval" bot-eval #t 2 4)
\ No newline at end of file
+(bot:addcommand "eval" bot:eval #t 2 4)
\ No newline at end of file
index f10113a..c39b1f4 100644 (file)
@@ -1,8 +1,8 @@
 (define (hello c n)
         (if (string=? n "")
-            (bot-say c "Hello world !")
-            (bot-say c (string-append "Hello " n " !"))
+            (bot:say c "Hello world !")
+            (bot:say c (string-append "Hello " n " !"))
         )
 )
 
-(bot-addcommand "hello" hello #t 2 0)
+(bot:addcommand "hello" hello #t 2 0)
dissimilarity index 64%
index 072e041..63db7bc 100644 (file)
@@ -1,32 +1,32 @@
-;;; -*- guile-scheme -*-
-;;; test of bot-adduser
-(load "bobot-utils.scm")
-
-;;; test this!
-(define (scheme-adduser who channel level protect aop expire passwd)
-  (let ((level (string->number level))
-       (protect (string->number protect))
-       (aop 
-        (if (= 1 (string->number aop))
-          #t #f ))
-       (expire (string->number expire)))
-    (bot-adduser who channel level protect aop expire passwd)))
-
-(bot-addcommand "sadduser" scheme-adduser #f 7 4)
-
-(define (test-adduser)
-  (bot-log "Adding lap_r_g\n") 
-  (bot-adduser "lap_r_g" "#*" 4 0 #f)
-  (bot-log "Adding CowBot\n") 
-  (bot-adduser "CowBot" "#*" 2 0 #f "2M18H")
-  (bot-log "Adding ZugBut\n")
-  (bot-adduser "ZugBot" "#*" 2 0 #f "1Y" "moo")
-  (bot-log "Done...\n"))
-
-(bot-addcommand "testadduser" test-adduser #f 0 4)
-
-(define (test-addshit)
-  (bot-log "Adding root")
-  (bot-addshit "*!root@*.*" "*" 2))
-
-;(bot-addcommand "testaddshit" test-addshit #f 0 4)
\ No newline at end of file
+;;; -*- guile-scheme -*-
+;;; test of bot:adduser
+(load "bobot:utils.scm")
+
+;;; test this!
+(define (scheme-adduser who channel level protect aop expire passwd)
+  (let ((level (string->number level))
+       (protect (string->number protect))
+       (aop 
+        (if (= 1 (string->number aop))
+          #t #f ))
+       (expire (string->number expire)))
+    (bot:adduser who channel level protect aop expire passwd)))
+
+(bot:addcommand "sadduser" scheme-adduser #f 7 4)
+
+(define (test-adduser)
+  (bot:log "Adding lap_r_g\n") 
+  (bot:adduser "lap_r_g" "#*" 4 0 #f)
+  (bot:log "Adding CowBot\n") 
+  (bot:adduser "CowBot" "#*" 2 0 #f "2M18H")
+  (bot:log "Adding ZugBut\n")
+  (bot:adduser "ZugBot" "#*" 2 0 #f "1Y" "moo")
+  (bot:log "Done...\n"))
+
+(bot:addcommand "testadduser" test-adduser #f 0 4)
+
+(define (test-addshit)
+  (bot:log "Adding root")
+  (bot:addshit "*!root@*.*" "*" 2))
+
+;(bot:addcommand "testaddshit" test-addshit #f 0 4)
\ No newline at end of file
index acf452f..35f29bd 100644 (file)
 ;;; yes, this uses a sql db!
 (use-modules (database simplesql)
             (ice-9 debug))
-(load "../bobot-utils.scm")
+(load "../bobot:utils.scm")
 
 ;;; Activate or desactivate the bot
 (define talk 1)
 
 (define (shutup)
   (set! talk 0))
-(bot-addcommand "shutup" shutup #f 0 2)
+(bot:addcommand "shutup" shutup #f 0 2)
 
 (define (dotalk)
   (set! talk 1))
-(bot-addcommand "talk" dotalk #f 0 2)
+(bot:addcommand "talk" dotalk #f 0 2)
 
 
 ;;; Miscellaneous list functions
 ;;; When someone joins a channel
 (define dumbTimer (list))
 (define (joinLourd n c)
-  (if (string-ci=? n (bot-getnickname))
+  (if (string-ci=? n (bot:getnickname))
     (begin
-      (if (= 1 talk) (bot-say c "I like limos"))
+      (if (= 1 talk) (bot:say c "I like limos"))
       (set! dumbTimer 
-           (addChannel c (bot-addtimer (+ 600 (bot-random 300)) 
+           (addChannel c (bot:addtimer (+ 600 (bot:random 300)) 
                                        (dumbLourd c)) dumbTimer)))
-    (if (= 1 talk) (bot-say c (string-append "Arf Moo Arf! " n
+    (if (= 1 talk) (bot:say c (string-append "Arf Moo Arf! " n
                                             " I like pizza...")))))
-(bot-addhook hooks/join ".*" joinLourd)
+(bot:addhook hooks/join ".*" joinLourd)
 
 ;;; When someone leaves the channel
 (define (partLourd n c)
-  (bot-flushport)
-  (if (not (string-ci=? n (bot-getnickname)))
-      (if (= 1 talk) (bot-msg n "I HATED YOU ANYWAY"))
+  (bot:flushport)
+  (if (not (string-ci=? n (bot:getnickname)))
+      (if (= 1 talk) (bot:msg n "I HATED YOU ANYWAY"))
       (let* ((timer (assoc c dumbTimer)))
-        (bot-deltimer (cadr timer))
+        (bot:deltimer (cadr timer))
         (set! dumbTimer (removeChannel c dumbTimer)))))
-(bot-addhook hooks/part ".*" partLourd)
+(bot:addhook hooks/part ".*" partLourd)
 
 ;;; Random action to say something dumb
  (define (dumbLourd c)
    (lambda ()
    (if (= 1 talk) 
-     (bot-say 
+     (bot:say 
       c 
-      (vector-ref (list-ref dumbList (bot-random (length dumbList))) 0)))
+      (vector-ref (list-ref dumbList (bot:random (length dumbList))) 0)))
    (set! dumbTimer 
        (changeChannel 
         c
-        (bot-addtimer (+ 600 (bot-random 300)) (dumbLourd c)) dumbTimer))))
+        (bot:addtimer (+ 600 (bot:random 300)) (dumbLourd c)) dumbTimer))))
 
 
 (define dumbDB (simplesql-open 'postgresql "bot_sayings"))
 ;(define dumbList #f)
 ; (define (reload-sayings)
 ;   (set! dumbList (cdr (simplesql-query dumbDB "SELECT saying FROM sayings")))
-;   (display "Reloaded sayings from db\n" (bot-logport))
-;   (bot-flushport))
-; (bot-addcommand "reloadsayings" reload-sayings #f 0 4)
+;   (display "Reloaded sayings from db\n" (bot:logport))
+;   (bot:flushport))
+; (bot:addcommand "reloadsayings" reload-sayings #f 0 4)
 ; (reload-sayings)
 
 (define (_length db)
 
 
 (define (random-saying)
-  (vector-ref (_select dumbDB (bot-random (_length dumbDB))) 0))
+  (vector-ref (_select dumbDB (bot:random (_length dumbDB))) 0))
 
 ;;; Misc
 ;;; note that public hooks match the channel name too!
 ;;; match-not-channel prevents this
 
 ;;; this should be the first so it doesn't clobber the other hooks
-(bot-addhook 
+(bot:addhook 
  hooks/public (match-to-me "")
  (lambda (f t p)
    (if (= 1 talk)
-     (bot-say t
+     (bot:say t
              (string-append f ": " (random-saying))))) -50 #f)
 
 
-(bot-addhook hooks/public (match-not-channel "oracle")
+(bot:addhook hooks/public (match-not-channel "oracle")
             (lambda (f t p) 
               (if (= 1 talk) 
-                (bot-say t "Oracle is evil! Use Postgres instead!"))))
+                (bot:say t "Oracle is evil! Use Postgres instead!"))))
 
 (define (add-gnu word)
-  (bot-addhook hooks/public (match-not-channel word)
+  (bot:addhook hooks/public (match-not-channel word)
             (lambda (f t p) 
               (if (= 1 talk)
-                (bot-say t 
+                (bot:say t 
                          (string-append f ": I hope you meant GNU!"))))))
 (map add-gnu '("[^/g]linux" "microsoft" "bsd"))
 
-(bot-addhook hooks/public (match-not-channel "boulet")
+(bot:addhook hooks/public (match-not-channel "boulet")
             (lambda (f t p) 
-              (if (= 1 talk) (bot-say t "on parle de moi ?"))))
+              (if (= 1 talk) (bot:say t "on parle de moi ?"))))
 
-(bot-addhook hooks/public (match-not-channel "arf")
+(bot:addhook hooks/public (match-not-channel "arf")
             (lambda (f t p) 
               (if (= 1 talk) 
-                (bot-say t (random-saying)))))
+                (bot:say t (random-saying)))))
 
-(bot-addhook hooks/public (match-not-channel "csn")
+(bot:addhook hooks/public (match-not-channel "csn")
             (lambda (f t p) 
-              (if (= 1 talk) (bot-say t "???"))))
+              (if (= 1 talk) (bot:say t "???"))))
 
-(bot-addhook hooks/public (match-not-channel "pizza|pasta|soda")
+(bot:addhook hooks/public (match-not-channel "pizza|pasta|soda")
             (lambda (f t p)
               (if (= 1 talk) 
-                (bot-say t (string-append f ": give me one too!")))))
+                (bot:say t (string-append f ": give me one too!")))))
 
 (define (add-foul word)
-  (bot-addhook hooks/public (match-not-channel word)
+  (bot:addhook hooks/public (match-not-channel word)
             (lambda (f t p) 
               (if (= 1 talk)
-                (bot-action 
+                (bot:action 
                  t (string-append "hits " f 
                                   " for having a potty mouth"))))))
 (map add-foul '("bitch" "fuck" "whore" "cunt" "tit" "shit" "dick" "cock"))
 
-(bot-addhook hooks/public (match-not-channel "anal sex")
+(bot:addhook hooks/public (match-not-channel "anal sex")
             (lambda (f t p) 
               (if (= 1 talk)
                 (if (not (string-match "unknown_lamer" f))
-                  (bot-action 
+                  (bot:action 
                    t (string-append "grabs " f 
                                     " and buggers " f " up the ass"))))))
 
-(bot-addhook 
+(bot:addhook 
  hooks/public (match-not-channel "[[:space:]]*lame[[:space:]]+")
  (lambda (f t p)
    (if (= 1 talk)
-     (bot-say t
+     (bot:say t
              (string-append f ": NO NO YOU ARE THE LAMER")))))
 
-(bot-addhook hooks/public (match-to-me "burn")
+(bot:addhook hooks/public (match-to-me "burn")
             (lambda (f t p)
               (if (= 1 talk)
-                (bot-say
+                (bot:say
                  t
                  (string-append "How about you burn " f "?")))))
             
 ;(define (newDay l)
 ;  (if (not (null? l))
 ;      (begin
-;        (bot-say (caar l) "What is up my homey g-d0g?")
+;        (bot:say (caar l) "What is up my homey g-d0g?")
 ;        (newDay (cdr l))
 ;        )
 ;      )
 ;)
 
-;(bot-addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
+;(bot:addhook hooks/timer "09:00" (lambda (h) (newDay dumbTimer) (talk)))
 
 ;;; 18h00, il est temps de rentrer
 ;(define (timeToGo l)
 ;  (if (not (null? l))
 ;      (begin
-;        (bot-say (caar l) "Give me food")
-;        (bot-action (caar l) "I'm bored")
+;        (bot:say (caar l) "Give me food")
+;        (bot:action (caar l) "I'm bored")
 ;        (timeToGo (cdr l))
 ;        )
 ;      )
 ;)
-;(bot-addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))
\ No newline at end of file
+;(bot:addhook hooks/timer "18:00" (lambda (h) (timeToGo dumbTimer) (shutup)))
\ No newline at end of file
index cff6b2c..559fe43 100644 (file)
 (define (tamere w)
   (string-append w
    ", ta mère "
-   (list-ref where (bot-random (length where))) " "
-   (list-ref how (bot-random (length how)))))
+   (list-ref where (bot:random (length where))) " "
+   (list-ref how (bot:random (length how)))))
 
-(define (bot-tamere c w)
-  (bot-say c (tamere w)))
+(define (bot:tamere c w)
+  (bot:say c (tamere w)))
 
-(bot-addcommand "tamere" bot-tamere #t 2 1)
+(bot:addcommand "tamere" bot:tamere #t 2 1)
index 6d90b5a..d528892 100644 (file)
@@ -4,6 +4,6 @@
   (let* ((p (open-input-pipe "/bin/uname -a"))
          (s (read-line p)))
   (close-pipe p)
-  (bot-say c s)))
+  (bot:say c s)))
 
-(bot-addcommand "uname" uname #t 0 1)
+(bot:addcommand "uname" uname #t 0 1)
index f681a1b..b847838 100644 (file)
@@ -4,6 +4,6 @@
   (let* ((p (open-input-pipe "/usr/bin/uptime"))
          (s (read-line p)))
   (close-pipe p)
-  (bot-say c s)))
+  (bot:say c s)))
 
-(bot-addcommand "uptime" uptime #t 0 1)
+(bot:addcommand "uptime" uptime #t 0 1)
index f372f60..4b8c836 100644 (file)
@@ -40,6 +40,7 @@
 #define DEFAULT_HELPFILENAME "bot.help"
 #define DEFAULT_SCRIPTLOGFILENAME "script.log"
 #define DEFAULT_LOGFILENAME "bot.log"
+#define DEFAULT_LOGDIR getenv ("HOME") + String("/.bobotpp/logs/")
 #define DEFAULT_INITFILENAME "bot.init"
 #ifdef USESCRIPTS
 #define DEFAULT_AUTOEXECFILENAME "bot.autoexec"
@@ -58,6 +59,7 @@ Bot::Bot(String filename, bool debug_on)
     userListFileName(DEFAULT_USERLISTFILENAME),
     shitListFileName(DEFAULT_SHITLISTFILENAME),
     logFileName(DEFAULT_LOGFILENAME),
+    logs_dir (DEFAULT_LOGDIR),
     helpFileName(DEFAULT_HELPFILENAME),
     initFileName(DEFAULT_INITFILENAME),
 #ifdef USESCRIPTS
@@ -88,10 +90,10 @@ Bot::Bot(String filename, bool debug_on)
   }
 
 #if HAVE_IOSBASE
-  logFile.open(logFileName, std::ios_base::out | std::ios_base::ate 
-              | std::ios_base::app);
+  logFile.open(logs_dir + logFileName, std::ios_base::out | 
+              std::ios_base::ate | std::ios_base::app);
 #else
- logFile.open(logFileName, ios::out | ios::ate 
+ logFile.open(logs_dir + logFileName, ios::out | ios::ate 
              | ios::app);
 #endif
   logLine("Starting log.");
@@ -153,7 +155,7 @@ Bot::Bot(String filename, bool debug_on)
 
   std::srand (std::time (0)); // srand for bot-random
 #ifdef USESCRIPTS
-  botInterp = new BotInterp(this, scriptLogFileName);
+  botInterp = new BotInterp(this, logs_dir + scriptLogFileName);
   botInterp->LoadScript(autoexecFileName);
 #endif
 }
@@ -273,7 +275,7 @@ Bot::readConfig()
       }
     }
     else if (command == "LOGFILE")
-      logFileName = parameters;
+       logFileName = parameters;
 #ifdef USESCRIPTS
     else if (command == "SCRIPTLOGFILE")
       scriptLogFileName = parameters;
index 726c882..67bf12b 100644 (file)
@@ -67,16 +67,10 @@ public:
   String localIP;
   char commandChar;
 
-  String configFileName;
   String userListFileName;
   String shitListFileName;
-  String logFileName;
   String helpFileName;
   String initFileName;
-#ifdef USESCRIPTS
-  String scriptLogFileName;
-  String autoexecFileName;
-#endif
 
   std::ofstream logFile;
 
@@ -117,6 +111,15 @@ public:
   static const std::time_t PING_TIME = 90;
   static const std::time_t TIMEOUT = 120;
 
+private:
+  String logFileName;
+  String logs_dir;
+  String configFileName;
+#ifdef USESCRIPTS
+  String scriptLogFileName;
+  String autoexecFileName;
+#endif
+
 public:
 
   Bot(String, bool=false);
@@ -131,6 +134,7 @@ public:
 
   void reconnect();
 
+
   friend class Parser;
   friend class DCCParser;
   friend class Person;
index f1090d4..f4de9ee 100644 (file)
@@ -51,77 +51,18 @@ Interp::Startup()
 {
 //  scm_primitive_load_path(scm_makfrom0str("ice-9/boot-9.scm"));
 
-  scm_c_define ("bot-sys-scripts-dir", 
+  // Symbols
+  // bot:user-*
+  scm_c_define ("bot:user-none", scm_long2num (User::NONE));
+  scm_c_define ("bot:user-user", scm_long2num (User::USER));
+  scm_c_define ("bot:user-trusted", scm_long2num (User::TRUSTED_USER));
+  scm_c_define ("bot:user-friend", scm_long2num (User::FRIEND));
+  scm_c_define ("bot:user-master", scm_long2num (User::MASTER));
+  // sys-dir
+  scm_c_define ("bot:sys-scripts-dir", 
                scm_makfrom0str (String(PREFIX) + 
                                 "/share/bobotpp/scripts/"));
-  scm_primitive_load 
-    (scm_makfrom0str (String(PREFIX) + 
-                     "/share/bobotpp/scripts/bobot-utils.scm"));
-
-  bot_new_procedure ("bot-action", (SCMFunc)ScriptCommands::Action, 2, 0, 0);
-  scm_c_define_gsubr ("bot-adduser", 5, 2, 0,
-                     (SCMFunc)ScriptCommands::AddUser);
-  bot_new_procedure ("bot-addserver", (SCMFunc)ScriptCommands::Action, 
-                    3, 4, 0);
-  scm_c_define_gsubr ("bot-addshit", 3, 2, 0, 
-                     (SCMFunc)ScriptCommands::AddShit);
-  bot_new_procedure ("bot-ban", (SCMFunc)ScriptCommands::Action, 2, 0, 0);
-  bot_new_procedure ("bot-cycle", (SCMFunc)ScriptCommands::Action, 1, 0, 0);
-  bot_new_procedure ("bot-deban", (SCMFunc)ScriptCommands::Deban, 2, 0, 0);
-  bot_new_procedure ("bot-delserver", (SCMFunc)ScriptCommands::DelServer, 
-                    1, 0, 0);
-  bot_new_procedure ("bot-deluser", (SCMFunc)ScriptCommands::DelUser, 2, 0, 0);
-  bot_new_procedure ("bot-delshit", (SCMFunc)ScriptCommands::DelShit, 2, 0, 0);
-  bot_new_procedure ("bot-deop", (SCMFunc)ScriptCommands::Deop, 2, 0, 0);
-  bot_new_procedure ("bot-die", (SCMFunc)ScriptCommands::Die, 1, 0, 0);
-  bot_new_procedure ("bot-do", (SCMFunc)ScriptCommands::Do, 1, 0, 0);
-  bot_new_procedure ("bot-invite", (SCMFunc)ScriptCommands::Invite, 2, 0, 0);
-  bot_new_procedure ("bot-join", (SCMFunc)ScriptCommands::Join, 1, 1, 0);
-  bot_new_procedure ("bot-keep", (SCMFunc)ScriptCommands::Keep, 2, 0, 0);
-  bot_new_procedure ("bot-kick", (SCMFunc)ScriptCommands::Kick, 2, 1, 0);
-  bot_new_procedure ("bot-kickban", (SCMFunc)ScriptCommands::KickBan, 2, 1, 0);
-  bot_new_procedure ("bot-lock", (SCMFunc)ScriptCommands::Lock, 1, 0, 0);
-  bot_new_procedure ("bot-logport", (SCMFunc)ScriptCommands::LogPort, 0, 0, 0);
-  bot_new_procedure ("bot-mode", (SCMFunc)ScriptCommands::Mode, 2, 0, 0);
-  bot_new_procedure ("bot-msg", (SCMFunc)ScriptCommands::Msg, 2, 0, 0);
-  bot_new_procedure ("bot-nextserver", (SCMFunc)ScriptCommands::NextServer, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-nick", (SCMFunc)ScriptCommands::Nick, 1, 0, 0);
-  bot_new_procedure ("bot-op", (SCMFunc)ScriptCommands::Op, 2, 0, 0);
-  bot_new_procedure ("bot-part", (SCMFunc)ScriptCommands::Part, 1, 0, 0);
-  bot_new_procedure ("bot-reconnect", (SCMFunc)ScriptCommands::Reconnect, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-say", (SCMFunc)ScriptCommands::Say, 2, 0, 0);
-  bot_new_procedure ("bot-server", (SCMFunc)ScriptCommands::Server, 1, 0, 0);
-  bot_new_procedure ("bot-setversion", (SCMFunc)ScriptCommands::SetVersion, 
-                    1, 0, 0);
-  bot_new_procedure ("bot-tban", (SCMFunc)ScriptCommands::TBan, 3, 0, 0);
-  bot_new_procedure ("bot-tkban", (SCMFunc)ScriptCommands::TKBan, 3, 1, 0);
-  bot_new_procedure ("bot-topic", (SCMFunc)ScriptCommands::Topic, 2, 0, 0);
-  bot_new_procedure ("bot-unlock", (SCMFunc)ScriptCommands::Unlock, 1, 0, 0);
-
-  bot_new_procedure ("bot-getnickname", (SCMFunc)ScriptCommands::getNickname, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-getserver", (SCMFunc)ScriptCommands::getServer, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-getserverlist", 
-                    (SCMFunc)ScriptCommands::getServerList, 0, 0, 0);
-  bot_new_procedure ("bot-flush", (SCMFunc)ScriptCommands::flushQueue, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-flushport", (SCMFunc)ScriptCommands::flushPort, 
-                    0, 0, 0);
-  bot_new_procedure ("bot-random", (SCMFunc)ScriptCommands::random, 
-                    1, 0, 0);
-  bot_new_procedure ("bot-addcommand", (SCMFunc)ScriptCommands::addCommand, 
-                    5, 0, 0);
-  bot_new_procedure ("bot-delcommand", (SCMFunc)ScriptCommands::delCommand, 
-                    1, 0, 0);
-  bot_new_procedure ("bot-addhook", (SCMFunc)ScriptCommands::AddHook, 
-                    3, 2, 0);
-  bot_new_procedure ("bot-addtimer", (SCMFunc)ScriptCommands::AddTimer, 
-                    2, 0, 0);
-  bot_new_procedure ("bot-deltimer", (SCMFunc)ScriptCommands::DelTimer, 
-                    1, 0, 0);
+  // Hooks
   scm_c_define ("hooks/action", scm_long2num(Hook::ACTION));
   scm_c_define ("hooks/nickname", scm_long2num(Hook::NICKNAME));
   scm_c_define ("hooks/signoff", scm_long2num(Hook::SIGNOFF));
@@ -143,6 +84,79 @@ Interp::Startup()
   scm_c_define ("hooks/raw", scm_long2num(Hook::RAW));
   scm_c_define ("hooks/timer", scm_long2num(Hook::TIMER));
   scm_c_define ("hooks/topic", scm_long2num(Hook::TOPIC));
+
+
+  // procedures
+  bot_new_procedure ("bot:action", (SCMFunc)ScriptCommands::Action, 2, 0, 0);
+  scm_c_define_gsubr ("bot:adduser", 5, 2, 0,
+                     (SCMFunc)ScriptCommands::AddUser);
+  bot_new_procedure ("bot:addserver", (SCMFunc)ScriptCommands::Action, 
+                    3, 4, 0);
+  scm_c_define_gsubr ("bot:addshit", 3, 2, 0, 
+                     (SCMFunc)ScriptCommands::AddShit);
+  bot_new_procedure ("bot:ban", (SCMFunc)ScriptCommands::Action, 2, 0, 0);
+  bot_new_procedure ("bot:cycle", (SCMFunc)ScriptCommands::Action, 1, 0, 0);
+  bot_new_procedure ("bot:deban", (SCMFunc)ScriptCommands::Deban, 2, 0, 0);
+  bot_new_procedure ("bot:delserver", (SCMFunc)ScriptCommands::DelServer, 
+                    1, 0, 0);
+  bot_new_procedure ("bot:deluser", (SCMFunc)ScriptCommands::DelUser, 2, 0, 0);
+  bot_new_procedure ("bot:delshit", (SCMFunc)ScriptCommands::DelShit, 2, 0, 0);
+  bot_new_procedure ("bot:deop", (SCMFunc)ScriptCommands::Deop, 2, 0, 0);
+  bot_new_procedure ("bot:die", (SCMFunc)ScriptCommands::Die, 1, 0, 0);
+  bot_new_procedure ("bot:do", (SCMFunc)ScriptCommands::Do, 1, 0, 0);
+  bot_new_procedure ("bot:invite", (SCMFunc)ScriptCommands::Invite, 2, 0, 0);
+  bot_new_procedure ("bot:join", (SCMFunc)ScriptCommands::Join, 1, 1, 0);
+  bot_new_procedure ("bot:keep", (SCMFunc)ScriptCommands::Keep, 2, 0, 0);
+  bot_new_procedure ("bot:kick", (SCMFunc)ScriptCommands::Kick, 2, 1, 0);
+  bot_new_procedure ("bot:kickban", (SCMFunc)ScriptCommands::KickBan, 2, 1, 0);
+  bot_new_procedure ("bot:lock", (SCMFunc)ScriptCommands::Lock, 1, 0, 0);
+  bot_new_procedure ("bot:logport", (SCMFunc)ScriptCommands::LogPort, 0, 0, 0);
+  bot_new_procedure ("bot:mode", (SCMFunc)ScriptCommands::Mode, 2, 0, 0);
+  bot_new_procedure ("bot:msg", (SCMFunc)ScriptCommands::Msg, 2, 0, 0);
+  bot_new_procedure ("bot:nextserver", (SCMFunc)ScriptCommands::NextServer, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:nick", (SCMFunc)ScriptCommands::Nick, 1, 0, 0);
+  bot_new_procedure ("bot:op", (SCMFunc)ScriptCommands::Op, 2, 0, 0);
+  bot_new_procedure ("bot:part", (SCMFunc)ScriptCommands::Part, 1, 0, 0);
+  bot_new_procedure ("bot:reconnect", (SCMFunc)ScriptCommands::Reconnect, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:say", (SCMFunc)ScriptCommands::Say, 2, 0, 0);
+  bot_new_procedure ("bot:server", (SCMFunc)ScriptCommands::Server, 1, 0, 0);
+  bot_new_procedure ("bot:setversion", (SCMFunc)ScriptCommands::SetVersion, 
+                    1, 0, 0);
+  bot_new_procedure ("bot:tban", (SCMFunc)ScriptCommands::TBan, 3, 0, 0);
+  bot_new_procedure ("bot:tkban", (SCMFunc)ScriptCommands::TKBan, 3, 1, 0);
+  bot_new_procedure ("bot:topic", (SCMFunc)ScriptCommands::Topic, 2, 0, 0);
+  bot_new_procedure ("bot:unlock", (SCMFunc)ScriptCommands::Unlock, 1, 0, 0);
+
+  bot_new_procedure ("bot:getnickname", (SCMFunc)ScriptCommands::getNickname, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:getserver", (SCMFunc)ScriptCommands::getServer, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:getserverlist", 
+                    (SCMFunc)ScriptCommands::getServerList, 0, 0, 0);
+  bot_new_procedure ("bot:flush", (SCMFunc)ScriptCommands::flushQueue, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:flushport", (SCMFunc)ScriptCommands::flushPort, 
+                    0, 0, 0);
+  bot_new_procedure ("bot:random", (SCMFunc)ScriptCommands::random, 
+                    1, 0, 0);
+  bot_new_procedure ("bot:addcommand", (SCMFunc)ScriptCommands::addCommand, 
+                    5, 0, 0);
+  bot_new_procedure ("bot:delcommand", (SCMFunc)ScriptCommands::delCommand, 
+                    1, 0, 0);
+  bot_new_procedure ("bot:addhook", (SCMFunc)ScriptCommands::AddHook, 
+                    3, 2, 0);
+  bot_new_procedure ("bot:addtimer", (SCMFunc)ScriptCommands::AddTimer, 
+                    2, 0, 0);
+  bot_new_procedure ("bot:deltimer", (SCMFunc)ScriptCommands::DelTimer, 
+                    1, 0, 0);
+  // load bobot-utils
+  scm_primitive_load 
+    (scm_makfrom0str (String(PREFIX) + 
+                     "/share/bobotpp/scripts/bobot-utils.scm"));
+
+
 }
 
 void
index 17f7f91..d62ef0b 100644 (file)
@@ -26,6 +26,9 @@
 #include <csignal>
 #include <cstdlib>
 #include <getopt.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <sys/types.h>
 
 #ifdef USESCRIPTS
 #include "Interp.H"
@@ -181,6 +184,13 @@ static void real_main(void* DONOTUSE, int argc, char **argv)
       exit(1);
     }
 
+  DIR * temp;
+  if (! (temp = opendir (String(getenv ("HOME")) + "/.bobotpp/logs")))
+    mkdir (String(getenv ("HOME")) + "/.bobotpp/logs",
+          S_IRWXU);
+  else
+    closedir (temp);
+
   if (!cmd_directory.length ())
     {
       if (chdir(user_directory + user_subdir) < 0)
@@ -204,6 +214,9 @@ static void real_main(void* DONOTUSE, int argc, char **argv)
   //    "under certain conditions; See the COPYING file for details.\n";
   print_version ();
 
+  // initialize the Parser
+  Parser::init ();
+
   if (!debug) {
     if (background)
       switch (fork()) {
index 42417e2..7d64cab 100644 (file)
 #include "Utils.H"
 #include "ShitList.H"
 
-struct {
-  char *name;
-  void (*function)(ServerConnection *, Person *, String);
-} functions[] =
-{
-  { "001",     Parser::parse001     }, /* RPL_WELCOME */
-  { "302",     Parser::parse302     }, /* RPL_USERHOST */
-  { "311",     Parser::parse311     }, /* RPL_WHOISUSER */
-  { "315",     Parser::parse315     }, /* RPL_ENDOFWHO */
-  { "324",     Parser::parse324     }, /* RPL_CHANNELMODEIS */
-  { "332",     Parser::parse332     }, /* RPL_TOPIC */
-  { "352",     Parser::parse352     }, /* RPL_WHOREPLY */
-  { "353",     Parser::parse353     }, /* RPL_NAMESREPLY */
-  { "366",     Parser::parse366     }, /* RPL_ENDOFNAMES */
-  { "367",     Parser::parse367     }, /* RPL_BANLIST */
-  { "401",     Parser::parse401     }, /* ERR_NOSUCHNICK */
-  { "433",     Parser::parse433     }, /* ERR_NICKNAMEINUSE */
-  { "437",     Parser::parse433     }, /* ERR_UNAVAILRESOURCE */
-  { "471",     Parser::parse473     }, /* ERR_CHANNELISFULL */
-  { "473",     Parser::parse473     }, /* ERR_INVITEONLYCHAN */
-  { "474",     Parser::parse473     }, /* ERR_BANNEDFROMCHAN */
-  { "475",     Parser::parse473     }, /* ERR_BADCHANNELKEY */
-  { "ERROR",   Parser::parseError   },
-  { "INVITE",  Parser::parseInvite  },
-  { "JOIN",    Parser::parseJoin    },
-  { "KICK",    Parser::parseKick    },
-  { "MODE",    Parser::parseMode    },
-  { "NICK",    Parser::parseNick    },
-  { "NOTICE",  Parser::parseNotice  },
-  { "PART",    Parser::parsePart    },
-  { "PING",    Parser::parsePing    },
-  { "PONG",    Parser::parsePong    },
-  { "PRIVMSG", Parser::parsePrivmsg },
-  { "QUIT",    Parser::parseQuit    },
-  { "TOPIC",   Parser::parseTopic   },
-  { "",        Parser::parseError   },
-  { 0,         0                    }
-};
+typedef void (*fptr)(ServerConnection *, Person *, String);
+std::map<std::string, fptr, std::less<std::string> > Parser::functions;
+
+void Parser::init ()
+{
+  Parser::functions["001"] = Parser::parse001; /* RPL_WELCOME */
+  Parser::functions["302"] = Parser::parse302; /* RPL_USERHOST */
+  Parser::functions["311"] = Parser::parse311; /* RPL_WHOISUSER */
+  Parser::functions["315"] = Parser::parse315; /* RPL_ENDOFWHO */
+  Parser::functions["324"] = Parser::parse324; /* RPL_CHANNELMODEIS */
+  Parser::functions["332"] = Parser::parse332; /* RPL_TOPIC */
+  Parser::functions["352"] = Parser::parse352; /* RPL_WHOREPLY */
+  Parser::functions["353"] = Parser::parse353; /* RPL_NAMESREPLY */
+  Parser::functions["366"] = Parser::parse366; /* RPL_ENDOFNAMES */
+  Parser::functions["367"] = Parser::parse367; /* RPL_BANLIST */
+  Parser::functions["401"] = Parser::parse401; /* ERR_NOSUCHNICK */
+  Parser::functions["433"] = Parser::parse433; /* ERR_NICKNAMEINUSE */
+  Parser::functions["437"] = Parser::parse433; /* ERR_UNAVAILRESOURCE */
+  Parser::functions["471"] = Parser::parse473; /* ERR_CHANNELISFULL */
+  Parser::functions["473"] = Parser::parse473; /* ERR_INVITEONLYCHAN */
+  Parser::functions["474"] = Parser::parse473; /* ERR_BANNEDFROMCHAN */
+  Parser::functions["475"] = Parser::parse473; /* ERR_BADCHANNELKEY */
+  Parser::functions["ERROR"] = Parser::parseError;
+  Parser::functions["INVITE"] = Parser::parseInvite;
+  Parser::functions["JOIN"] = Parser::parseJoin;
+  Parser::functions["KICK"] = Parser::parseKick ;
+  Parser::functions["MODE"] = Parser::parseMode ;
+  Parser::functions["NICK"] = Parser::parseNick ;
+  Parser::functions["NOTICE"] = Parser::parseNotice;
+  Parser::functions["PART"] = Parser::parsePart;
+  Parser::functions["PING"] = Parser::parsePing;
+  Parser::functions["PONG"] = Parser::parsePong;
+  Parser::functions["PRIVMSG"] = Parser::parsePrivmsg;
+  Parser::functions["QUIT"] = Parser::parseQuit;
+  Parser::functions["TOPIC"] = Parser::parseTopic;
+  Parser::functions[""] = Parser::parseError;
+}
 
 
 void
@@ -91,11 +90,14 @@ Parser::parseLine(ServerConnection * cnx, String line)
   String command = st.nextToken();
   String rest = st.rest();
 
-  for (int i = 0; functions[i].name != 0; i++)
+  /*  for (int i = 0; functions[i].name != 0; i++)
     if (command == functions[i].name) {
       functions[i].function(cnx, from, rest);
       break;
     }
+  */
+  if (fptr temp_func = functions[command])
+    temp_func (cnx, from, rest);
 
   delete from;
 }
@@ -790,12 +792,12 @@ Parser::parseCTCP(ServerConnection *cnx,
     command = st2.nextToken().toUpper();
     if (command == "CHAT") {
       // FIXME: Re-activate and debug DCC
-//       st2.nextToken();
-//       unsigned long address =
-//         htonl(strtoul((const char *)st2.nextToken(), 0, 0));
-//       int port = atoi((const char *)st2.rest());
-//       if (port >= 1024 && Utils::getLevel(cnx->bot, from->getAddress()))
-//         cnx->bot->addDCC(from, address, port);
+      st2.nextToken();
+      unsigned long address =
+       ntohl (strtoul((const char *)st2.nextToken(), 0, 0));
+      int port = atoi((const char *)st2.nextToken ());
+      if (port >= 1024 && Utils::getLevel(cnx->bot, from->getAddress()))
+       cnx->bot->addDCC(from, address, port);
     }
   }
 #ifdef USESCRIPTS
@@ -991,8 +993,8 @@ Parser::parseScriptFunction(ServerConnection *cnx, String channel,
   wd.func = scmFunc;
   wd.args = args_list;
 
-  gh_catch(SCM_BOOL_T, (scm_catch_body_t) scm_apply_wrapper,
-           (void *)&wd, (scm_catch_handler_t) Interp::ErrorHandler,
+  gh_catch(SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper,
+           (void *)&wd, (scm_t_catch_handler) Interp::ErrorHandler,
            0);
 }
 #endif
index 2fe635b..ca36233 100644 (file)
@@ -32,6 +32,9 @@
 #include <libguile.h>
 #endif
 
+#include <map>
+#include <string>
+
 struct userFunctionsStruct {
   String name;
   void (*function)(ServerConnection *, Person *, String, String);
@@ -76,6 +79,7 @@ public:
 
 class Parser {
 public:
+  static void init ();
   static void parseLine(ServerConnection *, String);
 
   static void parse001(ServerConnection *, Person *, String);
@@ -115,6 +119,10 @@ public:
 #endif
 
   static void sendNotice(Person *, String);
+private:
+  
+  typedef void (*fptr)(ServerConnection *, Person *, String);
+  static std::map<std::string, fptr, std::less<std::string> > functions;
 };
 
 #endif
index 62b9f75..8fb7604 100644 (file)
@@ -572,7 +572,7 @@ SCM
 ScriptCommands::AddHook(SCM type, SCM regex, SCM function, SCM pri, SCM fall)
 {
   int priority = 0;
-  bool fallt = false; // does this hook fall through?
+  bool fallt = true; // does this hook fall through?
 
   if (!SCM_UNBNDP (pri))
     priority = scm_num2int (pri, SCM_ARG1, "ScriptCommands::AddHook");
index 588b3a2..1042c77 100644 (file)
@@ -203,7 +203,7 @@ ServerQueue::sendTopic(String channel, String topic)
 void
 ServerQueue::sendUser(String username, String ircname)
 {
-  addLine(String("USER ") + username + " . . :" + ircname,
+  addLine(String("USER ") + username + " 0 * :" + ircname,
           NICK_PRIORITY, NICK_PENALTY, ServerQueueItem::USER);
 }
 
index 0430b16..3e83568 100644 (file)
@@ -1,4 +1,5 @@
 // Socket.C  -*- C++ -*-
+// Copyright (C) 2002 Clinton Ebadi
 // Copyright (c) 1997, 1998 Etienne BERNARD
 
 // This program is free software; you can redistribute it and/or modify
@@ -246,25 +247,26 @@ Socket::readLine()
   int pos = 0, nb;
   char r;
   
-  do {
-    nb = ::read(fd->fd, &r, 1);
-    switch (nb) {
-    case 0:
-      return String("");
-    case -1:
-      if (errno != EINTR && errno != EAGAIN)
-        return String("");
-      sleep(1);
-    }
-
-    if (nb != -1)
-      buf[pos++] = r;
-  } while (r != '\n');
+  do 
+    {
+      nb = ::read(fd->fd, &r, 1);
+      switch (nb) {
+      case 0:
+       return String("");
+      case -1:
+       if (errno != EINTR && errno != EAGAIN)
+         return String("");
+       sleep(1);
+      }
+      
+      if (nb != -1)
+       buf[pos++] = r;
+    } while (r != '\n');
   
-  if (pos > 1 && buf[pos-2] == '\r')
+if (pos > 1 && buf[pos-2] == '\r')
     buf[pos-2] = '\0';
   else
-    buf[pos-1] = '\0';
+  buf[pos-1] = '\0';
 
   return String(buf);
 }
index 1c4aed2..fc10aaf 100644 (file)
@@ -37,7 +37,6 @@ class Socket {
 
   int begin, end;
 
-  char buf[1024];
 
 public:
   Socket();