From e171dcce70ed3538130a7d9dabce71675a058798 Mon Sep 17 00:00:00 2001 From: unknown_lamer Date: Thu, 10 Apr 2003 01:53:57 +0000 Subject: [PATCH 1/1] [project @ 2003-04-10 01:53:57 by unknown_lamer] Added support for overriding the flood rate --- ChangeLog | 20 ++++++++++++ NEWS | 6 ++++ bobot++.info | 67 ++++++++++++++++++++++++++++++----------- bobot++.texinfo | 28 ++++++++++++++++- configure.ac | 6 ++-- source/Bot.C | 22 ++++++++------ source/Bot.H | 2 +- source/Commands.C | 11 +++++++ source/Commands.H | 1 + source/Interp.C | 2 ++ source/ScriptCommands.C | 9 ++++++ source/ScriptCommands.H | 1 + source/UserCommands.C | 13 ++++++++ source/UserCommands.H | 1 + 14 files changed, 156 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a04d6e..a1daa8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2003-04-09 Clinton Ebadi + + * 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 + + * configure.ac: Merged all AC_OUTPUTs at the end + 2003-04-02 Clinton Ebadi * scripts/bobot-utils.scm: Make exported symbols from diff --git a/NEWS b/NEWS index c24cec5..802bfcc 100644 --- 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 diff --git a/bobot++.info b/bobot++.info index 5cda927..4e52901 100644 --- a/bobot++.info +++ b/bobot++.info @@ -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:: + + +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 +: description" + + * NICKNAME : The nickname of the bot (NICK is an alias for + NICKNAME) + + * USERNAME : The IRC username of the bot + + * CMDCHAR : The character that prefixes commands given to the bot + (COMMAND is an alias for CMDCHAR) + + * IRCNAME : The IRC name (or 'real name') of the bot + (REALNAME is an alias for IRCNAME) + + * USERLIST : Name of the file where the userlist is stored + + * SHITLIST : Name of the file where the shitlist is stored + + * LOGFILE <$LOGDIR/bot.log>: +  File: bobot++.info, Node: Configure File Placement, Prev: Configuration File Syntax, Up: Configuration @@ -524,21 +554,22 @@ Node: Top517 Node: Introduction1246 Node: Configuration1437 Node: Configuration File Syntax1823 -Node: Configure File Placement2025 -Node: Using the Bot2499 -Node: User Levels2673 -Node: Scripting3677 -Node: Adding New Commands4585 -Node: Hooks5852 -Node: Creating a Hook6826 -Node: Hook Types7965 -Node: Scheme User Levels11439 -Node: Sending Messages12568 -Node: High Level Message Functions13179 -Node: Low Level Message Functions13393 -Node: Misc Scripting Stuff14146 -Node: Concept Index14565 -Node: Function Index14747 -Node: Variable Index15008 +Node: bot.conf2030 +Node: Configure File Placement2865 +Node: Using the Bot3339 +Node: User Levels3513 +Node: Scripting4517 +Node: Adding New Commands5425 +Node: Hooks6692 +Node: Creating a Hook7666 +Node: Hook Types8805 +Node: Scheme User Levels12279 +Node: Sending Messages13408 +Node: High Level Message Functions14019 +Node: Low Level Message Functions14233 +Node: Misc Scripting Stuff14986 +Node: Concept Index15405 +Node: Function Index15587 +Node: Variable Index15848  End Tag Table diff --git a/bobot++.texinfo b/bobot++.texinfo index 36f2838..a312228 100644 --- a/bobot++.texinfo +++ b/bobot++.texinfo @@ -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} +: description'' + +@itemize @bullet + +@item @var{nickname} : The nickname of the bot (@var{nick} is an +alias for @var{nickname}) +@item @var{username} : 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} : The IRC name (or 'real name') of +the bot (@var{realname} is an alias for @var{ircname}) +@item @var{userlist} : Name of the file where the userlist is +stored +@item @var{shitlist} : 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 diff --git a/configure.ac b/configure.ac index 3c96d2a..cc6f969 100644 --- a/configure.ac +++ b/configure.ac @@ -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) diff --git a/source/Bot.C b/source/Bot.C index f1c4c30..91a35a2 100644 --- a/source/Bot.C +++ b/source/Bot.C @@ -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(¤tTime); - 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"] = diff --git a/source/Bot.H b/source/Bot.H index 27bc225..e330345 100644 --- a/source/Bot.H +++ b/source/Bot.H @@ -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; diff --git a/source/Commands.C b/source/Commands.C index 9fc6cd1..8d289a9 100644 --- a/source/Commands.C +++ b/source/Commands.C @@ -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) { diff --git a/source/Commands.H b/source/Commands.H index 19c4ae6..e2008a2 100644 --- a/source/Commands.H +++ b/source/Commands.H @@ -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); diff --git a/source/Interp.C b/source/Interp.C index 6d448f8..401d7d5 100644 --- a/source/Interp.C +++ b/source/Interp.C @@ -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); diff --git a/source/ScriptCommands.C b/source/ScriptCommands.C index be4053c..0562cca 100644 --- a/source/ScriptCommands.C +++ b/source/ScriptCommands.C @@ -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) { diff --git a/source/ScriptCommands.H b/source/ScriptCommands.H index afd7799..2c7995b 100644 --- a/source/ScriptCommands.H +++ b/source/ScriptCommands.H @@ -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); diff --git a/source/UserCommands.C b/source/UserCommands.C index 68cb148..f8a8356 100644 --- a/source/UserCommands.C +++ b/source/UserCommands.C @@ -28,6 +28,7 @@ #include #include #include +#include #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) diff --git a/source/UserCommands.H b/source/UserCommands.H index f6727b3..8161ef9 100644 --- a/source/UserCommands.H +++ b/source/UserCommands.H @@ -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); -- 2.20.1