+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.
====== 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
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)
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
-# 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,
# 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
# 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.
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],
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])
# 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
# ----------------------------
# 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 -*-
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
# 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)
# 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
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])
])
# 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
])
[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
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])
# 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
_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
])
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])])
# 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($@)])
@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
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)
(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
// 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
#include "Bot.H"
#include "DCCConnection.H"
+#include "DCCChatConnection.H"
#include "StringTokenizer.H"
#include "ServerConnection.H"
#include "Utils.H"
}
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())
{
// 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
#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;
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);
--- /dev/null
+// 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);
+}
--- /dev/null
+// 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
#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);
+// }
// 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
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
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);
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;
}
#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)
void
DCCPerson::keepAlive()
{
- dcc->autoRemove = false;
+ dcc->set_autoRemove (false);
}
bool
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,
ChannelList.C \
Commands.C \
Connection.C \
+ DCCChatConnection.C \
DCCConnection.C \
DCCManager.H \
DCCManager.C \
ChannelList.H \
Commands.H \
Connection.H \
+ DCCChatConnection.H \
DCCConnection.H \
DCCParser.H \
DCCPerson.H \
// 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
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");
}
// 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
#include "Interp.H"
#include "DCCPerson.H"
#include "DCCManager.H"
+#include "Parser.H"
#include <libguile.h>
#define VERIFY_STRING(par) if (!SCM_STRINGP((par))) \
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)
{
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);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#include "Socket.H"
+#include "Bot.H"
#include <string>
#include <sys/types.h>
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;
}
// 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>
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");