[project @ 2004-04-28 03:33:52 by unknown_lamer]
authorunknown_lamer <unknown>
Wed, 28 Apr 2004 03:33:52 +0000 (03:33 +0000)
committerunknown_lamer <unknown>
Wed, 28 Apr 2004 03:33:52 +0000 (03:33 +0000)
Huge Update, see the ChangeLog

25 files changed:
ChangeLog
NEWS
TODO
aclocal.m4
bobot++.texinfo
configure.ac
scripts/bobot-utils.scm
source/Bot.C
source/Bot.H
source/DCCChatConnection.C [new file with mode: 0644]
source/DCCChatConnection.H [new file with mode: 0644]
source/DCCConnection.C
source/DCCConnection.H
source/DCCManager.C
source/DCCParser.C
source/DCCPerson.C
source/Interp.C
source/Makefile.am
source/Parser.C
source/Parser.H
source/ScriptCommands.C
source/ScriptCommands.H
source/Socket.C
source/String.H
source/UserCommands.C

index a1daa8f..13d4c97 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,61 @@
+2004-01-28  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * ChangeLog: Updated copyright notice
+
+2004-01-09  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Interp.C (interp_init_helper): Register
+       bot:change-command-level
+
+       * source/ScriptCommands.C (ChangeCommandLevel): Added
+       ChangeCommandLevel to change the level a user needs to be to run a
+       command
+
+       * source/ScriptCommands.H: Added ChangeCommandLevel
+
+2003-10-12  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/String.H: Changed #define STRING_H to BSTRING_H
+
+2003-08-04  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * scripts/bobot-utils.scm (bot:sent-to-me?): New procedure, used
+       to see if a message was sent to the bot (this is better than
+       bot:match-to-me because the hook isn't invalidated when the bot's
+       nickname changes)
+
+       * source/DCCConnection.H: Added `nuh' back and added an
+       accessor (get_nuh)
+       Added setter `set_autoRemove(bool)'
+
+       * source/DCCConnection.H: Removed all friends
+       Added accessors (get_bot, get_lastSpoken, get_autoRemove; get_bot
+       reveals the pointer to the bot [PRIVATE POINTER] which probably
+       isn't so nice, but there isn't much to be done about it with the
+       current design of the bot)
+
+       * source/DCCChatConnection.H: Removed all friends
+
+       * source/DCCConnection.H: DCCConnection is now a pure virtual
+       class with the subclass DCCChatConnection
+
+2003-07-29  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Socket.C (connect): log errors to the bot log instead of
+       printing to stderr
+
+2003-07-23  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Parser.C (parseMessage): use the find method of std::map
+       to find the command to call instead of [] and then extract the
+       pointer to the userFunction from that if it exists. This appears
+       to fix the crash when one uses an undefined command followed by
+       any defined command.
+
 2003-04-09  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * source/Interp.C (interp_init_helper): Bind bot:setfloodrate to
-       ScriptCmmands::SetFloodRate
+       ScriptCommands::SetFloodRate
 
        * source/ScriptCommands.C (SetFloodRate): New Method: SetFloodRate
 
        * source/Queue.C: Didn't notice iostream.h here! Fixed
 
 
-Copyright 2002 Clinton Ebadi
+Copyright 2002,2003,2004 Clinton Ebadi
 Copying and distribution of this file, with or without modification, are
 permitted provided the copyright notice and this notice are preserved.
diff --git a/NEWS b/NEWS
index 802bfcc..557ded1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,11 +10,29 @@ IMPORTANT NOTES:
 ====== The News =====================================================
 =====================================================================
 
+Version 2.1.4: DCC Support Enhancements
+- Internal Change: DCCConnection is now an abstract class
+- Internal Change: DCCChatConnection provides the functionality of
+  the old DCCConnection so that DCC FILE support can be added
+- New Scheme Procedure: (bot:sent-to-me? message), checks to see if a
+  message was addressed to the bot. This is better than using
+  bot:match-to-me because the hook will continue to function if the
+  bot's nick changes. The only downside to using it is that there may
+  be an increased overhead of calling more hooks than could be called,
+  but that shouldn't be much of a problem.
+- New Scheme Procedure: (bot:change-command-level command level),
+  changes the level a user command to allow a user of `level' level or
+  above to run it.
+
 Version 2.1.3: Something
 - The flood rate can now be set using !setfloodrate INTEGER. The
 default is two messages per second before the bot will ignore
 you. (thanks to Björn Gustavsson for requesting this)
-- The flood rate may also be set from Scheme using (bot:setfloodrate integer)
+- The flood rate may also be set from Scheme using (bot:setfloodrate
+integer)
+- A very large crash bug has been fixed. Previously, if an undefined
+command was called, any attempts to call a subsequent command would
+cause the bot to crash. Now the bot doesn't crash.
 
 Version 2.1.2: Llama
 
diff --git a/TODO b/TODO
index 7f29cdb..8fe2313 100644 (file)
--- a/TODO
+++ b/TODO
@@ -22,12 +22,16 @@ Scripting:
 
 Networking:
 * Add a networked interface to guile repl
+   - This can be done as a script, but requires non-coop threads
+      support to be done easily
    - Admins only
    - Telnet
    - Store authorized users and passwords in bot.telnet file
    - Bot master can add new telnet users
    - MUST HAVE PASSWORD
-* DCC FILE support (this can be done as a script)
+   - Maybe use SSL?
+* DCC FILE support (this can be done as a script if a few changes are
+   made to the DCC support)
 
 Documentation:
 * Work on Texinfo manual (especially scripting section)
@@ -41,4 +45,9 @@ Other (post 2.2 release):
    on top of pthreads, which I could probably use when 1.8 nears
    release.
    UPDATE[2002-12-22]: Guile CVS now has support for full pthreads, no
-   more coop stuff. After 1.8 is released threads will probably be used.
\ No newline at end of file
+   more coop stuff. After 1.8 is released threads will probably be
+   used.
+   - To clarify: There will be one thread for DCCs and another thread
+   for the current irc server connection, each with its own select
+   loop. There may also be a thread for the network repls if I
+   implement that.
\ No newline at end of file
index 11092b3..a7294d9 100644 (file)
@@ -1,6 +1,6 @@
-# aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*-
+# generated automatically by aclocal 1.7.6 -*- Autoconf -*-
 
-# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
 # Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -288,7 +288,7 @@ AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
 # This macro actually does too much some checks are only needed if
 # your package does certain things.  But this isn't really a big deal.
 
-# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
 # Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -306,16 +306,9 @@ AC_DEFUN([GUILE_MODULE_REQUIRED_EXPORT],
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 # 02111-1307, USA.
 
-# serial 8
-
-# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
-# written in clear, in which case automake, when reading aclocal.m4,
-# will think it sees a *use*, and therefore will trigger all it's
-# C support machinery.  Also note that it means that autoscan, seeing
-# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+# serial 10
 
-
-AC_PREREQ([2.52])
+AC_PREREQ([2.54])
 
 # Autoconf 2.50 wants to disallow AM_ names.  We explicitly allow
 # the ones we care about.
@@ -341,6 +334,16 @@ if test "`cd $srcdir && pwd`" != "`pwd`" &&
   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
 fi
 
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
 # Define the identity of the package.
 dnl Distinguish between old-style and new-style calls.
 m4_ifval([$2],
@@ -348,8 +351,8 @@ m4_ifval([$2],
  AC_SUBST([PACKAGE], [$1])dnl
  AC_SUBST([VERSION], [$2])],
 [_AM_SET_OPTIONS([$1])dnl
- AC_SUBST([PACKAGE], [AC_PACKAGE_TARNAME])dnl
- AC_SUBST([VERSION], [AC_PACKAGE_VERSION])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
 
 _AM_IF_OPTION([no-define],,
 [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
@@ -370,19 +373,41 @@ AM_PROG_INSTALL_STRIP
 # some platforms.
 AC_REQUIRE([AC_PROG_AWK])dnl
 AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
 
 _AM_IF_OPTION([no-dependencies],,
-[AC_PROVIDE_IFELSE([AC_PROG_][CC],
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
                   [_AM_DEPENDENCIES(CC)],
-                  [define([AC_PROG_][CC],
-                          defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl
-AC_PROVIDE_IFELSE([AC_PROG_][CXX],
+                  [define([AC_PROG_CC],
+                          defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
                   [_AM_DEPENDENCIES(CXX)],
-                  [define([AC_PROG_][CXX],
-                          defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+                  [define([AC_PROG_CXX],
+                          defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
 ])
 ])
 
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $1 | $1:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
+
 # Copyright 2002  Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
@@ -403,14 +428,14 @@ AC_PROVIDE_IFELSE([AC_PROG_][CXX],
 # ----------------------------
 # Automake X.Y traces this macro to ensure aclocal.m4 has been
 # generated from the m4 files accompanying Automake X.Y.
-AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.6"])
+AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.7"])
 
 # AM_SET_CURRENT_AUTOMAKE_VERSION
 # -------------------------------
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-        [AM_AUTOMAKE_VERSION([1.6.3])])
+        [AM_AUTOMAKE_VERSION([1.7.6])])
 
 # Helper functions for option handling.                    -*- Autoconf -*-
 
@@ -696,9 +721,42 @@ fi
 INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# serial 4                                             -*- Autoconf -*-
+#                                                          -*- Autoconf -*-
+# Copyright (C) 2003  Free Software Foundation, Inc.
+
+# 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, or (at your option)
+# 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.
 
-# Copyright 1999, 2000, 2001 Free Software Foundation, Inc.
+# serial 1
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# serial 5                                             -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003  Free Software Foundation, Inc.
 
 # 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
@@ -759,18 +817,32 @@ AC_CACHE_CHECK([dependency style of $depcc],
   # using a relative directory.
   cp "$am_depcomp" conftest.dir
   cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
 
   am_cv_$1_dependencies_compiler_type=none
   if test "$am_compiler_list" = ""; then
      am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
   fi
   for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
     # We need to recreate these files for each test, as the compiler may
     # overwrite some of them when testing with obscure command lines.
     # This happens at least with the AIX C compiler.
-    echo '#include "conftest.h"' > conftest.c
-    echo 'int i;' > conftest.h
-    echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      : > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
 
     case $depmode in
     nosideeffect)
@@ -788,13 +860,20 @@ AC_CACHE_CHECK([dependency style of $depcc],
     # mode.  It turns out that the SunPro C++ compiler does not properly
     # handle `-M -o', and we need to detect this.
     if depmode=$depmode \
-       source=conftest.c object=conftest.o \
-       depfile=conftest.Po tmpdepfile=conftest.TPo \
-       $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 &&
-       grep conftest.h conftest.Po > /dev/null 2>&1 &&
+       source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
        ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      am_cv_$1_dependencies_compiler_type=$depmode
-      break
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored.
+      if grep 'ignoring option' conftest.err >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
     fi
   done
 
@@ -805,6 +884,9 @@ else
 fi
 ])
 AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
 ])
 
 
@@ -813,16 +895,8 @@ AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
 # Choose a directory name for dependency files.
 # This macro is AC_REQUIREd in _AM_DEPENDENCIES
 AC_DEFUN([AM_SET_DEPDIR],
-[rm -f .deps 2>/dev/null
-mkdir .deps 2>/dev/null
-if test -d .deps; then
-  DEPDIR=.deps
-else
-  # MS-DOS does not allow filenames that begin with a dot.
-  DEPDIR=_deps
-fi
-rmdir .deps 2>/dev/null
-AC_SUBST([DEPDIR])
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
 ])
 
 
@@ -924,7 +998,9 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
      [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
 ])
 
-# Copyright 2001 Free Software Foundation, Inc.             -*- Autoconf -*-
+# Check to see how 'make' treats includes.     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
 # 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
@@ -949,8 +1025,9 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 AC_DEFUN([AM_MAKE_INCLUDE],
 [am_make=${MAKE-make}
 cat > confinc << 'END'
-doit:
+am__doit:
        @echo done
+.PHONY: am__doit
 END
 # If we don't find an include directive, just comment out the code.
 AC_MSG_CHECKING([for style of include used by $am_make])
@@ -964,7 +1041,7 @@ echo "include confinc" > confmf
 # In particular we don't look at `^make:' because GNU make might
 # be invoked under some other name (usually "gmake"), in which
 # case it prints its new name instead of `make'.
-if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then
+if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
    am__include=include
    am__quote=
    _am_result=GNU
@@ -978,9 +1055,9 @@ if test "$am__include" = "#"; then
       _am_result=BSD
    fi
 fi
-AC_SUBST(am__include)
-AC_SUBST(am__quote)
-AC_MSG_RESULT($_am_result)
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
 rm -f confinc confmf
 ])
 
@@ -1024,7 +1101,7 @@ else
 fi
 AC_CONFIG_COMMANDS_PRE(
 [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
-  AC_MSG_ERROR([conditional \"$1\" was never defined.
+  AC_MSG_ERROR([conditional "$1" was never defined.
 Usually this means the macro was only invoked conditionally.])
 fi])])
 
@@ -1051,58 +1128,6 @@ AC_PREREQ([2.52])
 
 # serial 6
 
-# When config.status generates a header, we must update the stamp-h file.
-# This file resides in the same directory as the config header
-# that is generated.  We must strip everything past the first ":",
-# and everything past the last "/".
-
-# _AM_DIRNAME(PATH)
-# -----------------
-# Like AS_DIRNAME, only do it during macro expansion
-AC_DEFUN([_AM_DIRNAME],
-       [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1,
-             m4_if(regexp([$1], [^//\([^/]\|$\)]), -1,
-                   m4_if(regexp([$1], [^/.*]), -1,
-                         [.],
-                         patsubst([$1], [^\(/\).*], [\1])),
-                   patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])),
-             patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl
-])# _AM_DIRNAME
-
-
-# The stamp files are numbered to have different names.
-# We could number them on a directory basis, but that's additional
-# complications, let's have a unique counter.
-m4_define([_AM_STAMP_Count], [0])
-
-
-# _AM_STAMP(HEADER)
-# -----------------
-# The name of the stamp file for HEADER.
-AC_DEFUN([_AM_STAMP],
-[m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl
-AS_ESCAPE(_AM_DIRNAME(patsubst([$1],
-                               [:.*])))/stamp-h[]_AM_STAMP_Count])
-
-
-# _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS)
-# ------------------------------------------------------------
-# We used to try to get a real timestamp in stamp-h.  But the fear is that
-# that will cause unnecessary cvs conflicts.
-AC_DEFUN([_AM_CONFIG_HEADER],
-[# Add the stamp file to the list of files AC keeps track of,
-# along with our hook.
-AC_CONFIG_HEADERS([$1],
-                  [# update the timestamp
-echo 'timestamp for $1' >"_AM_STAMP([$1])"
-$2],
-                  [$3])
-])# _AM_CONFIG_HEADER
-
-
-# AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS)
-# --------------------------------------------------------------
-AC_DEFUN([AM_CONFIG_HEADER],
-[AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])])
-])# AM_CONFIG_HEADER
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
 
index a312228..96c130c 100644 (file)
@@ -24,7 +24,7 @@ Texts.
 @author Clinton Ebadi
 
 @page
-@c @vskip O plus 1filll
+@vskip O plus 1filll
 Copyright @copyright{} 2002 Clinton Ebadi
 
 Permission is granted to copy, distribute and/or modify this document
index cc6f969..add45f6 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PRERQ(2.50)
 dnl AC_INIT(source/Makefile.in)
-AC_INIT([Bobot++], [2.1.3CVS], [clinton@unknownlamer.org], [bobotpp])
+AC_INIT([Bobot++], [2.1.4CVS], [clinton@unknownlamer.org], [bobotpp])
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(config.h)
 
index d5d2950..a3323dc 100644 (file)
   (string-append (bot:match-not-channel (bot:getnickname))
                 "[[:space:][:graph:]]*" regex))
 
+(define-public (bot:sent-to-me? message)
+  (let ((to-me (make-regexp (bot:match-to-me ""))))
+    (if (regexp-exec to-me message) #t #f)))
+
 ;;;; string-utils
 (define-public str-app string-append) ; shorter
 
index 91a35a2..5b59b4c 100644 (file)
@@ -1,6 +1,6 @@
 // Bot.C  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2003 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
@@ -28,6 +28,7 @@
 
 #include "Bot.H"
 #include "DCCConnection.H"
+#include "DCCChatConnection.H"
 #include "StringTokenizer.H"
 #include "ServerConnection.H"
 #include "Utils.H"
@@ -523,10 +524,15 @@ Bot::connect(int serverNumber)
 }
 
 void
-Bot::addDCC(Person * from, unsigned long address, int port)
+Bot::addDCC(Person * from, unsigned long address, int port, int type)
 {
-  DCCConnection * d = new DCCConnection(this, from->getAddress (),
-                                        address, port);
+  DCCConnection *d = 0;
+
+  if (type == CHAT)
+    d = new DCCChatConnection(this, from->getAddress (),
+                             address, port);
+  else
+    return;
 
   if (!d->connect())
     {
index e330345..0158c15 100644 (file)
@@ -1,6 +1,6 @@
 // Bot.H  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (c) 2002 Clinton Ebadi
+// Copyright (c) 2002,2003 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
@@ -46,8 +46,8 @@
 #include <guile/gh.h>
 #endif
 
-#define VERSION_STRING PACKAGE" version "VERSION" by unknown_lamer@OPN <clinton@unknownlamer.org>\n1.97 and below by eb@IRCNet <eb@via.ecp.fr>"
-#define COPYRIGHT_STRING PACKAGE" version "VERSION", Copyright (C) 1997-2000 Etienne BERNARD\nCopyright (C) 2002 Clinton Ebadi"
+#define VERSION_STRING PACKAGE" version "VERSION" by unknown_lamer@FreeNode <clinton@unknownlamer.org>\n1.97 and below by eb@IRCNet <eb@via.ecp.fr>"
+#define COPYRIGHT_STRING PACKAGE" version "VERSION", Copyright (C) 1997-2000 Etienne BERNARD\nCopyright (C) 2002,2003,2004 Clinton Ebadi"
 
 class Channel;
 class DCCConnection;
@@ -155,7 +155,8 @@ private:
   void nextServer();
   void connect(int);
 
-  void addDCC(Person *, unsigned long, int);
+  enum DCC_TYPE { CHAT };
+  void addDCC(Person *, unsigned long, int, int);
 
   void rehash();
   String getUserhost(String, String);
diff --git a/source/DCCChatConnection.C b/source/DCCChatConnection.C
new file mode 100644 (file)
index 0000000..4614ed1
--- /dev/null
@@ -0,0 +1,77 @@
+// DCCConnection.C  -*- C++ -*-
+// Copyright (c) 1998 Etienne BERNARD
+// Copyright (C) 2002 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 <ctime>
+#include <string>
+
+#include "Socket.H"
+#include "DCCParser.H"
+#include "DCCChatConnection.H"
+#include "Person.H"
+#include "BotInterp.H"
+#include "Utils.H"
+
+DCCChatConnection::DCCChatConnection(Bot *b, String n, unsigned long address, 
+                                    int port)
+  : DCCConnection(b, n, address, port)
+{ }
+
+bool
+DCCChatConnection::connect()
+{
+  if (!socket.connect())
+    return false;
+
+#ifdef USESCRIPTS
+  // run hooks/dcc/chat-begin
+  DCCPerson *tmp = new DCCPerson (this);
+  bot->botInterp->RunHooks (Hook::DCC_CHAT_BEGIN, 
+                           tmp->getAddress (),
+                           scm_list_n (Utils::
+                                       string2SCM (tmp->getAddress ()),
+                                       SCM_UNDEFINED));
+  delete tmp;
+#endif
+
+
+  return true;
+}
+
+bool
+DCCChatConnection::handleInput()
+{
+  std::string line = socket.readLine();
+
+  lastSpoken = time(0);
+
+  if (line.length() == 0)
+    return true;
+
+  if (bot->debug)
+    std::cout << "DCC: <" << line << ">" << std::endl;
+
+  DCCParser::parseLine(this, line);
+
+  return false;
+}
+
+void
+DCCChatConnection::sendNotice(String message)
+{
+  socket.write(message, true);
+}
diff --git a/source/DCCChatConnection.H b/source/DCCChatConnection.H
new file mode 100644 (file)
index 0000000..c53d92c
--- /dev/null
@@ -0,0 +1,46 @@
+// DCCChatConnection.H  -*- C++ -*-
+// Copyright (c) 2003 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.
+
+#ifndef DCCCHATCONNECTION_H
+#define DCCCHATCONNECTION_H
+
+#include <ctime>
+
+#include "Connection.H"
+#include "Bot.H"
+#include "DCCPerson.H"
+#include "DCCConnection.H"
+
+class UserCommands;
+
+class DCCChatConnection : public DCCConnection {
+public:
+  DCCChatConnection(Bot *, String, unsigned long, int);
+
+  bool connect();
+  bool handleInput();
+
+  void sendNotice(String);
+
+//   friend class Bot;
+//   friend class DCCPerson;
+//   friend class DCCParser;
+//   friend class UserCommands;
+//   friend class DCCManager;
+};
+
+#endif
index d5cd487..5f2ffea 100644 (file)
 #include "BotInterp.H"
 #include "Utils.H"
 
-DCCConnection::DCCConnection(Bot *b, String n, unsigned long address, 
+DCCConnection::DCCConnection(unsigned long address, 
                             int port)
- : Connection(address, port), bot(b), nuh(n),
-   lastSpoken(time(0)), autoRemove(true)
+  : Connection(address, port)
+{ }
+
+DCCConnection::DCCConnection(Bot *b, String n, unsigned long address, 
+                                    int port)
+  : Connection(address, port), bot(b),lastSpoken(time(0)), autoRemove(true)
 { }
 
-bool
-DCCConnection::connect()
-{
-  if (!socket.connect())
-    return false;
+// bool
+// DCCConnection::connect()
+// {
+//   if (!socket.connect())
+//     return false;
 
-#ifdef USESCRIPTS
-  // run hooks/dcc/chat-begin
-  DCCPerson *tmp = new DCCPerson (this);
-  bot->botInterp->RunHooks (Hook::DCC_CHAT_BEGIN, 
-                           tmp->getAddress (),
-                           scm_list_n (Utils::
-                                       string2SCM (tmp->getAddress ()),
-                                       SCM_UNDEFINED));
-  delete tmp;
-#endif
+// #ifdef USESCRIPTS
+//   // run hooks/dcc/chat-begin
+//   DCCPerson *tmp = new DCCPerson (this);
+//   bot->botInterp->RunHooks (Hook::DCC_CHAT_BEGIN, 
+//                         tmp->getAddress (),
+//                         scm_list_n (Utils::
+//                                     string2SCM (tmp->getAddress ()),
+//                                     SCM_UNDEFINED));
+//   delete tmp;
+// #endif
 
 
-  return true;
-}
+//   return true;
+// }
 
-bool
-DCCConnection::handleInput()
-{
-  std::string line = socket.readLine();
+// bool
+// DCCConnection::handleInput()
+// {
+//   std::string line = socket.readLine();
 
-  lastSpoken = time(0);
+//   lastSpoken = time(0);
 
-  if (line.length() == 0)
-    return true;
+//   if (line.length() == 0)
+//     return true;
 
-  if (bot->debug)
-    std::cout << "DCC: <" << line << ">" << std::endl;
+//   if (bot->debug)
+//     std::cout << "DCC: <" << line << ">" << std::endl;
 
-  DCCParser::parseLine(this, line);
+//   DCCParser::parseLine(this, line);
 
-  return false;
-}
+//   return false;
+// }
 
-void
-DCCConnection::sendNotice(String message)
-{
-  socket.write(message, true);
-}
+// void
+// DCCConnection::sendNotice(String message)
+// {
+//   socket.write(message, true);
+// }
index 31c9e15..8049f15 100644 (file)
@@ -1,6 +1,6 @@
 // DCCConnection.H  -*- C++ -*-
 // Copyright (c) 1998 Etienne BERNARD
-// Copyright (c) 2002 Clinton Ebadi
+// Copyright (c) 2002,2003 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
@@ -29,24 +29,34 @@ class DCCPerson;
 class UserCommands;
 
 class DCCConnection : public Connection {
+protected:
   Bot *bot;
   String nuh;
   std::time_t lastSpoken;
   bool autoRemove;
+  DCCConnection (unsigned long, int);
 
 public:
   DCCConnection(Bot *, String, unsigned long, int);
 
-  bool connect();
-  bool handleInput();
+  virtual bool connect()=0;
+  virtual bool handleInput()=0;
 
-  void sendNotice(String);
+  virtual void sendNotice(String)=0;
 
-  friend class Bot;
-  friend class DCCPerson;
-  friend class DCCParser;
-  friend class UserCommands;
-  friend class DCCManager;
+  // Accessors
+  virtual Bot* get_bot () const { return bot; };
+  virtual std::time_t get_lastSpoken () const { return lastSpoken; };
+  virtual bool get_autoRemove () const { return autoRemove; };
+  virtual String get_nuh () const { return nuh;};
+  // Setters
+  virtual void set_autoRemove (bool new_ar) { autoRemove = new_ar;};
+
+  //  friend class Bot;
+  //  friend class DCCPerson;
+  //  friend class DCCParser;
+  //  friend class UserCommands;
+  //  friend class DCCManager;
 };
 
 #endif
index 7a31e14..8f51521 100644 (file)
@@ -50,8 +50,8 @@ DCCManager::checkStale ()
        it != it2; ++it)
     {
       temp_cnx = it->second->dcc;
-      if (temp_cnx->autoRemove && std::time (0) >= 
-         (std::time_t)(temp_cnx->lastSpoken + Bot::DCC_DELAY))
+      if (temp_cnx->get_autoRemove () && std::time (0) >= 
+         (std::time_t)(temp_cnx->get_lastSpoken () + Bot::DCC_DELAY))
        {
          delete it->second;
          dcc_map.erase (it);
index b34d857..859ce79 100644 (file)
@@ -32,14 +32,15 @@ DCCParser::parseLine(DCCConnection *cnx, String line)
   Person * from = new DCCPerson(cnx);
 #ifdef USESCRIPTS
   // Call hooks/dcc/chat-message hook functions
-  cnx->bot->botInterp->RunHooks (Hook::DCC_CHAT_MESSAGE, 
+  cnx->get_bot()->botInterp->RunHooks (Hook::DCC_CHAT_MESSAGE, 
                                 from->getAddress () + " " + line,
                                 scm_list_n (Utils::
                                             string2SCM (from->getAddress ()),
                                             Utils::string2SCM (line),
                                             SCM_UNDEFINED));
 #endif
-  Parser::parseMessage(cnx->bot->serverConnection, from, cnx->bot->nickName,
+  Parser::parseMessage(cnx->get_bot()->serverConnection, 
+                      from, cnx->get_bot()->nickName,
                        line);
   delete from;
 }
index 24227f1..3eab3e9 100644 (file)
@@ -19,7 +19,7 @@
 #include "DCCPerson.H"
 
 DCCPerson::DCCPerson(DCCConnection *cnx)
-  : Person(cnx->bot, cnx->nuh), dcc(cnx)
+  : Person(cnx->get_bot(), cnx->get_nuh()), dcc(cnx)
 { }
 
 DCCPerson::DCCPerson(DCCPerson &p)
@@ -41,7 +41,7 @@ DCCPerson::copy()
 void
 DCCPerson::keepAlive()
 {
-  dcc->autoRemove = false;
+  dcc->set_autoRemove (false);
 }
 
 bool
index 401d7d5..2940561 100644 (file)
@@ -118,6 +118,8 @@ interp_init_helper (void* unused)
   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:change-command-level", (SCMFunc)ScriptCommands::ChangeCommandLevel,
+                    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, 
index 97f458a..ef77312 100644 (file)
@@ -7,6 +7,7 @@ bobotpp_SOURCES = BanEntry.C \
        ChannelList.C \
        Commands.C \
        Connection.C \
+       DCCChatConnection.C \
        DCCConnection.C \
        DCCManager.H \
        DCCManager.C \
@@ -41,6 +42,7 @@ bobotpp_SOURCES = BanEntry.C \
        ChannelList.H \
        Commands.H \
        Connection.H \
+       DCCChatConnection.H \
        DCCConnection.H \
        DCCParser.H \
        DCCPerson.H \
index a79e92c..030ea8f 100644 (file)
@@ -1,6 +1,6 @@
 // Parser.C  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (C) 2002 Clinton Ebadi
+// Copyright (C) 2002,2003 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
@@ -853,7 +853,7 @@ Parser::parseCTCP (ServerConnection * cnx,
            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);
+           cnx->bot->addDCC (from, address, port, Bot::CHAT);
          else
            cnx->bot->logLine ("DCC Chat Failed in Parser");
        }
index 502eaf6..052bebe 100644 (file)
@@ -1,6 +1,6 @@
 // Parser.H  -*- C++ -*-
 // Copyright (c) 1997, 1998 Etienne BERNARD
-// Copyright (c) 2002 Clinton Ebadi
+// Copyright (c) 2002,2003 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
index 0562cca..241f814 100644 (file)
@@ -30,6 +30,7 @@
 #include "Interp.H"
 #include "DCCPerson.H"
 #include "DCCManager.H"
+#include "Parser.H"
 #include <libguile.h>
 
 #define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \
@@ -146,6 +147,33 @@ ScriptCommands::Ban(SCM channel, SCM who)
   return scm_long2num(m.getCode());
 }
 
+SCM
+ScriptCommands::ChangeCommandLevel(SCM command, SCM level)
+{
+  VERIFY_STRING (command);
+  VERIFY_NUMBER (level);
+
+  SCM_STRING_COERCE_0TERMINATION_X (command);
+  std::string ccommand = SCM_STRING_CHARS (command);
+  unsigned int llevel = scm_num2uint (level, 0, "ScriptCommands::ChangeCommandLevel");
+
+  if (llevel > 4)
+    return SCM_BOOL_F;
+
+  std::map<std::string, class userFunction*, 
+    std::less<std::string> >::const_iterator  uf_iter 
+    = Interp::bot->userFunctions.find (ccommand);
+  userFunction * f = 0;
+  
+  if (uf_iter != Interp::bot->userFunctions.end ())
+    f = uf_iter->second;
+  else
+    return SCM_BOOL_F;
+
+  f->minLevel = llevel;
+  return SCM_BOOL_T;
+}
+
 SCM
 ScriptCommands::Cycle(SCM channel)
 {
index 2c7995b..2ec1301 100644 (file)
@@ -35,7 +35,7 @@ public:
   static SCM AddServer(SCM, SCM);
   static SCM AddShit(SCM, SCM, SCM, SCM, SCM);
   static SCM Ban(SCM, SCM);
-  static SCM ChangeLevel(SCM, SCM, SCM);
+  static SCM ChangeCommandLevel(SCM, SCM);
   static SCM Cycle(SCM);
   static SCM Deban(SCM, SCM);
   static SCM DelServer(SCM);
index 2cacfd3..a2fb81d 100644 (file)
@@ -17,6 +17,7 @@
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
 
 #include "Socket.H"
+#include "Bot.H"
 #include <string>
 
 #include <sys/types.h>
@@ -192,8 +193,8 @@ Socket::connect()
   addr.sin_port = htons(remotePort);
   if (::connect(fd->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0)
     {
-      // I'd rather log this to the log file
-      std::cerr << strerror (errno) << std::endl;
+      //      Bot::logLine (String("Socket Error: ") 
+      //                   + strerror (errno) + String("\n"));
       return false;
     }
   
index 06cda22..697520f 100644 (file)
@@ -16,8 +16,8 @@
 // along with this program; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
 
-#ifndef STRING_H
-#define STRING_H
+#ifndef BSTRING_H
+#define BSTRING_H
 
 #include <iostream>
 #include <string>
index f8a8356..3bcfc50 100644 (file)
@@ -410,9 +410,9 @@ UserCommands::DCCList(ServerConnection *cnx, Person *from,
          cnx->bot->dccConnections->dcc_map.begin ();
         it != cnx->bot->dccConnections->dcc_map.end();
        ++it) {
-    from->sendNotice(String(it->second->dcc->nuh).pad(32) + " " +
+    from->sendNotice(String(it->second->dcc->get_nuh()).pad(32) + " " +
                      String((long)(current_time -
-                                   it->second->dcc->lastSpoken)));
+                                   it->second->dcc->get_lastSpoken())));
   }
 
   from->sendNotice("\002End of dcclist.\002");