[project @ 2002-07-24 03:05:06 by unknown_lamer]
authorunknown_lamer <unknown>
Wed, 24 Jul 2002 03:05:06 +0000 (03:05 +0000)
committerunknown_lamer <unknown>
Wed, 24 Jul 2002 03:05:06 +0000 (03:05 +0000)
Lots of changes, look at the ChangeLog. Most notable is that the Hooks
system actually works now.

AUTHORS
ChangeLog
NEWS
TODO
bobot++.info
bobot++.texinfo
scripts/bobot-utils.scm
source/Bot.C
source/Bot.H
source/BotInterp.C
source/BotInterp.H

diff --git a/AUTHORS b/AUTHORS
index bfad05b..d80a9a9 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -5,4 +5,4 @@ eb on IRCNet
 
 Current Maintainer (1.98 and above):
 Clinton Ebadi <clinton@unknownlamer.org>
-unknown_lamer on OpenProjects
\ No newline at end of file
+unknown_lamer on OpenProjects and OFTC
index bac2201..bb0ead5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-07-23  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/BotInterp.H (Hook<): Changed behavior of Hook's <. If a
+       hook is greater than or less than the other hook, only the
+       priority is considered. However, if both hooks have the same
+       priority, then the fallthru-ness is considered, with fallthru
+       hooks being greater than non-fallthru hooks.
+       
+       * source/BotInterp.C (hptr_lt): Added this static function to be
+       used to sort the hooks list (now hooks should be sorted using
+       Hook's operator < instead of using pointer comparision, meaning
+       the new hook system will work correctly)
+
+       * scripts/bobot-utils.scm: Make bot:log use for-each instead of
+       map because we don't need the result of the displays (this would
+       just be a list of #<undefined> values and is a waste of memory).
+
 2002-07-13  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * source/Bot.C (Bot): userFunctions is now a map for efficiency
diff --git a/NEWS b/NEWS
index 0aca854..0d44e29 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,7 +1,18 @@
--*- text -*-
-As of version 1.98 unknown_lamer is the new maintainer.
-Also as of version 1.98, you must have Guile 1.5.6+ or 1.6.x in order
-to compile scripting support.
+======================================================================
+====== This is a -*- text -*- file and ===============================
+====== User Visible Changes In Bobot++ ===============================
+======================================================================
+
+IMPORTANT NOTE:
++====================================================================+
+| As of version 1.98 unknown_lamer is the new maintainer.            |
+| Also as of version 1.98, you must have Guile 1.5.6+ or 1.6.x in    |
+| order to compile scripting support.                                |
++====================================================================+
+
+=====================================================================
+====== The News =====================================================
+=====================================================================
 
 Version 2.1.0: Zug Zug
 - Hooks can now be fallthrough or non fallthrough. You can set a hooks
diff --git a/TODO b/TODO
index eb358dc..774f1de 100644 (file)
--- a/TODO
+++ b/TODO
@@ -28,35 +28,18 @@ Networking:
    - Access to repl will require user to authenticate
    - Allow server to be disabled at run because of security...
 * Fix DCC support
-* Add Channel logging (log full text of channel if enabled)
-   - maybe do this as a script (log.scm)
+   - Note that Socket will have a buffer overflow problem with DCC
+     because it uses a buffer of 512 characters, and a DCC line is not
+     limited to 512 chars like an IRC line is. The question is: should
+     I rewrite readLine to be more general (allocate buffer on the
+     fly) or rename readLine to ircReadLine and add a more general
+     readLine? I think I could use a static std::string and have it
+     grow as needed, with a default size of 512.
+* Add Channel logging (log full text of channel if enabled) script
 * Make connecting to irc.oftc.net work...I wonder if their ircd is b0rked
 
-Config: (maybe)
-* Change bot.conf syntax (just load it with guile)
-(set-cmdchar #\!)
-(set-name "DumbBot")
-(set-userlist "bot.users")
-(set-shitlist "bot.shit")
-(set-logfile  "bot.log")
-
-(add-server "irc.openprojects.net")
-(add-server "trollaxor.com")
-
-(add-channel "#bobot") ; all networks
-
-;;; note that (add-server) would be a macro that defines
-;;; a symbol for the network
-(server-add-channel irc.openprojects.net "#umbclinux:::")
-(server-add-channel irc.openprojects.net "#tpu:::")
-;;; add-channels just maps args to server-add-channel
-(server-add-channels trollaxor.com "#trolls:::" "#crapflooders:::")
-(server-set-name trollaxor.com "TrollBot")
-
-  - Support per-server channels, logfiles, cmdchars, everything...
-
 Documentation:
-- Work on Texinfo manual (including scripting section)
+* Work on Texinfo manual (especially scripting section)
 
 Other (post 2.2 release):
 * Remove gh_* when Guile 1.8 is released
\ No newline at end of file
index 492f209..f9b5eb3 100644 (file)
@@ -181,9 +181,10 @@ 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.
+hooks are executed before non-fallthrough hooks of the same priority. 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:
 
@@ -479,14 +480,14 @@ Node: User Levels\7f2673
 Node: Scripting\7f3677
 Node: Adding New Commands\7f4560
 Node: Hooks\7f5803
-Node: Creating a Hook\7f6720
-Node: Hook Types\7f7512
-Node: Scheme User Levels\7f9985
-Node: Sending Messages\7f11114
-Node: High Level Message Functions\7f11682
-Node: Low Level Message Functions\7f11900
-Node: Concept Index\7f12659
-Node: Function Index\7f12841
-Node: Variable Index\7f13102
+Node: Creating a Hook\7f6741
+Node: Hook Types\7f7533
+Node: Scheme User Levels\7f10006
+Node: Sending Messages\7f11135
+Node: High Level Message Functions\7f11703
+Node: Low Level Message Functions\7f11921
+Node: Concept Index\7f12680
+Node: Function Index\7f12862
+Node: Variable Index\7f13123
 \1f
 End Tag Table
index 16cf46f..d8a9356 100644 (file)
@@ -189,10 +189,10 @@ 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. 
+and fallthrough hooks are executed before non-fallthrough hooks of the
+same priority. 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::             
index 3e41396..d1963a3 100644 (file)
@@ -6,7 +6,7 @@
 
 ;;; Why the GPL? Technically anything that uses Bobot++'s functions
 ;;; must be GPLed, so all of your scripts have to be GPLed anyway
-;;; because you are really linking with Bobot++, a GPLed program!
+;;; because you are really linking with Bobot++, a GPLed program.
 
 ;;; Bot load (loads a file from %bot:loadpath)
 
@@ -53,7 +53,7 @@
 ;;; arg is a thunk it will be executed and it's output will be
 ;;; written to the log
 (define (bot:log . messages)
-  (map 
+  (for-each
    (lambda (x)
      (if (thunk? x)
        (display (x) (bot-logport))
index 331b349..6852832 100644 (file)
@@ -82,14 +82,10 @@ Bot::Bot(String filename, bool debug_on)
 
   init_user_functions ();
 
-#if HAVE_IOSBASE
-  logFile.open(logs_dir + logFileName, std::ios_base::out | 
-              std::ios_base::ate | std::ios_base::app);
-#else
- logFile.open(logs_dir + logFileName, ios::out | ios::ate 
-             | ios::app);
-#endif
-  logLine("Starting log.");
+  set_log_dir (logs_dir);
+  set_log_file (logFileName);
+
+
   channelList = new ChannelList();
   serverList = new ServerList();
   readConfig();
@@ -249,7 +245,15 @@ Bot::readConfig()
       }
     }
     else if (command == "LOGFILE")
-       logFileName = parameters;
+      {
+       if (parameters[0] == '/')
+         {
+           set_log_dir ("/");
+           set_log_file (parameters.subString (1));
+         }
+       else
+         set_log_file (parameters);
+      }
 #ifdef USESCRIPTS
     else if (command == "SCRIPTLOGFILE")
       scriptLogFileName = parameters;
@@ -669,3 +673,24 @@ Bot::destroy_user_functions ()
   userFunctions.erase (userFunctions.begin (),
                       userFunctions.end ());
 }
+
+void
+Bot::set_log_file (String name)
+{
+  logFileName = name;
+#if HAVE_IOSBASE
+  logFile.open(logs_dir + logFileName, std::ios_base::out | 
+              std::ios_base::ate | std::ios_base::app);
+#else
+  logFile.open(logs_dir + logFileName, ios::out | ios::ate 
+             | ios::app);
+#endif
+
+  logLine("Starting log.");
+}
+
+void
+Bot::set_log_dir (String dir)
+{
+  logs_dir = dir;
+}
index a0bbcd0..5abd072 100644 (file)
@@ -137,6 +137,9 @@ public:
 
   void reconnect();
 
+  // getters and setters
+  void set_log_dir (String);
+  void set_log_file (String);
 
   friend class Parser;
   friend class DCCParser;
index 00e774a..d678660 100644 (file)
@@ -61,6 +61,14 @@ BotInterp::ScriptLog(SCM throw_args)
   scm_flush(logPort);
 }
 
+namespace
+{
+  bool hptr_lt (const Hook* h, const Hook* h1)
+    // Hook Pointer less than
+    // Used to sort the Hooks list
+  { return *h < *h1; }
+}
+
 bool
 BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall) {
   if (scm_string_p(regex) == SCM_BOOL_F)
@@ -74,6 +82,7 @@ BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall) {
   // First, we check if an hook doesn't exist yet
   std::list<Hook *>::iterator it = hooksMap[hooktype].begin();
   std::list<Hook *>::iterator it2 = hooksMap[hooktype].end();
+
   for ( ; it != it2; ++it)
     // It exists, we replace it.
     if ((*it)->regex_str == rx) {
@@ -82,13 +91,13 @@ BotInterp::AddHook(int hooktype, SCM regex, SCM function, int pri, bool fall) {
       (*it)->function = function;
       (*it)->priority = pri;
       (*it)->fallthru = fall;
-      hooksMap[hooktype].sort ();
+      hooksMap[hooktype].sort (hptr_lt);
       return true;
     }
   // It does not exist, we create it
   hooksMap[hooktype].push_back (new Hook(hooktype, rx, r, 
                                         function, pri, fall));
-  hooksMap[hooktype].sort ();
+  hooksMap[hooktype].sort (hptr_lt);
   return true;
 }
 
index 3485724..c0b37e8 100644 (file)
@@ -46,15 +46,16 @@ struct Hook {
 
   bool operator< (const Hook &h) const
   {
-    if (fallthru && h.fallthru)
-      return priority < h.priority;
-    // fallthru-thru is > non-fallthru thru ALWAYS
+    if (priority < h.priority)
+      return true;
+    else if (priority > h.priority)
+      return false;
+    else if (fallthru && h.fallthru)
+      return false;
     else if (fallthru && !h.fallthru)
       return false;
     else if (!fallthru && h.fallthru)
       return true;
-    else
-      return priority < h.priority;
   }
 
   enum {