[project @ 2003-04-10 01:53:57 by unknown_lamer]
authorunknown_lamer <unknown>
Thu, 10 Apr 2003 01:53:57 +0000 (01:53 +0000)
committerunknown_lamer <unknown>
Thu, 10 Apr 2003 01:53:57 +0000 (01:53 +0000)
Added support for overriding the flood rate

14 files changed:
ChangeLog
NEWS
bobot++.info
bobot++.texinfo
configure.ac
source/Bot.C
source/Bot.H
source/Commands.C
source/Commands.H
source/Interp.C
source/ScriptCommands.C
source/ScriptCommands.H
source/UserCommands.C
source/UserCommands.H

index 7a04d6e..a1daa8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2003-04-09  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * source/Interp.C (interp_init_helper): Bind bot:setfloodrate to
+       ScriptCmmands::SetFloodRate
+
+       * source/ScriptCommands.C (SetFloodRate): New Method: SetFloodRate
+
+       * source/Bot.C (init_user_functions): Make SETFLOODRATE available
+       to bot master
+
+       * source/Bot.H: Made MAX_MESSAGES writeable
+
+       * source/UserCommands.H: New method: SetFloodRate
+
+       * source/Commands.H: New method: SetFloodRate
+
+2003-04-03  Clinton Ebadi  <clinton@unknownlamer.org>
+
+       * configure.ac: Merged all AC_OUTPUTs at the end
+
 2003-04-02  Clinton Ebadi  <clinton@unknownlamer.org>
 
        * scripts/bobot-utils.scm: Make exported symbols from
diff --git a/NEWS b/NEWS
index c24cec5..802bfcc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,12 @@ IMPORTANT NOTES:
 ====== The News =====================================================
 =====================================================================
 
+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)
+
 Version 2.1.2: Llama
 
 - match-to-me and match-not-channel are now bot:match-to-me and
index 5cda927..4e52901 100644 (file)
@@ -1,4 +1,4 @@
-This is bobot++.info, produced by makeinfo version 4.1 from
+This is bobot++.info, produced by makeinfo version 4.3 from
 bobot++.texinfo.
 
    This file documents Bobot++ by Clinton Ebadi and Etienne Bernard
@@ -68,7 +68,37 @@ File: bobot++.info,  Node: Configuration File Syntax,  Next: Configure File Plac
 Configuration File Syntax
 =========================
 
-   Not here yet.
+* Menu:
+
+* bot.conf::
+
+\1f
+File: bobot++.info,  Node: bot.conf,  Prev: Configuration File Syntax,  Up: Configuration File Syntax
+
+bot.conf
+--------
+
+   bot.conf is the main configuration file for a Bobot++. The available
+configuration variables are listed below in the format "VARIABLE
+<default-value>: description"
+
+   * NICKNAME <Bobot>: The nickname of the bot (NICK is an alias for
+     NICKNAME)
+
+   * USERNAME <bobot>: The IRC username of the bot
+
+   * CMDCHAR <!>: The character that prefixes commands given to the bot
+     (COMMAND is an alias for CMDCHAR)
+
+   * IRCNAME <I'm a bobot++!>: The IRC name (or 'real name') of the bot
+     (REALNAME is an alias for IRCNAME)
+
+   * USERLIST <bot.users>: Name of the file where the userlist is stored
+
+   * SHITLIST <bot.shit>: Name of the file where the shitlist is stored
+
+   * LOGFILE <$LOGDIR/bot.log>:
+
 
 \1f
 File: bobot++.info,  Node: Configure File Placement,  Prev: Configuration File Syntax,  Up: Configuration
@@ -524,21 +554,22 @@ Node: Top\7f517
 Node: Introduction\7f1246
 Node: Configuration\7f1437
 Node: Configuration File Syntax\7f1823
-Node: Configure File Placement\7f2025
-Node: Using the Bot\7f2499
-Node: User Levels\7f2673
-Node: Scripting\7f3677
-Node: Adding New Commands\7f4585
-Node: Hooks\7f5852
-Node: Creating a Hook\7f6826
-Node: Hook Types\7f7965
-Node: Scheme User Levels\7f11439
-Node: Sending Messages\7f12568
-Node: High Level Message Functions\7f13179
-Node: Low Level Message Functions\7f13393
-Node: Misc Scripting Stuff\7f14146
-Node: Concept Index\7f14565
-Node: Function Index\7f14747
-Node: Variable Index\7f15008
+Node: bot.conf\7f2030
+Node: Configure File Placement\7f2865
+Node: Using the Bot\7f3339
+Node: User Levels\7f3513
+Node: Scripting\7f4517
+Node: Adding New Commands\7f5425
+Node: Hooks\7f6692
+Node: Creating a Hook\7f7666
+Node: Hook Types\7f8805
+Node: Scheme User Levels\7f12279
+Node: Sending Messages\7f13408
+Node: High Level Message Functions\7f14019
+Node: Low Level Message Functions\7f14233
+Node: Misc Scripting Stuff\7f14986
+Node: Concept Index\7f15405
+Node: Function Index\7f15587
+Node: Variable Index\7f15848
 \1f
 End Tag Table
index 36f2838..a312228 100644 (file)
@@ -85,7 +85,33 @@ changing in the 2.1 series, so it is not documented for now. See the
 @node Configuration File Syntax, Configure File Placement, Configuration, Configuration
 @section Configuration File Syntax
 
-Not here yet.
+@menu
+* bot.conf::                    
+@end menu
+
+@node bot.conf,  , Configuration File Syntax, Configuration File Syntax
+@subsection bot.conf
+
+bot.conf is the main configuration file for a Bobot++. The available
+configuration variables are listed below in the format ``@var{variable}
+<default-value>: description''
+
+@itemize @bullet
+
+@item @var{nickname} <Bobot>: The nickname of the bot (@var{nick} is an
+alias for @var{nickname})
+@item @var{username} <bobot>: The IRC username of the bot
+@item @var{cmdchar} <!>: The character that prefixes commands given to
+the bot (@var{command} is an alias for @var{cmdchar})
+@item @var{ircname} <I'm a bobot++!>: The IRC name (or 'real name') of
+the bot (@var{realname} is an alias for @var{ircname})
+@item @var{userlist} <bot.users>: Name of the file where the userlist is
+stored
+@item @var{shitlist} <bot.shit>: Name of the file where the shitlist is
+stored
+@item @var{logfile} <$LOGDIR/bot.log>:
+
+@end itemize
 
 @node Configure File Placement,  , Configuration File Syntax, Configuration
 @section Configuration File Placement
index 3c96d2a..cc6f969 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.2CVS], [clinton@unknownlamer.org], [bobotpp])
+AC_INIT([Bobot++], [2.1.3CVS], [clinton@unknownlamer.org], [bobotpp])
 AM_INIT_AUTOMAKE
 AM_CONFIG_HEADER(config.h)
 
@@ -83,6 +83,4 @@ else
 fi
 
 dnl Generates the makefiles
-AC_OUTPUT(source/Makefile)
-AC_OUTPUT(scripts/Makefile)
-AC_OUTPUT(Makefile)
+AC_OUTPUT(source/Makefile scripts/Makefile Makefile)
index f1c4c30..91a35a2 100644 (file)
@@ -34,6 +34,9 @@
 #include "UserCommands.H"
 #include "DCCManager.H"
 
+
+unsigned int Bot::MAX_MESSAGES = 2;
+
 #define DEFAULT_NICKNAME "Bobot"
 #define DEFAULT_USERNAME "bobot"
 #define DEFAULT_IRCNAME "I'm a bobot++!"
@@ -385,17 +388,16 @@ Bot::waitForInput()
     }
 #ifdef USESCRIPTS
     botInterp->RunTimers(currentTime);
-#endif
 
-#ifdef USESCRIPTS
     tm *thisTime = localtime(&currentTime);
-    if (thisTime->tm_sec == 0) {
-      char s[6];
-      std::sprintf(s, "%2d:%2d", thisTime->tm_hour, thisTime->tm_min);
-      botInterp->RunHooks(Hook::TIMER, String(s),
-                          gh_list(Utils::string2SCM(String(s)), 
-                                 SCM_UNDEFINED));
-    }
+    if (thisTime->tm_sec == 0)
+      {
+       char s[6];
+       std::sprintf(s, "%2d:%2d", thisTime->tm_hour, thisTime->tm_min);
+       botInterp->RunHooks(Hook::TIMER, String(s),
+                           gh_list(Utils::string2SCM(String(s)), 
+                                   SCM_UNDEFINED));
+      }
 #endif
 
   }
@@ -644,6 +646,8 @@ Bot::init_user_functions ()
   userFunctions["SERVER"] = uf (UserCommands::Server, User::FRIEND, false);
   userFunctions["SERVERLIST"] =
     uf (UserCommands::ServerList, User::FRIEND, false);
+  userFunctions["SETFLOODRATE"] =
+    uf (UserCommands::SetFloodRate, User::MASTER, false);
   userFunctions["SETVERSION"] =
     uf (UserCommands::SetVersion, User::MASTER, false);
   userFunctions["SHITLIST"] =
index 27bc225..e330345 100644 (file)
@@ -106,7 +106,7 @@ public:
   unsigned long sentUserhostID;
   unsigned long receivedUserhostID;
 
-  static const unsigned int MAX_MESSAGES = 2;
+  static unsigned int MAX_MESSAGES;
   static const std::time_t NICK_CHANGE  = 60;
   static const std::time_t CHANNEL_JOIN = 60;
   static const std::time_t IGNORE_DELAY = 180;
index 9fc6cd1..8d289a9 100644 (file)
@@ -649,6 +649,17 @@ Commands::Server(Bot *bot, int number)
   return Ok;
 }
 
+Message
+Commands::SetFloodRate(Bot *bot, unsigned int num_messages)
+{
+  if (num_messages > 0)
+    {
+      bot->MAX_MESSAGES = num_messages;
+      return Ok;
+    }
+  return InvalidParameters;
+}
+
 Message
 Commands::SetVersion(Bot *bot, String str)
 {
index 19c4ae6..e2008a2 100644 (file)
@@ -61,6 +61,7 @@ public:
   static Message Say(Bot *, String, String);
   static Message Server(Bot *, int);
   static Message SetVersion(Bot *, String);
+  static Message SetFloodRate(Bot*, unsigned int);
   static Message TBan(Bot *, String, String, int);
   static Message TKBan(Bot *, String, String, int, String);
   static Message Topic(Bot *, String, String);
index 6d448f8..401d7d5 100644 (file)
@@ -145,6 +145,8 @@ interp_init_helper (void* unused)
                     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);
+  scm_c_define_gsubr ("bot:setfloodrate", 1, 0, 0,
+                     (SCMFunc)ScriptCommands::SetFloodRate);
   bot_new_procedure ("bot:setversion", (SCMFunc)ScriptCommands::SetVersion, 
                     1, 0, 0);
   bot_new_procedure ("bot:tban", (SCMFunc)ScriptCommands::TBan, 3, 0, 0);
index be4053c..0562cca 100644 (file)
@@ -375,6 +375,15 @@ ScriptCommands::Server(SCM number)
   return scm_long2num(m.getCode());
 }
 
+SCM
+ScriptCommands::SetFloodRate(SCM rate)
+{
+  VERIFY_NUMBER(rate);
+  Message m = Commands::SetFloodRate(Interp::bot, scm_num2uint 
+                                    (rate, 0, "SetFloodRate"));
+  return scm_long2num(m.getCode());
+}
+
 SCM
 ScriptCommands::SetVersion(SCM version)
 {
index afd7799..2c7995b 100644 (file)
@@ -60,6 +60,7 @@ public:
   static SCM Reconnect(void);
   static SCM Say(SCM, SCM);
   static SCM Server(SCM); // ACK NAMING CLASH
+  static SCM SetFloodRate(SCM);
   static SCM SetVersion(SCM);
   static SCM TBan(SCM, SCM, SCM);
   static SCM TKBan(SCM, SCM, SCM, SCM);
index 68cb148..f8a8356 100644 (file)
@@ -28,6 +28,7 @@
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <ctype.h>
+#include <cstdlib>
 #ifndef _X_OPEN_SOURCE
 #define _X_OPEN_SOURCE
 #endif
@@ -1167,6 +1168,18 @@ UserCommands::ServerList(ServerConnection *cnx, Person *from,
   from->sendNotice("\002End of server list.\002");
 }
 
+
+void
+UserCommands::SetFloodRate(ServerConnection *cnx, Person *from,
+                          String channel, String rest)
+{
+  Message m = Commands::SetFloodRate (cnx->bot, std::atoi (rest));
+  if (m.getCode ())
+    from->sendNotice (m.getMessage ());
+  else
+    from->sendNotice ("Flood Rate set to:" + String(std::atol(rest)));
+}
+
 void
 UserCommands::SetVersion(ServerConnection *cnx, Person *from,
                          String channel, String rest)
index f6727b3..8161ef9 100644 (file)
@@ -76,6 +76,7 @@ public:
   static void Say(ServerConnection *, Person *, String, String);
   static void Server(ServerConnection *, Person *, String, String);
   static void ServerList(ServerConnection *, Person *, String, String);
+  static void SetFloodRate(ServerConnection *, Person *, String, String);
   static void SetVersion(ServerConnection *, Person *, String, String);
   static void ShitList(ServerConnection *, Person *, String, String);
   static void SpyList(ServerConnection *, Person *, String, String);