[[project @ 2002-07-15 21:01:51 by unknown_lamer] unknown_lamer**20020715210151 User functions are now all stored in a map and the userFunctionStruct data type is gone as part of the new unification. userFunction now protects it's scmFunc if it was passed so you can use lambda's in a bot:addcommand now. The docs are slightly (not really) better and I've started to add lower level message sending commands to the scripting interface. Looks like it's almost time for 2.1.0 to be released. ] { hunk ./ChangeLog 1 +2002-07-13 Clinton Ebadi + + * source/Bot.C (Bot): userFunctions is now a map for efficiency + (worst case search is now NlogN instead of N). This improvement is + not as drastic as the one gained by making the Parser functions + list a map (because we don't scan this map for every message), but + it helps to clean up the code + +2002-07-12 Clinton Ebadi + + * source/Parser.H: Removed userFunctionsStruct + + * source/Interp.C (Startup): ScriptCommands::sendCTCP registered + as bot:send-CTCP for Scheme + + * source/ScriptCommands.C (sendCTCP): Wrote sendCTCP + hunk ./NEWS 6 -Version 2.1.0: Hook! +Version 2.1.0: Zug Zug hunk ./NEWS 31 +- You can now use lambda's for new commands (oops, I wasn't protecting + the objects from garbage collection) hunk ./TODO 4 -* Compile with -Wall and kill all warnings -* Make String more compatible with std::string - - Make operator >> act like all other >>'s, and add getline - + Add compatibility operators to String -* Remove gh_* and other deprecated guile stuff +* Make String operator >> act like all other >>'s, and add getline? hunk ./TODO 6 -* Add Scheme utils function to convert "normal" dates into time since - 1970. -* Make bot-random use the Guile RNG instead of C RNG (better?) -* Add commands to delete a hook - - return an iterator to the hook and let the user kill it? - - OR give the hook a new field ("name") and use that - - all part of the new hooks system I guess -* Convert UserCommands to use Commands -* Expand Commands to do everything the bot can do -* Add new commands to Scheme afterwards -* It would be interesting to see what SWIG could do here... - (eliminate ScriptCommands in favor a SWIG wrapper maybe?) Why - though? Well, maybe not kill ScriptCommands completely. Just make - it's interface a simple wrapper around Commands that automatically - adds the Bot* first arg as Interp::bot. This would eliminate a lot - of the type checking. OTOH, I'll have to look in to this more when - I get back. +* Finish converting UserCommands to use Commands hunk ./TODO 10 -* Fix logging stuff + +Scripting: +* Make bot:random use the Guile RNG instead of C RNG (better?) + - definition would be (define (bot:random) (random BIG_NUMBER)) + - Just use max-fixnum from the test scripts for BIG_NUMBER +* Add commands to delete a hook + - return an iterator to the hook and let the user kill it? + - this would require a new SMOB to be created +* Add Scheme utils function to convert "normal" dates into time since + 1970. +* Finish adding commands to Scheme for sending messages + (e.g. bot:send-CTCP to send a CTCP message) +* Add util functions for doing stuff like quoting CTCP messages hunk ./TODO 28 - - Access to repl will require use to authenticate - - Allow the load & reloading of scripts w/o restarting bot + - Access to repl will require user to authenticate hunk ./TODO 30 -* Enable DCC support (maybe not, you can always intercept CTCP from - Scheme) +* Fix DCC support hunk ./TODO 32 - - maybe not, you can do this from Scheme (it would probably be - really slow though) + - maybe do this as a script (log.scm) hunk ./TODO 35 -Config: +Config: (maybe) hunk ./TODO 59 -- Texinfo manual (including scripting section) +- Work on Texinfo manual (including scripting section) + +Other (post 2.2 release): +* Remove gh_* when Guile 1.8 is released hunk ./bobot++.info 35 +* Using the Bot:: hunk ./bobot++.info 51 -File: bobot++.info, Node: Configuration, Next: Scripting, Prev: Introduction, Up: Top +File: bobot++.info, Node: Configuration, Next: Using the Bot, Prev: Introduction, Up: Top hunk ./bobot++.info 86 -File: bobot++.info, Node: Scripting, Next: Concept Index, Prev: Configuration, Up: Top +File: bobot++.info, Node: Using the Bot, Next: Scripting, Prev: Configuration, Up: Top + +Using Bobot++ +************* + + FIXME: stuff here... + +* Menu: + +* User Levels:: + + +File: bobot++.info, Node: User Levels, Prev: Using the Bot, Up: Using the Bot + +User Levels +=========== + + There are five levels that a user may be when interfacing with a bot: +NONE, USER, TRUSTED_USER, FRIEND, MASTER. All users default to NONE +unless they are changed by a script, the `!adduser' command or the +`bot.users' file. NONE is for everyone--very few commands (e.g. help) +are available to the users and almost everyone should be this level. A +USER can execute many of the bot commands, but can't use masks on kicks +and bans. A TRUSTED user can everything a USER can do, but can also use +masks on kicks and bans. A FRIEND can do everything except for stopping +the bot (be careful who you give this to!). The MASTER level is for the +bot's owner (probably you) and can do _everything_ to the bot. Be +_very_ careful if you give MASTER level access to anyone else. You +cannot use this symbolic levels with the `!adduser' command. See +(FIXME: ref) for the numbers you must use with `!adduser'. + + +File: bobot++.info, Node: Scripting, Next: Concept Index, Prev: Using the Bot, Up: Top hunk ./bobot++.info 140 +* Scheme User Levels:: +* Sending Messages:: hunk ./bobot++.info 149 - Not here yet. + Adding a new command is simple. To register a new command use +`bot:addcommand'. The prototype for `bot:addcommand' is +`(bot:addcommand name func needs-channel? num-of-args min-level)'. The +`name' is a string representing the name of the command being added. +`func' is a function accepting `num-of-args' arguments. +`needs-channel?' is a bool that is true if the function needs the +channel name as its first arg, and false otherwise. `num-of-args' is +the number of args `func' will take and must be within zero (0) and +twenty (20). `min-level' is one of the *Note Scheme User Levels::. A +user must be at least a `min-level' user to use the new command. None +of the arguments are guaranteed to be passed; if they aren't they are +set to the empty string `""'. An example of a new command would be: +(define (hello channel name) (if (string=? name "")}@* (bot:say +channel "Hello world!") (bot:say channel (string-append "Hello " +name "!"))) + + (bot:addcommand "hello" hello #t 2 0) + + This will display ``Hello World!'' if called as !hello and ``Hello +World `USER''' if called as !hello USER. hunk ./bobot++.info 171 -File: bobot++.info, Node: Hooks, Prev: Adding New Commands, Up: Scripting +File: bobot++.info, Node: Hooks, Next: Scheme User Levels, Prev: Adding New Commands, Up: Scripting hunk ./bobot++.info 205 -of the hook-higher priority hooks are executed first. This argument is +of the hook---higher priority hooks are executed first. This argument is hunk ./bobot++.info 231 - That said, here is the list of available hooks: + That said, here is the list of available hooks: FIXME: write docs hunk ./bobot++.info 239 - hunk ./bobot++.info 245 - hunk ./bobot++.info 251 - hunk ./bobot++.info 257 - hunk ./bobot++.info 263 - hunk ./bobot++.info 269 - hunk ./bobot++.info 275 - hunk ./bobot++.info 281 - hunk ./bobot++.info 287 - hunk ./bobot++.info 293 - hunk ./bobot++.info 299 - hunk ./bobot++.info 305 - hunk ./bobot++.info 311 - hunk ./bobot++.info 317 - hunk ./bobot++.info 323 - hunk ./bobot++.info 329 - hunk ./bobot++.info 335 - hunk ./bobot++.info 341 - hunk ./bobot++.info 348 + +File: bobot++.info, Node: Scheme User Levels, Next: Sending Messages, Prev: Hooks, Up: Scripting + +Scheme User Levels +================== + + There are five levels that a user may be when interfacing with a bot: +NONE, USER, TRUSTED_USER, FRIEND, MASTER. The Scheme variables for the +user levels are `bot:user-none', `bot:user-user', `bot:user-trusted', +`bot:user-friend', and `bot:user-master'. See *Note User Levels:: for +more information on User Levels. + + When adding a new command, think about who should be able to use it. +Is your command a general purpose command that helps the channel (e.g. +`!seen') that everyone should be able to use? Or is it something that +should be restricted? See *Note User Levels:: for information on what +level users can do what with the built in bot commands and think about +what level a user your command is targetted towards. You must be _very_ +careful when giving new commands to lower level users because you can +do basically everything the bot can do with a script. As the scripting +interface becomes more powerful, you must think more about what users +can use new commands you add. + + +File: bobot++.info, Node: Sending Messages, Prev: Scheme User Levels, Up: Scripting + +Sending Messages +================ + + There are several types of messages you can send with Bobot++ from +scripts. There is the simple, but rather limited, `bot:say', +`bot:action' and `bot:msg', and the more powerful, but lower level, +`bot:send-MESSAGE' functions. Most bots will probably only need the +higher level functions, but for the sake of why-not Bobot++ lets you +use the lower level functions. + +* Menu: + +* High Level Message Functions:: +* Low Level Message Functions:: + + +File: bobot++.info, Node: High Level Message Functions, Next: Low Level Message Functions, Prev: Sending Messages, Up: Sending Messages + +``High Level'' Message Functions +-------------------------------- + + ... + + +File: bobot++.info, Node: Low Level Message Functions, Prev: High Level Message Functions, Up: Sending Messages + +``Low Level'' Message Functions +------------------------------- + + The ``Low Level'' messaging functions allow you to do things like +send CTCP messages. You probably want to read rfc 2812 and the CTCP spec +before using these. If you have no idea what these do, read rfc 2812 +(IRC Client Protocol) and CTCP spec. These functions all return +`*unspecified*' always, so don't use the return value for anything. + + * `bot:send-CTCP to command message' `to' is the target of your CTCP + message, `command' is the CTCP command, and `message' is the + message (or arguments) of the command. Make sure to + `bot:ctcp-quote' the message! + + hunk ./bobot++.info 422 + +* Background on Hooks: Hooks. + hunk ./bobot++.info 432 + +* addcommand: Adding New Commands. +* addhook: Creating a Hook. + hunk ./bobot++.info 444 +* hooks/action: Hook Types. +* hooks/ctcp: Hook Types. +* hooks/ctcp-reply: Hook Types. +* hooks/disconnect: Hook Types. +* hooks/flood: Hook Types. +* hooks/invite: Hook Types. +* hooks/join: Hook Types. +* hooks/kick: Hook Types. +* hooks/message: Hook Types. +* hooks/mode: Hook Types. +* hooks/nickname: Hook Types. +* hooks/notice: Hook Types. +* hooks/part: Hook Types. +* hooks/public: Hook Types. +* hooks/public-notice: Hook Types. +* hooks/raw: Hook Types. +* hooks/signoff: Hook Types. +* hooks/timer: Hook Types. +* hooks/topic: Hook Types. +* user-friend: Scheme User Levels. +* user-master: Scheme User Levels. +* user-none: Scheme User Levels. +* user-trusted: Scheme User Levels. +* user-user: Scheme User Levels. + + hunk ./bobot++.info 473 -Node: Introduction1228 -Node: Configuration1419 -Node: Configuration File Syntax1801 -Node: Configure File Placement2003 -Node: Scripting2477 -Node: Adding New Commands3316 -Node: Hooks3473 -Node: Creating a Hook4363 -Node: Hook Types5153 -Node: Concept Index7626 -Node: Function Index7758 -Node: Variable Index7897 +Node: Introduction1246 +Node: Configuration1437 +Node: Configuration File Syntax1823 +Node: Configure File Placement2025 +Node: Using the Bot2499 +Node: User Levels2673 +Node: Scripting3677 +Node: Adding New Commands4560 +Node: Hooks5803 +Node: Creating a Hook6720 +Node: Hook Types7512 +Node: Scheme User Levels9985 +Node: Sending Messages11114 +Node: High Level Message Functions11682 +Node: Low Level Message Functions11900 +Node: Concept Index12659 +Node: Function Index12841 +Node: Variable Index13102 hunk ./bobot++.texinfo 60 +* Using the Bot:: hunk ./bobot++.texinfo 73 -@node Configuration, Scripting, Introduction, Top +@node Configuration, Using the Bot, Introduction, Top hunk ./bobot++.texinfo 99 -@node Scripting, Concept Index, Configuration, Top +@node Using the Bot, Scripting, Configuration, Top +@chapter Using Bobot++ + +FIXME: stuff here... + +@menu +* User Levels:: +@end menu + +@node User Levels, , Using the Bot, Using the Bot +@section User Levels + +There are five levels that a user may be when interfacing with a bot: +@var{none}, @var{user}, @var{trusted_user}, @var{friend}, +@var{master}. All users default to @var{none} unless they are changed +by a script, the @code{!adduser} command or the @file{bot.users} +file. @var{none} is for everyone---very few commands (e.g. help) are +available to the users and almost everyone should be this +level. A @var{user} can execute many of the bot commands, but can't +use masks on kicks and bans. A @var{trusted} user can everything a +@var{user} can do, but can also use masks on kicks and bans. A +@var{friend} can do everything except for stopping the bot (be +careful who you give this to!). The @var{master} level is for the +bot's owner (probably you) and can do @emph{everything} to the bot. Be +@emph{very} careful if you give @var{master} level access to anyone +else. You cannot use this symbolic levels with the @code{!adduser} +command. See (FIXME: ref) for the numbers you must use with +@code{!adduser}. + +@node Scripting, Concept Index, Using the Bot, Top hunk ./bobot++.texinfo 148 +* Scheme User Levels:: +* Sending Messages:: hunk ./bobot++.texinfo 155 -Not here yet. +@findex addcommand +Adding a new command is simple. To register a new command use +@code{bot:addcommand}. The prototype for @code{bot:addcommand} is +@code{(bot:addcommand name func needs-channel? num-of-args +min-level)}. The @code{name} is a string representing the name of the +command being added. @code{func} is a function accepting +@code{num-of-args} arguments. @code{needs-channel?} is a bool that is +true if the function needs the channel name as its first arg, and +false otherwise. @code{num-of-args} is the number of args @code{func} +will take and must be within zero (0) and twenty +(20). @code{min-level} is one of the @ref{Scheme User Levels}. A user must be +at least a @code{min-level} user to use the new command. None of the +arguments are guaranteed to be passed; if they aren't they are set to +the empty string @code{""}. An example of a new command would be: +@verb{| +(define (hello channel name) + (if (string=? name "")}@* + (bot:say channel "Hello world!") + (bot:say channel (string-append "Hello " name "!"))) hunk ./bobot++.texinfo 175 -@node Hooks, , Adding New Commands, Scripting +(bot:addcommand "hello" hello #t 2 0) +|} +This will display ``Hello World!'' if called as @kbd{!hello} and +``Hello World @code{USER}'' if called as @kbd{!hello @var{USER}}. + +@node Hooks, Scheme User Levels, Adding New Commands, Scripting hunk ./bobot++.texinfo 183 +@cindex Background on Hooks hunk ./bobot++.texinfo 205 +@findex addhook hunk ./bobot++.texinfo 214 -hook--higher priority hooks are executed first. This argument is +hook---higher priority hooks are executed first. This argument is hunk ./bobot++.texinfo 247 +FIXME: write docs hunk ./bobot++.texinfo 250 + hunk ./bobot++.texinfo 252 +@vindex hooks/action hunk ./bobot++.texinfo 265 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 266 +@vindex hooks/nickname hunk ./bobot++.texinfo 279 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 280 +@vindex hooks/signoff hunk ./bobot++.texinfo 293 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 294 +@vindex hooks/ctcp hunk ./bobot++.texinfo 307 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 308 +@vindex hooks/ctcp-reply hunk ./bobot++.texinfo 321 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 322 +@vindex hooks/disconnect hunk ./bobot++.texinfo 335 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 336 +@vindex hooks/flood hunk ./bobot++.texinfo 349 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 350 +@vindex hooks/invite hunk ./bobot++.texinfo 363 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 364 +@vindex hooks/join hunk ./bobot++.texinfo 377 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 378 +@vindex hooks/kick hunk ./bobot++.texinfo 391 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 392 +@vindex hooks/part hunk ./bobot++.texinfo 405 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 406 +@vindex hooks/mode hunk ./bobot++.texinfo 419 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 420 +@vindex hooks/message hunk ./bobot++.texinfo 433 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 434 +@vindex hooks/notice hunk ./bobot++.texinfo 447 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 448 +@vindex hooks/public hunk ./bobot++.texinfo 461 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 462 +@vindex hooks/public-notice hunk ./bobot++.texinfo 475 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 476 +@vindex hooks/raw hunk ./bobot++.texinfo 489 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 490 +@vindex hooks/timer hunk ./bobot++.texinfo 503 -@end itemize -@itemize @bullet hunk ./bobot++.texinfo 504 +@vindex hooks/topic hunk ./bobot++.texinfo 520 +@node Scheme User Levels, Sending Messages, Hooks, Scripting +@section Scheme User Levels + +@vindex user-none +@vindex user-user +@vindex user-trusted +@vindex user-friend +@vindex user-master +There are five levels that a user may be when interfacing with a bot: +@var{none}, @var{user}, @var{trusted_user}, @var{friend}, +@var{master}. The Scheme variables for the user levels are +@code{bot:user-none}, @code{bot:user-user}, @code{bot:user-trusted}, +@code{bot:user-friend}, and @code{bot:user-master}. See @ref{User +Levels} for more information on User Levels. + +When adding a new command, think about who should be able to use +it. Is your command a general purpose command that helps the channel +(e.g. @code{!seen}) that everyone should be able to use? Or is it +something that should be restricted? See @ref{User Levels} for +information on what level users can do what with the built in bot +commands and think about what level a user your command is targetted +towards. You must be @emph{very} careful when giving new commands to +lower level users because you can do basically everything the bot can +do with a script. As the scripting interface becomes more powerful, +you must think more about what users can use new commands you add. + +@node Sending Messages, , Scheme User Levels, Scripting +@section Sending Messages + +There are several types of messages you can send with Bobot++ from +scripts. There is the simple, but rather limited, @code{bot:say}, +@code{bot:action} and @code{bot:msg}, and +the more powerful, but lower level, @code{bot:send-MESSAGE} +functions. Most bots will probably only need the higher level +functions, but for the sake of why-not Bobot++ lets you use the lower +level functions. + +@menu +* High Level Message Functions:: +* Low Level Message Functions:: +@end menu + +@node High Level Message Functions, Low Level Message Functions, Sending Messages, Sending Messages +@subsection ``High Level'' Message Functions + +... + +@node Low Level Message Functions, , High Level Message Functions, Sending Messages +@subsection ``Low Level'' Message Functions + +The ``Low Level'' messaging functions allow you to do things like send +CTCP messages. You probably want to read rfc 2812 and the CTCP spec +before using these. If you have no idea what these do, read rfc 2812 +(IRC Client Protocol) and CTCP spec. These functions all return +@code{*unspecified*} always, so don't use the return value for anything. + +@itemize @bullet + +@item @code{bot:send-CTCP to command message} +@code{to} is the target of your CTCP message, @code{command} is the +CTCP command, and @code{message} is the message (or arguments) of the +command. Make sure to @code{bot:ctcp-quote} the message! + +@end itemize + hunk ./scripts/bobot-utils.scm 43 - "[:,]*[[:space:][:graph:]]*" regex)) + "[[:space:][:graph:]]*" regex)) hunk ./scripts/bobot-utils.scm 64 -;;; DEPRECATED FUNCTION NAMED +;;; Message sending utils + +;;; returns the CTCP quoted message +(define (ctcp-quote message) + message) ; FIXME: fill me in + +;;; DEPRECATED FUNCTION NAMES hunk ./scripts/hello 2 - (if (string=? n "") - (bot:say c "Hello world !") - (bot:say c (string-append "Hello " n " !")) - ) -) + (if (string=? n "") + (bot:say c "Hello world !") + (bot:say c (string-append "Hello " n " !")))) hunk ./source/Bot.C 33 +#include "UserCommands.H" hunk ./source/Bot.C 76 - extern userFunctionsStruct userFunctionsInit[]; - hunk ./source/Bot.C 83 - for (int i = 0; userFunctionsInit[i].name[0] != '\0'; i++) { - userFunctions.push_back(new - userFunction(String(userFunctionsInit[i].name), - userFunctionsInit[i].function, - userFunctionsInit[i].minLevel, - userFunctionsInit[i].needsChannelName)); - } + init_user_functions (); hunk ./source/Bot.C 105 - std::list::iterator it; - bool found = false; - userFunction *u; hunk ./source/Bot.C 120 - found = false; - for (it = userFunctions.begin(); it != userFunctions.end(); ++it) - if (alias == (*it)->name) { - found = true; - break; - } - if (found) continue; - - // Check that the command exists - found = false; - for (it = userFunctions.begin(); it != userFunctions.end(); ++it) - if (command == (*it)->name) { - found = true; - u = *it; - break; - } - if (!found) continue; - - userFunctions.push_back (new - userFunction((char *)(const char *)alias, - u->function, - u->minLevel, - u->needsChannelName)); + if (!userFunctions[alias]) + { + if (userFunction *u = userFunctions[command]) + userFunctions[alias] = + new + userFunction(u->function, + u->minLevel, + u->needsChannelName); + } hunk ./source/Bot.C 132 + hunk ./source/Bot.C 156 - userFunction *u; - while (userFunctions.size() != 0) { - u = *userFunctions.begin(); - userFunctions.erase(userFunctions.begin()); - delete u; - } + + destroy_user_functions (); + hunk ./source/Bot.C 575 + +void +Bot::init_user_functions () +{ + // User Functions +#define uf(f, l, b) new userFunction (f, l, b); + userFunctions["ACTION"] = uf (UserCommands::Action, User::USER, true); + userFunctions["ADDUSER"] = uf (UserCommands::AddUser, User::FRIEND, false); + userFunctions["ADDSERVER"] = uf (UserCommands::AddServer, User::FRIEND, + false); + userFunctions["ADDSHIT"] = uf (UserCommands::AddShit, User::FRIEND, false); + userFunctions["ALIAS"] = uf (UserCommands::Alias, User::MASTER, false); + userFunctions["BAN"] = uf (UserCommands::Ban, User::USER, true); + userFunctions["BANLIST"] = uf (UserCommands::BanList, User::USER, true); + userFunctions["CHANNELS"] = + uf (UserCommands::Channels, User::FRIEND, false); + userFunctions["CYCLE"] = uf (UserCommands::Cycle, User::FRIEND, true); + userFunctions["DCCLIST"] = uf (UserCommands::DCCList, User::FRIEND, false); + userFunctions["DEBAN"] = uf (UserCommands::Deban, User::USER, true); + userFunctions["DELSERVER"] = uf (UserCommands::DelServer, User::FRIEND, + false); + userFunctions["DELUSER"] = uf (UserCommands::DelUser, User::FRIEND, false); + userFunctions["DELSHIT"] = uf (UserCommands::DelShit, User::FRIEND, false); + userFunctions["DEOP"] = uf (UserCommands::Deop, User::TRUSTED_USER, true); + userFunctions["DIE"] = uf (UserCommands::Die, User::MASTER, false); + userFunctions["DO"] = uf (UserCommands::Do, User::MASTER, false); +#ifdef USESCRIPTS + userFunctions["EXECUTE"] = uf (UserCommands::Execute, User::MASTER, false); +#endif + userFunctions["HELP"] = uf (UserCommands::Help, User::NONE, false); + userFunctions["IDENT"] = uf (UserCommands::Ident, User::NONE, true); + userFunctions["INVITE"] = uf (UserCommands::Invite, User::USER, true); + userFunctions["JOIN"] = uf (UserCommands::Join, User::FRIEND, false); + userFunctions["KEEP"] = uf (UserCommands::Keep, User::FRIEND, true); + userFunctions["KICK"] = uf (UserCommands::Kick, User::USER, true); + userFunctions["KICKBAN"] = uf (UserCommands::KickBan, User::USER, true); + userFunctions["LOAD"] = uf (UserCommands::Load, User::FRIEND, false); +#ifdef USESCRIPTS + userFunctions["LOADSCRIPT"] = uf (UserCommands::LoadScript, User::MASTER, + false); +#endif + userFunctions["LOCK"] = uf (UserCommands::Lock, User::FRIEND, true); + userFunctions["MODE"] = uf (UserCommands::Mode, User::FRIEND, true); + userFunctions["MSG"] = uf (UserCommands::Msg, User::USER, false); + userFunctions["NAMES"] = uf (UserCommands::Names, User::USER, true); + userFunctions["NEXTSERVER"] = uf (UserCommands::NextServer, User::FRIEND, + false); + userFunctions["NICK"] = uf (UserCommands::Nick, User::FRIEND, false); + userFunctions["NSLOOKUP"] = uf (UserCommands::NsLookup, User::USER, false); + userFunctions["OP"] = uf (UserCommands::Op, User::TRUSTED_USER, true); + userFunctions["PART"] = uf (UserCommands::Part, User::FRIEND, true); + userFunctions["PASSWORD"] = uf (UserCommands::Password, User::USER, true); + userFunctions["RECONNECT"] = + uf (UserCommands::Reconnect, User::FRIEND, false); + userFunctions["RSPYMESSAGE"] = + uf (UserCommands::RSpyMessage, User::USER, false); + userFunctions["SAVE"] = uf (UserCommands::Save, User::FRIEND, false); + userFunctions["SAY"] = uf (UserCommands::Say, User::USER, true); + userFunctions["SERVER"] = uf (UserCommands::Server, User::FRIEND, false); + userFunctions["SERVERLIST"] = + uf (UserCommands::ServerList, User::FRIEND, false); + userFunctions["SETVERSION"] = + uf (UserCommands::SetVersion, User::MASTER, false); + userFunctions["SHITLIST"] = + uf (UserCommands::ShitList, User::FRIEND, false); + userFunctions["SPYLIST"] = uf (UserCommands::SpyList, User::USER, false); + userFunctions["SPYMESSAGE"] = + uf (UserCommands::SpyMessage, User::USER, false); + userFunctions["STATS"] = uf (UserCommands::Stats, User::FRIEND, true); + userFunctions["TBAN"] = uf (UserCommands::TBan, User::USER, true); + userFunctions["TKBAN"] = uf (UserCommands::TKBan, User::USER, true); + userFunctions["TOPIC"] = uf (UserCommands::Topic, User::USER, true); + userFunctions["UNLOCK"] = uf (UserCommands::Unlock, User::FRIEND, true); + userFunctions["USERLIST"] = + uf (UserCommands::UserList, User::FRIEND, false); + userFunctions["WHO"] = uf (UserCommands::Who, User::NONE, true); + userFunctions["WHOIS"] = uf (UserCommands::Whois, User::FRIEND, true); +#undef uf +} + +namespace +{ + void erase_userf (std::pair it) + { + delete it.second; + } +} + +void +Bot::destroy_user_functions () +{ + for_each (userFunctions.begin (), + userFunctions.end (), + erase_userf); + userFunctions.erase (userFunctions.begin (), + userFunctions.end ()); +} hunk ./source/Bot.H 29 +#include +#include hunk ./source/Bot.H 92 - std::list userFunctions; - + // std::list userFunctions; + std::map > userFunctions; hunk ./source/Bot.H 160 + + void init_user_functions (); + void destroy_user_functions (); hunk ./source/Interp.C 154 + + // "Low Level" Message functuions + scm_c_define_gsubr ("bot:send-CTCP", 3, 0, 0, + (SCMFunc)ScriptCommands::sendCTCP); + hunk ./source/Parser.C 33 -typedef void (*fptr)(ServerConnection *, Person *, String); -std::map > Parser::functions; +typedef void (*fptr) (ServerConnection *, Person *, String); +std::map < std::string, fptr, std::less < std::string > >Parser::functions; hunk ./source/Parser.C 36 -void Parser::init () +void +Parser::init () hunk ./source/Parser.C 39 - Parser::functions["001"] = Parser::parse001; /* RPL_WELCOME */ - Parser::functions["302"] = Parser::parse302; /* RPL_USERHOST */ - Parser::functions["311"] = Parser::parse311; /* RPL_WHOISUSER */ - Parser::functions["315"] = Parser::parse315; /* RPL_ENDOFWHO */ - Parser::functions["324"] = Parser::parse324; /* RPL_CHANNELMODEIS */ - Parser::functions["332"] = Parser::parse332; /* RPL_TOPIC */ - Parser::functions["352"] = Parser::parse352; /* RPL_WHOREPLY */ - Parser::functions["353"] = Parser::parse353; /* RPL_NAMESREPLY */ - Parser::functions["366"] = Parser::parse366; /* RPL_ENDOFNAMES */ - Parser::functions["367"] = Parser::parse367; /* RPL_BANLIST */ - Parser::functions["401"] = Parser::parse401; /* ERR_NOSUCHNICK */ - Parser::functions["433"] = Parser::parse433; /* ERR_NICKNAMEINUSE */ - Parser::functions["437"] = Parser::parse433; /* ERR_UNAVAILRESOURCE */ - Parser::functions["471"] = Parser::parse473; /* ERR_CHANNELISFULL */ - Parser::functions["473"] = Parser::parse473; /* ERR_INVITEONLYCHAN */ - Parser::functions["474"] = Parser::parse473; /* ERR_BANNEDFROMCHAN */ - Parser::functions["475"] = Parser::parse473; /* ERR_BADCHANNELKEY */ + // Parser functions + Parser::functions["001"] = Parser::parse001; /* RPL_WELCOME */ + Parser::functions["302"] = Parser::parse302; /* RPL_USERHOST */ + Parser::functions["311"] = Parser::parse311; /* RPL_WHOISUSER */ + Parser::functions["315"] = Parser::parse315; /* RPL_ENDOFWHO */ + Parser::functions["324"] = Parser::parse324; /* RPL_CHANNELMODEIS */ + Parser::functions["332"] = Parser::parse332; /* RPL_TOPIC */ + Parser::functions["352"] = Parser::parse352; /* RPL_WHOREPLY */ + Parser::functions["353"] = Parser::parse353; /* RPL_NAMESREPLY */ + Parser::functions["366"] = Parser::parse366; /* RPL_ENDOFNAMES */ + Parser::functions["367"] = Parser::parse367; /* RPL_BANLIST */ + Parser::functions["401"] = Parser::parse401; /* ERR_NOSUCHNICK */ + Parser::functions["433"] = Parser::parse433; /* ERR_NICKNAMEINUSE */ + Parser::functions["437"] = Parser::parse433; /* ERR_UNAVAILRESOURCE */ + Parser::functions["471"] = Parser::parse473; /* ERR_CHANNELISFULL */ + Parser::functions["473"] = Parser::parse473; /* ERR_INVITEONLYCHAN */ + Parser::functions["474"] = Parser::parse473; /* ERR_BANNEDFROMCHAN */ + Parser::functions["475"] = Parser::parse473; /* ERR_BADCHANNELKEY */ hunk ./source/Parser.C 60 - Parser::functions["KICK"] = Parser::parseKick ; - Parser::functions["MODE"] = Parser::parseMode ; - Parser::functions["NICK"] = Parser::parseNick ; + Parser::functions["KICK"] = Parser::parseKick; + Parser::functions["MODE"] = Parser::parseMode; + Parser::functions["NICK"] = Parser::parseNick; hunk ./source/Parser.C 75 -Parser::parseLine(ServerConnection * cnx, String line) +Parser::parseLine (ServerConnection * cnx, String line) hunk ./source/Parser.C 77 - StringTokenizer st(line); - Person * from = 0; - + StringTokenizer st (line); + Person *from = 0; hunk ./source/Parser.C 80 - cnx->bot->botInterp->RunHooks(Hook::RAW, line, - scm_listify (Utils::string2SCM(line), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::RAW, line, + scm_listify (Utils:: + string2SCM (line), + SCM_UNDEFINED)); hunk ./source/Parser.C 85 + if (line[0] == ':') + { + String fromMask = st.nextToken ().subString (1); + if (fromMask.find ('!') != -1) + from = new Person (cnx->bot, fromMask); + } hunk ./source/Parser.C 92 - if (line[0] == ':') { - String fromMask = st.nextToken().subString(1); - if (fromMask.find('!') != -1) - from = new Person(cnx->bot, fromMask); - } - - String command = st.nextToken(); - String rest = st.rest(); - + String command = st.nextToken (); + String rest = st.rest (); hunk ./source/Parser.C 95 - if (command == functions[i].name) { - functions[i].function(cnx, from, rest); - break; - } - */ + if (command == functions[i].name) { + functions[i].function(cnx, from, rest); + break; + } + */ hunk ./source/Parser.C 102 - hunk ./source/Parser.C 106 -Parser::parse001(ServerConnection * cnx, - Person *from, String rest) +Parser::parse001 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 109 - StringTokenizer st(rest); - String realNick = st.nextToken(); - - if ((cnx->bot->nickName).toLower() != realNick) { - // Yes, this can happen, and it was a very subtle bug - cnx->bot->nickName = realNick; - cnx->bot->userList->removeFirst(); - cnx->bot->userList->addUserFirst(realNick + "!" + cnx->bot->userHost, "*", 0, 3, true, -1, ""); - cnx->bot->lastNickNameChange = time(0); - cnx->bot->rehash(); - } + StringTokenizer st (rest); + String realNick = st.nextToken (); + if ((cnx->bot->nickName).toLower () != realNick) + { + // Yes, this can happen, and it was a very subtle bug + cnx->bot->nickName = realNick; + cnx->bot->userList->removeFirst (); + cnx->bot->userList->addUserFirst (realNick + "!" + + cnx->bot->userHost, "*", 0, + 3, true, -1, ""); + cnx->bot->lastNickNameChange = time (0); + cnx->bot->rehash (); + } hunk ./source/Parser.C 124 - - cnx->queue->sendUserMode(cnx->bot->nickName, "+i"); - cnx->queue->sendWhois(cnx->bot->nickName); - - for (std::map >::iterator - it = cnx->bot->wantedChannels.begin(); - it != cnx->bot->wantedChannels.end(); ++it) - cnx->queue->sendJoin((*it).first, (*it).second->key); - - cnx->bot->logLine(String("Connected to server ") + - cnx->bot->serverList->currentServer()->getHostName() + - " (" + String((long)cnx->bot->serverList->currentServer()->getPort()) + - ")."); + cnx->queue->sendUserMode (cnx->bot->nickName, "+i"); + cnx->queue->sendWhois (cnx->bot->nickName); + for (std::map < String, wantedChannel *, + std::less < String > >::iterator it = + cnx->bot->wantedChannels.begin (); + it != cnx->bot->wantedChannels.end (); ++it) + cnx->queue->sendJoin ((*it).first, (*it).second->key); + cnx->bot->logLine (String ("Connected to server ") + + cnx->bot->serverList->currentServer ()-> + getHostName () + " (" + + String ((long) cnx->bot->serverList-> + currentServer ()->getPort ()) + ")."); hunk ./source/Parser.C 139 -Parser::parse302(ServerConnection *cnx, - Person *from, String rest) +Parser::parse302 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 142 - StringTokenizer st(rest); - - st.nextToken(':'); - - if (st.rest().length()) { - st.nextToken('='); - String parameters = st.rest(); - parameters = parameters.subString(1); - cnx->bot->userhostMap[num] = parameters; - } else + StringTokenizer st (rest); + st.nextToken (':'); + if (st.rest ().length ()) + { + st.nextToken ('='); + String parameters = st.rest (); + parameters = parameters.subString (1); + cnx->bot->userhostMap[num] = parameters; + } + else hunk ./source/Parser.C 156 -Parser::parse311(ServerConnection *cnx, - Person *from, String rest) +Parser::parse311 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 158 - StringTokenizer st(rest); - st.nextToken(); - String nuh = st.nextToken() + "!"; - String uh = st.nextToken() + "@"; - uh = uh + st.nextToken(); + StringTokenizer st (rest); + st.nextToken (); + String nuh = st.nextToken () + "!"; + String uh = st.nextToken () + "@"; + uh = uh + st.nextToken (); hunk ./source/Parser.C 164 - cnx->bot->userList->addUserFirst(nuh, "*", 0, 3, true, -1, ""); + cnx->bot->userList->addUserFirst (nuh, "*", 0, 3, true, -1, ""); hunk ./source/Parser.C 169 -Parser::parse315(ServerConnection *cnx, - Person *from, String rest) +Parser::parse315 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 171 - StringTokenizer st(rest); - st.nextToken(); - String channel = st.nextToken(); - Channel *c = cnx->bot->channelList->getChannel(channel); + StringTokenizer st (rest); + st.nextToken (); + String channel = st.nextToken (); + Channel *c = cnx->bot->channelList->getChannel (channel); hunk ./source/Parser.C 181 -Parser::parse324(ServerConnection *cnx, - Person *from, String rest) +Parser::parse324 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 183 - StringTokenizer st(rest); - st.nextToken(); - String channel = st.nextToken(); - if (Channel *c = cnx->bot->channelList->getChannel(channel)) - if (c) c->parseMode(from, st.rest()); + StringTokenizer st (rest); + st.nextToken (); + String channel = st.nextToken (); + if (Channel * c = cnx->bot->channelList->getChannel (channel)) + if (c) + c->parseMode (from, st.rest ()); hunk ./source/Parser.C 192 -Parser::parse332(ServerConnection *cnx, - Person *from, String rest) +Parser::parse332 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 194 - StringTokenizer st(rest); - st.nextToken(); - String channel = st.nextToken(); - if (Channel *c = cnx->bot->channelList->getChannel(channel)) - if (c) c->channelTopic = st.rest().subString(1); + StringTokenizer st (rest); + st.nextToken (); + String channel = st.nextToken (); + if (Channel * c = cnx->bot->channelList->getChannel (channel)) + if (c) + c->channelTopic = st.rest ().subString (1); hunk ./source/Parser.C 203 -Parser::parse352(ServerConnection *cnx, - Person *from, String rest) +Parser::parse352 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 205 - StringTokenizer st(rest); - st.nextToken(); - String ch = st.nextToken(); - String uh = st.nextToken() + "@"; - uh = uh + st.nextToken(); - st.nextToken(); - String n = st.nextToken(); - String m = st.nextToken(); + StringTokenizer st (rest); + st.nextToken (); + String ch = st.nextToken (); + String uh = st.nextToken () + "@"; + uh = uh + st.nextToken (); + st.nextToken (); + String n = st.nextToken (); + String m = st.nextToken (); hunk ./source/Parser.C 214 - - for (int i = 0; i < m.length(); i++) - switch (m[i]) { - case 'H': break; - case 'G': mode |= User::AWAY_MODE; break; - case '*': mode |= User::IRCOP_MODE; break; - case '@': mode |= User::OP_MODE; break; - case '+': mode |= User::VOICE_MODE; break; - } - if (Channel *c = cnx->bot->channelList->getChannel(ch)) - if (c) c->addNick(n, uh, mode, cnx->bot->userList); + for (int i = 0; i < m.length (); i++) + switch (m[i]) + { + case 'H': + break; + case 'G': + mode |= User::AWAY_MODE; + break; + case '*': + mode |= User::IRCOP_MODE; + break; + case '@': + mode |= User::OP_MODE; + break; + case '+': + mode |= User::VOICE_MODE; + break; + } + if (Channel * c = cnx->bot->channelList->getChannel (ch)) + if (c) + c->addNick (n, uh, mode, cnx->bot->userList); hunk ./source/Parser.C 238 -Parser::parse353(ServerConnection *cnx, - Person *from, String rest) +Parser::parse353 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 242 - - StringTokenizer st(rest); - st.nextToken(); st.nextToken(); - - Channel * c = cnx->bot->channelList->getChannel(st.nextToken()); - if (!c) return; - StringTokenizer st2(st.nextToken(':')); - - while (st2.hasMoreTokens()) { - nick = st2.nextToken(); - if (nick[0] == '@') { - mode = User::OP_MODE; - nick = nick.subString(1); - } else if (nick[0] == '+') { - mode = User::VOICE_MODE; - nick = nick.subString(1); + StringTokenizer st (rest); + st.nextToken (); + st.nextToken (); + Channel *c = cnx->bot->channelList->getChannel (st.nextToken ()); + if (!c) + return; + StringTokenizer st2 (st.nextToken (':')); + while (st2.hasMoreTokens ()) + { + nick = st2.nextToken (); + if (nick[0] == '@') + { + mode = User::OP_MODE; + nick = nick.subString (1); + } + else if (nick[0] == '+') + { + mode = User::VOICE_MODE; + nick = nick.subString (1); + } + c->addNick (nick, "", mode, 0, true); hunk ./source/Parser.C 264 - c->addNick(nick, "", mode, 0, true); - } hunk ./source/Parser.C 267 -Parser::parse366(ServerConnection *cnx, - Person *from, String rest) +Parser::parse366 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 269 - StringTokenizer st(rest); - st.nextToken(); - String ch = st.nextToken(); - if (Channel *c = cnx->bot->channelList->getChannel(ch)) + StringTokenizer st (rest); + st.nextToken (); + String ch = st.nextToken (); + if (Channel * c = cnx->bot->channelList->getChannel (ch)) hunk ./source/Parser.C 277 -Parser::parse367(ServerConnection *cnx, - Person *from, String rest) +Parser::parse367 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 279 - StringTokenizer st(rest); - st.nextToken(); - String ch = st.nextToken(); - if (Channel *c = cnx->bot->channelList->getChannel(ch)) - c->addBan(st.nextToken(), -1); + StringTokenizer st (rest); + st.nextToken (); + String ch = st.nextToken (); + if (Channel * c = cnx->bot->channelList->getChannel (ch)) + c->addBan (st.nextToken (), -1); hunk ./source/Parser.C 287 -Parser::parse401(ServerConnection *cnx, - Person *from, String rest) +Parser::parse401 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 289 - StringTokenizer st(rest); - st.nextToken(); - String nick = st.nextToken(); - - if (cnx->bot->spyList.find(nick) != cnx->bot->spyList.end()) { - delete cnx->bot->spyList[nick]; - cnx->bot->spyList.erase(nick); - } + StringTokenizer st (rest); + st.nextToken (); + String nick = st.nextToken (); + if (cnx->bot->spyList.find (nick) != cnx->bot->spyList.end ()) + { + delete cnx->bot->spyList[nick]; + cnx->bot->spyList.erase (nick); + } hunk ./source/Parser.C 300 -Parser::parse433(ServerConnection *cnx, - Person *from, String rest) +Parser::parse433 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 304 - - if (cnx->bot->nickName.length() == 9) { - int i; - for (i = 0; i < cnx->bot->nickName.length() && cnx->bot->nickName[i] == '_'; i++) - ; - if (i < cnx->bot->nickName.length()) - cnx->bot->nickName = cnx->bot->nickName.subString(0, i-1) + "_" + cnx->bot->nickName.subString(i+1); - else - cnx->bot->nickName = cnx->bot->nickName.subString(0, 4) + - String((long)(rand() % 10000)); - } - else - cnx->bot->nickName = cnx->bot->nickName + "_"; - - cnx->queue->sendNick(cnx->bot->nickName); + if (cnx->bot->nickName.length () == 9) + { + int i; + for (i = 0; + i < cnx->bot->nickName.length () + && cnx->bot->nickName[i] == '_'; i++); + if (i < cnx->bot->nickName.length ()) + cnx->bot->nickName = + cnx->bot->nickName.subString (0, + i - 1) + "_" + + cnx->bot->nickName.subString (i + 1); + else + cnx->bot->nickName = cnx->bot->nickName.subString (0, 4) + + String ((long) (rand () % 10000)); + } + else + cnx->bot->nickName = cnx->bot->nickName + "_"; + cnx->queue->sendNick (cnx->bot->nickName); hunk ./source/Parser.C 325 -Parser::parse473(ServerConnection *cnx, - Person *from, String rest) +Parser::parse473 (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 327 - StringTokenizer st(rest); - st.nextToken(); - - cnx->bot->logLine(String("Unable to join channel ") + - st.nextToken() + "."); + StringTokenizer st (rest); + st.nextToken (); + cnx->bot->logLine (String ("Unable to join channel ") + + st.nextToken () + "."); hunk ./source/Parser.C 334 -Parser::parseError(ServerConnection *cnx, - Person *from, String rest) +Parser::parseError (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 336 - cnx->bot->logLine(String("Error from server ") + - cnx->bot->serverList->currentServer()->getHostName() + - " (" + String((long)cnx->bot->serverList->currentServer()->getPort()) + - ")."); - cnx->bot->nextServer(); + cnx->bot->logLine (String ("Error from server ") + + cnx->bot->serverList->currentServer ()-> + getHostName () + " (" + + String ((long) cnx->bot->serverList-> + currentServer ()->getPort ()) + ")."); + cnx->bot->nextServer (); hunk ./source/Parser.C 345 -Parser::parseInvite(ServerConnection *cnx, - Person *from, String rest) +Parser::parseInvite (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 347 - String nick = from->getNick(); - StringTokenizer st(rest); - st.nextToken(':'); - String channel = st.rest(); - + String nick = from->getNick (); + StringTokenizer st (rest); + st.nextToken (':'); + String channel = st.rest (); hunk ./source/Parser.C 352 - cnx->bot->botInterp->RunHooks(Hook::INVITE, nick + " " + channel, - scm_listify (Utils::string2SCM(nick), - Utils::string2SCM(channel), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::INVITE, + nick + " " + channel, + scm_listify (Utils:: + string2SCM (nick), + Utils:: + string2SCM + (channel), SCM_UNDEFINED)); hunk ./source/Parser.C 360 - - if (cnx->bot->wantedChannels.find(channel) != - cnx->bot->wantedChannels.end()) - cnx->queue->sendJoin(channel, cnx->bot->wantedChannels[channel]->key); + if (cnx->bot->wantedChannels.find (channel) != + cnx->bot->wantedChannels.end ()) + cnx->queue->sendJoin (channel, cnx->bot->wantedChannels[channel]->key); hunk ./source/Parser.C 366 -Parser::parseJoin(ServerConnection *cnx, - Person *from, String rest) +Parser::parseJoin (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 368 - StringTokenizer st(from->getAddress()); - String n = st.nextToken('!'); - String uh = st.nextToken(); - StringTokenizer st2(rest); - String c = st2.nextToken(':'); + StringTokenizer st (from->getAddress ()); + String n = st.nextToken ('!'); + String uh = st.nextToken (); + StringTokenizer st2 (rest); + String c = st2.nextToken (':'); hunk ./source/Parser.C 375 - hunk ./source/Parser.C 376 - cnx->bot->botInterp->RunHooks(Hook::JOIN, n + " " + c, - scm_listify (Utils::string2SCM(n), - Utils::string2SCM(c), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::JOIN, n + " " + c, + scm_listify (Utils:: + string2SCM (n), + Utils:: + string2SCM (c), SCM_UNDEFINED)); hunk ./source/Parser.C 382 - hunk ./source/Parser.C 383 - if (c.find('\007') >= 0) { - joinAndMode = true; - StringTokenizer st3(c); - c = st3.nextToken('\007'); - String m = st3.rest(); - mode = c + " +" + m; - for (int i = 0; i < m.length(); i++) - mode = mode + " " + n; - } + if (c.find ('\007') >= 0) + { + joinAndMode = true; + StringTokenizer st3 (c); + c = st3.nextToken ('\007'); + String m = st3.rest (); + mode = c + " +" + m; + for (int i = 0; i < m.length (); i++) + mode = mode + " " + n; + } hunk ./source/Parser.C 394 - if (n == cnx->bot->nickName) { - cnx->bot->logLine(String("Joined channel ") + c + "."); - if (cnx->bot->wantedChannels.find(c) != cnx->bot->wantedChannels.end()) - cnx->bot->channelList->addChannel(cnx, c, cnx->bot->wantedChannels[c]->keep); - else - cnx->bot->channelList->addChannel(cnx, c); - cnx->queue->sendWho(c); - cnx->queue->sendChannelMode(String("MODE ") + c + " b"); - cnx->queue->sendChannelMode(String("MODE ") + c); - } else { - Channel * ch = cnx->bot->channelList->getChannel(c); - if (!ch) - return; - ShitEntry * se = cnx->bot->shitList->getShit(n+"!"+uh, c); - if (se && se->isStillValid() && - se->getShitLevel() >= ShitEntry::SHIT_NOJOIN) { - cnx->queue->sendChannelMode(c, "+b", se->getMask()); - cnx->queue->sendKick(c, n, se->getShitReason()); - return; + if (n == cnx->bot->nickName) + { + cnx->bot->logLine (String ("Joined channel ") + c + "."); + if (cnx->bot->wantedChannels.find (c) != + cnx->bot->wantedChannels.end ()) + cnx->bot->channelList-> + addChannel (cnx, c, cnx->bot->wantedChannels[c]->keep); + else + cnx->bot->channelList->addChannel (cnx, c); + cnx->queue->sendWho (c); + cnx->queue->sendChannelMode (String ("MODE ") + c + " b"); + cnx->queue->sendChannelMode (String ("MODE ") + c); hunk ./source/Parser.C 407 - ch->addNick(n, uh, 0, cnx->bot->userList); - if (ch->getUser(n)->getAop() && !(ch->getUser(n)->mode & User::OP_MODE) && cnx->bot->iAmOp(c)) { - // This is a part of the antispoof code - ch->getUser(n)->userkey = Utils::getKey(); - cnx->queue->sendCTCP(n, "PING", ch->getUser(n)->userkey + " " + c); + else + { + Channel *ch = cnx->bot->channelList->getChannel (c); + if (!ch) + return; + ShitEntry *se = cnx->bot->shitList->getShit (n + "!" + uh, c); + if (se && se->isStillValid () && + se->getShitLevel () >= ShitEntry::SHIT_NOJOIN) + { + cnx->queue->sendChannelMode (c, "+b", se->getMask ()); + cnx->queue->sendKick (c, n, se->getShitReason ()); + return; + } + ch->addNick (n, uh, 0, cnx->bot->userList); + if (ch->getUser (n)->getAop () + && !(ch->getUser (n)->mode & User::OP_MODE) && cnx->bot->iAmOp (c)) + { + // This is a part of the antispoof code + ch->getUser (n)->userkey = Utils::getKey (); + cnx->queue->sendCTCP (n, "PING", + ch->getUser (n)->userkey + " " + c); + } hunk ./source/Parser.C 430 - } hunk ./source/Parser.C 432 - parseMode(cnx, 0, mode); + parseMode (cnx, 0, mode); hunk ./source/Parser.C 436 -Parser::parseKick(ServerConnection *cnx, - Person *from, String rest) +Parser::parseKick (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 438 - StringTokenizer st(rest); - String channel = st.nextToken(); - String target = st.nextToken(); - String reason = st.rest().subString(1); - + StringTokenizer st (rest); + String channel = st.nextToken (); + String target = st.nextToken (); + String reason = st.rest ().subString (1); hunk ./source/Parser.C 443 - cnx->bot->botInterp->RunHooks(Hook::KICK, target + " " + from->getNick() + " " - + channel + " " + reason, - scm_listify (Utils::string2SCM(target), - Utils::string2SCM(from->getNick()), - Utils::string2SCM(channel), - Utils::string2SCM(reason), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::KICK, + target + " " + + from->getNick () + " " + + channel + " " + reason, + scm_listify (Utils:: + string2SCM + (target), + Utils:: + string2SCM (from-> + getNick + ()), + Utils:: + string2SCM + (channel), + Utils:: + string2SCM + (reason), SCM_UNDEFINED)); hunk ./source/Parser.C 461 - - if (target == cnx->bot->nickName) { - cnx->bot->logLine(from->getAddress() + " kicked me out of channel " + - channel + " (" + reason + ")."); - cnx->queue->sendJoin(channel, cnx->bot->channelList->getChannel(channel)->channelKey); - cnx->bot->channelList->delChannel(channel); - } else { - if (!cnx->bot->channelList->getChannel(channel)) return; - User *u = cnx->bot->channelList->getChannel(channel)->getUser(target); - if (u && u->getProt() >= User::NO_KICK) { - String fromNick = from->getNick(); - User *v = cnx->bot->channelList->getChannel(channel)->getUser(fromNick); - if (v->getProt() < User::NO_KICK) { - cnx->bot->logLine(from->getAddress() + " kicked " + target + - " (protected) out of channel " + channel + - " (" + reason + ")."); - cnx->queue->sendKick(channel, fromNick, - target + " \002is protected !\002"); - } + if (target == cnx->bot->nickName) + { + cnx->bot->logLine (from->getAddress () + + " kicked me out of channel " + channel + + " (" + reason + ")."); + cnx->queue->sendJoin (channel, + cnx->bot->channelList-> + getChannel (channel)->channelKey); + cnx->bot->channelList->delChannel (channel); + } + else + { + if (!cnx->bot->channelList->getChannel (channel)) + return; + User *u = cnx->bot->channelList->getChannel (channel)->getUser (target); + if (u && u->getProt () >= User::NO_KICK) + { + String fromNick = from->getNick (); + User *v = + cnx->bot->channelList->getChannel (channel)->getUser (fromNick); + if (v->getProt () < User::NO_KICK) + { + cnx->bot->logLine (from->getAddress () + " kicked " + target + + " (protected) out of channel " + channel + + " (" + reason + ")."); + cnx->queue->sendKick (channel, fromNick, + target + " \002is protected !\002"); + } + } + cnx->bot->channelList->getChannel (channel)->delNick (target); hunk ./source/Parser.C 492 - cnx->bot->channelList->getChannel(channel)->delNick(target); - } hunk ./source/Parser.C 495 -Parser::parseMode(ServerConnection *cnx, - Person *from, String rest) +Parser::parseMode (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 497 - StringTokenizer st(rest); - String ch = st.nextToken(); - String modes = st.rest(); - + StringTokenizer st (rest); + String ch = st.nextToken (); + String modes = st.rest (); hunk ./source/Parser.C 501 - if (from) - cnx->bot->botInterp->RunHooks(Hook::MODE, from->getNick() + " " + ch + - " " + modes, - scm_listify (Utils::string2SCM(from->getNick()), - Utils::string2SCM(ch), - Utils::string2SCM(modes), - SCM_UNDEFINED)); + if (from) + cnx->bot->botInterp->RunHooks (Hook::MODE, + from->getNick () + " " + ch + + " " + modes, + scm_listify (Utils:: + string2SCM (from-> + getNick + ()), + Utils:: + string2SCM (ch), + Utils:: + string2SCM (modes), + SCM_UNDEFINED)); hunk ./source/Parser.C 515 - - - if (Utils::isChannel(ch)) { - Channel *c = cnx->bot->channelList->getChannel(ch); - if (!c) - return; - if (from) - c->parseMode(from, modes); - else - c->parseMode(0, modes); - } + if (Utils::isChannel (ch)) + { + Channel *c = cnx->bot->channelList->getChannel (ch); + if (!c) + return; + if (from) + c->parseMode (from, modes); + else + c->parseMode (0, modes); + } hunk ./source/Parser.C 528 -Parser::parseNick(ServerConnection *cnx, - Person *from, String rest) +Parser::parseNick (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 530 - String on_orig = from->getNick(); - String on = on_orig.toLower(); - String nn = rest.subString(1); - String nn_lower = nn.toLower(); - + String on_orig = from->getNick (); + String on = on_orig.toLower (); + String nn = rest.subString (1); + String nn_lower = nn.toLower (); hunk ./source/Parser.C 535 - cnx->bot->botInterp->RunHooks(Hook::NICKNAME, on_orig + " " + nn, - scm_listify (Utils::string2SCM(on_orig), - Utils::string2SCM(nn), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::NICKNAME, + on_orig + " " + nn, + scm_listify (Utils:: + string2SCM + (on_orig), + Utils:: + string2SCM (nn), + SCM_UNDEFINED)); hunk ./source/Parser.C 544 + if ((cnx->bot->nickName).toLower () == on) + { + cnx->bot->userList->removeFirst (); + cnx->bot->userList->addUserFirst (nn + "!" + + cnx->bot->userHost, "*", 0, + 3, true, -1, ""); + cnx->bot->lastNickNameChange = time (0); + cnx->bot->nickName = nn; + cnx->bot->rehash (); + } hunk ./source/Parser.C 555 - if ((cnx->bot->nickName).toLower() == on) { - cnx->bot->userList->removeFirst(); - cnx->bot->userList->addUserFirst(nn + "!" + cnx->bot->userHost, "*", 0, 3, true, -1, ""); - cnx->bot->lastNickNameChange = time(0); - cnx->bot->nickName = nn; - cnx->bot->rehash(); - } - - if (cnx->bot->spyList.find(on) != cnx->bot->spyList.end()) { - cnx->bot->spyList[nn_lower] = cnx->bot->spyList[on]; - cnx->bot->spyList.erase(on); - } + if (cnx->bot->spyList.find (on) != cnx->bot->spyList.end ()) + { + cnx->bot->spyList[nn_lower] = cnx->bot->spyList[on]; + cnx->bot->spyList.erase (on); + } hunk ./source/Parser.C 561 - for (std::map >::iterator it = - cnx->bot->channelList->begin(); - it != cnx->bot->channelList->end(); - ++it) - if ((*it).second->hasNick(on)) - (*it).second->changeNick(on, nn_lower); + for (std::map < String, Channel *, + std::less < String > >::iterator it = + cnx->bot->channelList->begin (); + it != cnx->bot->channelList->end (); ++it) + if ((*it).second->hasNick (on)) + (*it).second->changeNick (on, nn_lower); hunk ./source/Parser.C 570 -Parser::parseNotice(ServerConnection *cnx, - Person *from, String rest) +Parser::parseNotice (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 573 - hunk ./source/Parser.C 574 - nick = from->getNick(); - - StringTokenizer st(rest); - String to = st.nextToken(); - - rest = st.rest().subString(1); - - if (rest[0] != '\001') { + nick = from->getNick (); + StringTokenizer st (rest); + String to = st.nextToken (); + rest = st.rest ().subString (1); + if (rest[0] != '\001') + { hunk ./source/Parser.C 581 - if (Utils::isChannel(to)) - cnx->bot->botInterp->RunHooks(Hook::PUBLIC_NOTICE, nick + " " + - to + " " + rest, - scm_listify (Utils::string2SCM(nick), - Utils::string2SCM(to), - Utils::string2SCM(rest), - SCM_UNDEFINED)); - else - cnx->bot->botInterp->RunHooks(Hook::NOTICE, nick + " " + rest, - scm_listify (Utils::string2SCM(nick), - Utils::string2SCM(rest), - SCM_UNDEFINED)); + if (Utils::isChannel (to)) + cnx->bot->botInterp->RunHooks (Hook::PUBLIC_NOTICE, + nick + " " + to + " " + rest, + scm_listify (Utils:: + string2SCM (nick), + Utils:: + string2SCM (to), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); + else + cnx->bot->botInterp->RunHooks (Hook::NOTICE, nick + " " + rest, + scm_listify (Utils:: + string2SCM (nick), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); hunk ./source/Parser.C 599 - return; - } - - rest = rest.subString(1, rest.length() - 2); - StringTokenizer st2(rest); - String command = st2.nextToken(); - rest = st2.rest(); + return; + } hunk ./source/Parser.C 602 + rest = rest.subString (1, rest.length () - 2); + StringTokenizer st2 (rest); + String command = st2.nextToken (); + rest = st2.rest (); hunk ./source/Parser.C 607 - cnx->bot->botInterp->RunHooks(Hook::CTCP_REPLY, nick + " " + command + - " " + rest, - scm_listify (Utils::string2SCM(nick), - Utils::string2SCM(command), - Utils::string2SCM(rest), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::CTCP_REPLY, + nick + " " + command + " " + + rest, + scm_listify (Utils:: + string2SCM (nick), + Utils:: + string2SCM + (command), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); hunk ./source/Parser.C 619 - - if (command == "PING") { - StringTokenizer st3(rest); - rest = st3.nextToken(); - String c = st3.rest(); - if (cnx->bot->channelList->getChannel(c) && - cnx->bot->channelList->getChannel(c)->getUser(nick) && - cnx->bot->channelList->getChannel(c)->getUser(nick)->getAop() && - !(cnx->bot->channelList->getChannel(c)->getUser(nick)->mode & User::OP_MODE) - && cnx->bot->channelList->getChannel(c)->getUser(nick)->userkey == rest) - cnx->queue->sendChannelMode(c, "+o", nick); - } + if (command == "PING") + { + StringTokenizer st3 (rest); + rest = st3.nextToken (); + String c = st3.rest (); + if (cnx->bot->channelList->getChannel (c) && + cnx->bot->channelList->getChannel (c)->getUser (nick) && + cnx->bot->channelList->getChannel (c)->getUser (nick)-> + getAop () + && !(cnx->bot->channelList->getChannel (c)-> + getUser (nick)->mode & User::OP_MODE) + && cnx->bot->channelList->getChannel (c)->getUser (nick)-> + userkey == rest) + cnx->queue->sendChannelMode (c, "+o", nick); + } hunk ./source/Parser.C 637 -Parser::parsePrivmsg(ServerConnection *cnx, - Person *from, String rest) +Parser::parsePrivmsg (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 639 - String nick = from->getNick(); - - StringTokenizer st(rest); - String to = st.nextToken(); - String fromUserhost = Utils::getUserhost(from->getAddress()); - - rest = st.rest().subString(1); - - if (++(cnx->bot->ignoredUserhosts[fromUserhost]) - > Bot::MAX_MESSAGES) { - if (cnx->bot->ignoredUserhosts[fromUserhost] - == Bot::MAX_MESSAGES+1) { + String nick = from->getNick (); + StringTokenizer st (rest); + String to = st.nextToken (); + String fromUserhost = Utils::getUserhost (from->getAddress ()); + rest = st.rest ().subString (1); + if (++(cnx->bot->ignoredUserhosts[fromUserhost]) > Bot::MAX_MESSAGES) + { + if (cnx->bot->ignoredUserhosts[fromUserhost] == Bot::MAX_MESSAGES + 1) + { hunk ./source/Parser.C 649 - cnx->bot->botInterp->RunHooks(Hook::FLOOD, nick, - scm_listify (Utils::string2SCM(nick), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::FLOOD, nick, + scm_listify (Utils:: + string2SCM (nick), + SCM_UNDEFINED)); hunk ./source/Parser.C 654 - cnx->bot->ignoredUserhosts[fromUserhost] += Bot::IGNORE_DELAY; - cnx->bot->logLine(from->getAddress() + - " is flooding me. We will ignore him/her/it."); - if (!Utils::isChannel(to)) - from->sendNotice(String("\002You are now being ignored for ") + - String((long)Bot::IGNORE_DELAY) + " seconds.\002"); - } - // The following lines reset the counter if you use the - // command "!sorry" (if '!' is your command char). - // This is not documented, I know. But one probably does - // not want that every users can bypass the flood control - // Of course, if you want this feature to remain 'secret', - // do not use it in public. - if (rest.toUpper() == String(cnx->bot->commandChar) + "SORRY") { - cnx->bot->ignoredUserhosts[fromUserhost] = 0; - from->sendNotice("\002Don't do it again!\002"); + cnx->bot->ignoredUserhosts[fromUserhost] += Bot::IGNORE_DELAY; + cnx->bot->logLine (from->getAddress () + + " is flooding me. We will ignore him/her/it."); + if (!Utils::isChannel (to)) + from-> + sendNotice (String ("\002You are now being ignored for ") + + String ((long) Bot::IGNORE_DELAY) + + " seconds.\002"); + } + // The following lines reset the counter if you use the + // command "!sorry" (if '!' is your command char). + // This is not documented, I know. But one probably does + // not want that every users can bypass the flood control + // Of course, if you want this feature to remain 'secret', + // do not use it in public. + if (rest.toUpper () == String (cnx->bot->commandChar) + "SORRY") + { + cnx->bot->ignoredUserhosts[fromUserhost] = 0; + from->sendNotice ("\002Don't do it again!\002"); + } + return; hunk ./source/Parser.C 676 - return; - } hunk ./source/Parser.C 677 - if (rest[0] == '\001') { - rest = rest.subString(1, rest.length() - 2); - if (!Utils::isChannel(to)) - for (std::map >::iterator it = - cnx->bot->spyList.begin(); it != cnx->bot->spyList.end(); ++it) - (*it).second->sendNotice(String("CTCP From ") + nick + - ": " + rest); - Parser::parseCTCP(cnx, from, to, rest); - } - else { - if ((rest.length() < 5 || - rest.subString(1, 5).toUpper() != "IDENT") && - (rest.length() < 8 || - rest.subString(1, 8).toUpper() != "PASSWORD") && - !Utils::isChannel(to)) - for (std::map >::iterator it = - cnx->bot->spyList.begin(); it != cnx->bot->spyList.end(); ++it) - (*it).second->sendNotice(String("*") + nick + "* " + rest); - Parser::parseMessage(cnx, from, to, rest); - } + if (rest[0] == '\001') + { + rest = rest.subString (1, rest.length () - 2); + if (!Utils::isChannel (to)) + for (std::map < String, Person *, + std::less < String > >::iterator it = + cnx->bot->spyList.begin (); it != cnx->bot->spyList.end (); ++it) + (*it).second->sendNotice (String ("CTCP From ") + + nick + ": " + rest); + Parser::parseCTCP (cnx, from, to, rest); + } + else + { + if ((rest.length () < 5 || + rest.subString (1, 5).toUpper () != "IDENT") && + (rest.length () < 8 || + rest.subString (1, 8).toUpper () != "PASSWORD") && + !Utils::isChannel (to)) + for (std::map < String, Person *, + std::less < String > >::iterator it = + cnx->bot->spyList.begin (); it != cnx->bot->spyList.end (); ++it) + (*it).second->sendNotice (String ("*") + nick + "* " + rest); + Parser::parseMessage (cnx, from, to, rest); + } hunk ./source/Parser.C 704 -Parser::parsePart(ServerConnection *cnx, - Person *from, String rest) +Parser::parsePart (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 706 - String n = from->getNick(); - StringTokenizer st(rest); - String channel = st.nextToken(); - + String n = from->getNick (); + StringTokenizer st (rest); + String channel = st.nextToken (); hunk ./source/Parser.C 710 - cnx->bot->botInterp->RunHooks(Hook::LEAVE, n + " " + channel, - scm_listify (Utils::string2SCM(n), - Utils::string2SCM(channel), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::LEAVE, n + " " + channel, + scm_listify (Utils:: + string2SCM (n), + Utils:: + string2SCM + (channel), SCM_UNDEFINED)); hunk ./source/Parser.C 717 - - if (n.toLower() == cnx->bot->nickName.toLower()) { - cnx->bot->logLine(String("Leaved channel ") + channel + "."); - cnx->bot->channelList->delChannel(channel); - } else { - Channel * c = cnx->bot->channelList->getChannel(channel); - if (!c) return; - c->delNick(n); - if (c->countOp == 0 && c->count == 1) { - cnx->queue->sendPart(channel); - cnx->queue->sendJoin(channel, cnx->bot->wantedChannels[channel]->key); + if (n.toLower () == cnx->bot->nickName.toLower ()) + { + cnx->bot->logLine (String ("Leaved channel ") + channel + "."); + cnx->bot->channelList->delChannel (channel); + } + else + { + Channel *c = cnx->bot->channelList->getChannel (channel); + if (!c) + return; + c->delNick (n); + if (c->countOp == 0 && c->count == 1) + { + cnx->queue->sendPart (channel); + cnx->queue->sendJoin (channel, + cnx->bot->wantedChannels[channel]->key); + } hunk ./source/Parser.C 735 - } hunk ./source/Parser.C 738 -Parser::parsePing(ServerConnection * cnx, - Person *from, String rest) +Parser::parsePing (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 740 - cnx->queue->sendPong(rest); + cnx->queue->sendPong (rest); hunk ./source/Parser.C 744 -Parser::parsePong(ServerConnection *cnx, - Person *from, String rest) +Parser::parsePong (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 746 - cnx->lag = (cnx->lag + 2 * (time(NULL) - cnx->pingTime)) / 3; + cnx->lag = (cnx->lag + 2 * (time (NULL) - cnx->pingTime)) / 3; hunk ./source/Parser.C 751 -Parser::parseQuit(ServerConnection *cnx, - Person *from, String rest) +Parser::parseQuit (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 753 - String n = from->getNick(); - + String n = from->getNick (); hunk ./source/Parser.C 755 - cnx->bot->botInterp->RunHooks(Hook::SIGNOFF, n + " " + rest, - scm_listify (Utils::string2SCM(n), - Utils::string2SCM(rest), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::SIGNOFF, n + " " + rest, + scm_listify (Utils:: + string2SCM (n), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); hunk ./source/Parser.C 762 - hunk ./source/Parser.C 764 - - for (std::map >::iterator it = - cnx->bot->channelList->begin(); - it != cnx->bot->channelList->end(); - ++it) - (*it).second->delNick(n); + for (std::map < String, Channel *, + std::less < String > >::iterator it = + cnx->bot->channelList->begin (); + it != cnx->bot->channelList->end (); ++it) + (*it).second->delNick (n); hunk ./source/Parser.C 772 -Parser::parseTopic(ServerConnection *cnx, - Person *from, String rest) +Parser::parseTopic (ServerConnection * cnx, Person * from, String rest) hunk ./source/Parser.C 774 - StringTokenizer st(rest); - String channel = st.nextToken(); - String newTopic = st.rest().subString(1); - Channel *c = cnx->bot->channelList->getChannel(channel); - + StringTokenizer st (rest); + String channel = st.nextToken (); + String newTopic = st.rest ().subString (1); + Channel *c = cnx->bot->channelList->getChannel (channel); hunk ./source/Parser.C 779 - cnx->bot->botInterp->RunHooks(Hook::TOPIC, from->getNick() + " " + channel + - " " + newTopic, - scm_listify (Utils::string2SCM(from->getNick()), - Utils::string2SCM(channel), - Utils::string2SCM(newTopic), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::TOPIC, + from->getNick () + " " + + channel + " " + newTopic, + scm_listify (Utils:: + string2SCM (from-> + getNick + ()), + Utils:: + string2SCM + (channel), + Utils:: + string2SCM + (newTopic), SCM_UNDEFINED)); hunk ./source/Parser.C 793 - - if (!c) return; - - if (c->lockedTopic && from->getNick() != cnx->bot->nickName) - cnx->queue->sendTopic(channel, c->channelTopic); - + if (!c) + return; + if (c->lockedTopic && from->getNick () != cnx->bot->nickName) + cnx->queue->sendTopic (channel, c->channelTopic); hunk ./source/Parser.C 801 -Parser::parseCTCP(ServerConnection *cnx, - Person *from, String to, - String parameters) +Parser::parseCTCP (ServerConnection * cnx, + Person * from, String to, String parameters) hunk ./source/Parser.C 804 - StringTokenizer st(parameters); - String command = st.nextToken().toUpper(); - String nick = from->getNick(); + StringTokenizer st (parameters); + String command = st.nextToken ().toUpper (); + String nick = from->getNick (); hunk ./source/Parser.C 808 - - if (st.hasMoreTokens()) - rest = st.rest(); + if (st.hasMoreTokens ()) + rest = st.rest (); hunk ./source/Parser.C 812 - hunk ./source/Parser.C 813 - cnx->bot->botInterp->RunHooks(Hook::CTCP, nick + " " + to + " " + - command + " " + rest, - scm_listify (Utils::string2SCM(nick), - Utils::string2SCM(to), - Utils::string2SCM(command), - Utils::string2SCM(rest), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::CTCP, + nick + " " + to + " " + + command + " " + rest, + scm_listify (Utils:: + string2SCM (nick), + Utils:: + string2SCM (to), + Utils:: + string2SCM + (command), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); hunk ./source/Parser.C 827 - hunk ./source/Parser.C 828 - cnx->queue->sendCTCPReply(nick, "PING", rest); + cnx->queue->sendCTCPReply (nick, "PING", rest); hunk ./source/Parser.C 830 - cnx->queue->sendCTCPReply(nick, "VERSION", cnx->bot->versionString); - - else if (command == "CLOCK") { - time_t diff = time(NULL) - cnx->bot->startTime; - cnx->queue->sendCTCPReply(nick, "CLOCK", String("elapsed time: ") + - String((long)(diff / 86400)) + "d" + - String((long)(diff % 86400) / 3600) + - "h" + String((long)(diff % 3600) / 60) + - "m" + String((long)(diff % 60)) + "s"); - } else if (command == "COMMAND") - cnx->queue->sendCTCPReply(nick, - "COMMAND", - String(cnx->bot->commandChar)); + cnx->queue->sendCTCPReply (nick, "VERSION", cnx->bot->versionString); + else if (command == "CLOCK") + { + time_t diff = time (NULL) - cnx->bot->startTime; + cnx->queue->sendCTCPReply (nick, "CLOCK", + String ("elapsed time: ") + + String ((long) (diff / 86400)) + + "d" + + String ((long) (diff % 86400) / + 3600) + "h" + + String ((long) (diff % 3600) / 60) + + "m" + String ((long) (diff % 60)) + "s"); + } + else if (command == "COMMAND") + cnx->queue->sendCTCPReply (nick, + "COMMAND", String (cnx->bot->commandChar)); hunk ./source/Parser.C 847 - cnx->queue->sendCTCPReply(nick, "LAG", - String((long)cnx->lag) + " second(s)"); - else if (command == "DCC") { - StringTokenizer st2(rest); - command = st2.nextToken().toUpper(); - if (command == "CHAT") { - // FIXME: Re-activate and debug DCC - st2.nextToken(); - unsigned long address = - ntohl (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->queue->sendCTCPReply (nick, "LAG", + String ((long) cnx->lag) + " second(s)"); + else if (command == "DCC") + { + StringTokenizer st2 (rest); + command = st2.nextToken ().toUpper (); + if (command == "CHAT") + { + // FIXME: Re-activate and debug DCC + st2.nextToken (); + unsigned long address = + ntohl (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); + } hunk ./source/Parser.C 864 - } hunk ./source/Parser.C 865 - else if (command == "ACTION") { - cnx->bot->botInterp->RunHooks(Hook::ACTION, from->getAddress() + " " + - to + " " + rest, - scm_listify (Utils::string2SCM(from->getAddress()), - Utils::string2SCM(to), - Utils::string2SCM(rest), - SCM_UNDEFINED)); - } + else if (command == "ACTION") + { + cnx->bot->botInterp->RunHooks (Hook::ACTION, + from->getAddress () + " " + to + + " " + rest, + scm_listify (Utils:: + string2SCM (from-> + getAddress + ()), + Utils:: + string2SCM (to), + Utils:: + string2SCM (rest), + SCM_UNDEFINED)); + } hunk ./source/Parser.C 883 -struct userFunctionsStruct userFunctionsInit[] = - -{ - { "ACTION", UserCommands::Action, User::USER, true }, - { "ADDUSER", UserCommands::AddUser, User::FRIEND, false }, - { "ADDSERVER", UserCommands::AddServer, User::FRIEND, false }, - { "ADDSHIT", UserCommands::AddShit, User::FRIEND, false }, - { "ALIAS", UserCommands::Alias, User::MASTER, false }, - { "BAN", UserCommands::Ban, User::USER, true }, - { "BANLIST", UserCommands::BanList, User::USER, true }, - // { "CHANGELEVEL", UserCommands::ChangeLevel, User::FRIEND, false }, - { "CHANNELS", UserCommands::Channels, User::FRIEND, false }, - { "CYCLE", UserCommands::Cycle, User::FRIEND, true }, - { "DCCLIST", UserCommands::DCCList, User::FRIEND, false }, - { "DEBAN", UserCommands::Deban, User::USER, true }, - { "DELSERVER", UserCommands::DelServer, User::FRIEND, false }, - { "DELUSER", UserCommands::DelUser, User::FRIEND, false }, - { "DELSHIT", UserCommands::DelShit, User::FRIEND, false }, - { "DEOP", UserCommands::Deop, User::TRUSTED_USER, true }, - { "DIE", UserCommands::Die, User::MASTER, false }, - { "DO", UserCommands::Do, User::MASTER, false }, -#ifdef USESCRIPTS - { "EXECUTE", UserCommands::Execute, User::MASTER, false }, -#endif - { "HELP", UserCommands::Help, User::NONE, false }, - { "IDENT", UserCommands::Ident, User::NONE, true }, - { "INVITE", UserCommands::Invite, User::USER, true }, - { "JOIN", UserCommands::Join, User::FRIEND, false }, - { "KEEP", UserCommands::Keep, User::FRIEND, true }, - { "KICK", UserCommands::Kick, User::USER, true }, - { "KICKBAN", UserCommands::KickBan, User::USER, true }, - { "LOAD", UserCommands::Load, User::FRIEND, false }, -#ifdef USESCRIPTS - { "LOADSCRIPT", UserCommands::LoadScript, User::MASTER, false }, -#endif - { "LOCK", UserCommands::Lock, User::FRIEND, true }, - { "MODE", UserCommands::Mode, User::FRIEND, true }, - { "MSG", UserCommands::Msg, User::USER, false }, - { "NAMES", UserCommands::Names, User::USER, true }, - { "NEXTSERVER", UserCommands::NextServer, User::FRIEND, false }, - { "NICK", UserCommands::Nick, User::FRIEND, false }, - { "NSLOOKUP", UserCommands::NsLookup, User::USER, false }, - { "OP", UserCommands::Op, User::TRUSTED_USER, true }, - { "PART", UserCommands::Part, User::FRIEND, true }, - { "PASSWORD", UserCommands::Password, User::USER, true }, - { "RECONNECT", UserCommands::Reconnect, User::FRIEND, false }, - { "RSPYMESSAGE", UserCommands::RSpyMessage, User::USER, false }, - { "SAVE", UserCommands::Save, User::FRIEND, false }, - { "SAY", UserCommands::Say, User::USER, true }, - { "SERVER", UserCommands::Server, User::FRIEND, false }, - { "SERVERLIST", UserCommands::ServerList, User::FRIEND, false }, - { "SETVERSION", UserCommands::SetVersion, User::MASTER, false }, - { "SHITLIST", UserCommands::ShitList, User::FRIEND, false }, - { "SPYLIST", UserCommands::SpyList, User::USER, false }, - { "SPYMESSAGE", UserCommands::SpyMessage, User::USER, false }, - { "STATS", UserCommands::Stats, User::FRIEND, true }, - { "TBAN", UserCommands::TBan, User::USER, true }, - { "TKBAN", UserCommands::TKBan, User::USER, true }, - { "TOPIC", UserCommands::Topic, User::USER, true }, - { "UNLOCK", UserCommands::Unlock, User::FRIEND, true }, - { "USERLIST", UserCommands::UserList, User::FRIEND, false }, - { "WHO", UserCommands::Who, User::NONE, true }, - { "WHOIS", UserCommands::Whois, User::FRIEND, true }, - { "", 0, 0, false } -}; - +// struct userFunctionsStruct userFunctionsInit[] = { +// { +// "ACTION", UserCommands::Action, User::USER, true} +// , +// { +// "ADDUSER", UserCommands::AddUser, User::FRIEND, false} +// , +// { +// "ADDSERVER", UserCommands::AddServer, User::FRIEND, false} +// , +// { +// "ADDSHIT", UserCommands::AddShit, User::FRIEND, false} +// , +// { +// "ALIAS", UserCommands::Alias, User::MASTER, false} +// , +// { +// "BAN", UserCommands::Ban, User::USER, true} +// , +// { +// "BANLIST", UserCommands::BanList, User::USER, true} +// , +// // { "CHANGELEVEL", UserCommands::ChangeLevel, User::FRIEND, false }, +// { +// "CHANNELS", UserCommands::Channels, User::FRIEND, false} +// , +// { +// "CYCLE", UserCommands::Cycle, User::FRIEND, true} +// , +// { +// "DCCLIST", UserCommands::DCCList, User::FRIEND, false} +// , +// { +// "DEBAN", UserCommands::Deban, User::USER, true} +// , +// { +// "DELSERVER", UserCommands::DelServer, User::FRIEND, false} +// , +// { +// "DELUSER", UserCommands::DelUser, User::FRIEND, false} +// , +// { +// "DELSHIT", UserCommands::DelShit, User::FRIEND, false} +// , +// { +// "DEOP", UserCommands::Deop, User::TRUSTED_USER, true} +// , +// { +// "DIE", UserCommands::Die, User::MASTER, false} +// , +// { +// "DO", UserCommands::Do, User::MASTER, false} +// , +// #ifdef USESCRIPTS +// { +// "EXECUTE", UserCommands::Execute, User::MASTER, false} +// , +// #endif +// { +// "HELP", UserCommands::Help, User::NONE, false} +// , +// { +// "IDENT", UserCommands::Ident, User::NONE, true} +// , +// { +// "INVITE", UserCommands::Invite, User::USER, true} +// , +// { +// "JOIN", UserCommands::Join, User::FRIEND, false} +// , +// { +// "KEEP", UserCommands::Keep, User::FRIEND, true} +// , +// { +// "KICK", UserCommands::Kick, User::USER, true} +// , +// { +// "KICKBAN", UserCommands::KickBan, User::USER, true} +// , +// { +// "LOAD", UserCommands::Load, User::FRIEND, false} +// , +// #ifdef USESCRIPTS +// { +// "LOADSCRIPT", UserCommands::LoadScript, User::MASTER, false} +// , +// #endif +// { +// "LOCK", UserCommands::Lock, User::FRIEND, true} +// , +// { +// "MODE", UserCommands::Mode, User::FRIEND, true} +// , +// { +// "MSG", UserCommands::Msg, User::USER, false} +// , +// { +// "NAMES", UserCommands::Names, User::USER, true} +// , +// { +// "NEXTSERVER", UserCommands::NextServer, User::FRIEND, false} +// , +// { +// "NICK", UserCommands::Nick, User::FRIEND, false} +// , +// { +// "NSLOOKUP", UserCommands::NsLookup, User::USER, false} +// , +// { +// "OP", UserCommands::Op, User::TRUSTED_USER, true} +// , +// { +// "PART", UserCommands::Part, User::FRIEND, true} +// , +// { +// "PASSWORD", UserCommands::Password, User::USER, true} +// , +// { +// "RECONNECT", UserCommands::Reconnect, User::FRIEND, false} +// , +// { +// "RSPYMESSAGE", UserCommands::RSpyMessage, User::USER, false} +// , +// { +// "SAVE", UserCommands::Save, User::FRIEND, false} +// , +// { +// "SAY", UserCommands::Say, User::USER, true} +// , +// { +// "SERVER", UserCommands::Server, User::FRIEND, false} +// , +// { +// "SERVERLIST", UserCommands::ServerList, User::FRIEND, false} +// , +// { +// "SETVERSION", UserCommands::SetVersion, User::MASTER, false} +// , +// { +// "SHITLIST", UserCommands::ShitList, User::FRIEND, false} +// , +// { +// "SPYLIST", UserCommands::SpyList, User::USER, false} +// , +// { +// "SPYMESSAGE", UserCommands::SpyMessage, User::USER, false} +// , +// { +// "STATS", UserCommands::Stats, User::FRIEND, true} +// , +// { +// "TBAN", UserCommands::TBan, User::USER, true} +// , +// { +// "TKBAN", UserCommands::TKBan, User::USER, true} +// , +// { +// "TOPIC", UserCommands::Topic, User::USER, true} +// , +// { +// "UNLOCK", UserCommands::Unlock, User::FRIEND, true} +// , +// { +// "USERLIST", UserCommands::UserList, User::FRIEND, false} +// , +// { +// "WHO", UserCommands::Who, User::NONE, true} +// , +// { +// "WHOIS", UserCommands::Whois, User::FRIEND, true} +// , +// { +// "", 0, 0, false} +// }; hunk ./source/Parser.C 1058 -Parser::parseMessage(ServerConnection *cnx, - Person *from, String to, - String parameters) +Parser::parseMessage (ServerConnection * cnx, + Person * from, String to, String parameters) hunk ./source/Parser.C 1062 - if (Utils::isChannel(to)) - cnx->bot->botInterp->RunHooks(Hook::PUBLIC, from->getNick() + " " + - to + " " + parameters, - scm_listify (Utils::string2SCM(from->getNick()), - Utils::string2SCM(to), - Utils::string2SCM(parameters), - SCM_UNDEFINED)); + if (Utils::isChannel (to)) + cnx->bot->botInterp->RunHooks (Hook::PUBLIC, + from->getNick () + " " + to + + " " + parameters, + scm_listify (Utils:: + string2SCM (from-> + getNick + ()), + Utils:: + string2SCM (to), + Utils:: + string2SCM + (parameters), SCM_UNDEFINED)); hunk ./source/Parser.C 1076 - cnx->bot->botInterp->RunHooks(Hook::MESSAGE, from->getNick() + " " + parameters, - scm_listify (Utils::string2SCM(from->getNick()), - Utils::string2SCM(parameters), - SCM_UNDEFINED)); + cnx->bot->botInterp->RunHooks (Hook::MESSAGE, + from->getNick () + " " + + parameters, + scm_listify (Utils:: + string2SCM (from-> + getNick + ()), + Utils:: + string2SCM + (parameters), SCM_UNDEFINED)); hunk ./source/Parser.C 1087 - hunk ./source/Parser.C 1090 - StringTokenizer st(parameters); - - String command = st.nextToken().subString(1).toUpper(); - String rest = st.rest().trim(); + StringTokenizer st (parameters); + String command = st.nextToken ().subString (1).toUpper (); + String rest = st.rest ().trim (); hunk ./source/Parser.C 1095 - - std::list::iterator it; - for (it = cnx->bot->userFunctions.begin(); - it != cnx->bot->userFunctions.end(); - ++it) - if (command == (*it)->name) { - if ((*it)->needsChannelName) { - if (Utils::isChannel(rest)) { - StringTokenizer st2(rest); - to = st.nextToken(); - rest = st.rest(); - } - if (!Utils::isChannel(to)) { - from->sendNotice("\002You need to supply a channel name" - " for this command\002"); - return; - } - if (!cnx->bot->channelList->getChannel(to)) { - from->sendNotice(String("\002I am not on channel\002 ") + - to); - return; - } - level = Utils::getLevel(cnx->bot, from->getAddress(), to); - User * u = 0; - if (Channel *c = cnx->bot->channelList->getChannel(to)) - u = c->getUser(from->getNick()); - if (!u || !u->userListItem) - identified = true; - else - identified = u->userListItem->passwd == "" || u->userListItem->identified > 0; - } else { - level = Utils::getLevel(cnx->bot, from->getAddress()); - identified = true; - } - if (level >= (*it)->minLevel) { - cnx->bot->logLine(from->getAddress() + " did " + command + - " " + rest); + userFunction * f = cnx->bot->userFunctions[command]; + if (f) + { + if (f->needsChannelName) + { + if (Utils::isChannel (rest)) + { + StringTokenizer st2 (rest); + to = st.nextToken (); + rest = st.rest (); + } + if (!Utils::isChannel (to)) + { + from->sendNotice ("\002You need to supply a channel name" + " for this command\002"); + return; + } + if (!cnx->bot->channelList->getChannel (to)) + { + from->sendNotice (String ("\002I am not on channel\002 ") + + to); + return; + } + level = Utils::getLevel (cnx->bot, from->getAddress (), to); + User *u = 0; + if (Channel * c = cnx->bot->channelList->getChannel (to)) + u = c->getUser (from->getNick ()); + if (!u || !u->userListItem) + identified = true; + else + identified = u->userListItem->passwd == "" + || u->userListItem->identified > 0; + } + else + { + level = Utils::getLevel (cnx->bot, from->getAddress ()); + identified = true; + } + if (level >= f->minLevel) + { + cnx->bot->logLine (from->getAddress () + " did " + command + + " " + rest); hunk ./source/Parser.C 1138 - if ((*it)->argsCount != -1) { - Parser::parseScriptFunction(cnx, to, (*it)->needsChannelName, - (*it)->scmFunc, (*it)->argsCount, rest); - } else { - (*it)->function(cnx, from, to, rest); - } + if (f->argsCount != -1) + { + Parser::parseScriptFunction (cnx, to, f->needsChannelName, + f->scmFunc, f->argsCount, + rest); + } + else + { + f->function (cnx, from, to, rest); + } hunk ./source/Parser.C 1149 - (*it)->function(cnx, from, to, rest); + f->function (cnx, from, to, rest); hunk ./source/Parser.C 1151 - break; - } else { - if (!identified) - from->sendNotice(String("\002You are not identified on channel\002 ")+to); + } + else + { + if (!identified) + from-> + sendNotice (String + ("\002You are not identified on channel\002 ") + + to); + } hunk ./source/Parser.C 1161 - } hunk ./source/Parser.C 1165 -Parser::parseScriptFunction(ServerConnection *cnx, String channel, - bool needsChannelName, SCM scmFunc, - int argsCount, String parameters) +Parser::parseScriptFunction (ServerConnection * cnx, + String channel, + bool needsChannelName, + SCM scmFunc, int argsCount, String parameters) hunk ./source/Parser.C 1172 + if (needsChannelName) + { + args_list = gh_append2 (args_list, + scm_listify (Utils:: + string2SCM (channel), + SCM_UNDEFINED)); + argsCount--; + } hunk ./source/Parser.C 1181 - if (needsChannelName) { - args_list = gh_append2(args_list, - scm_listify (Utils::string2SCM(channel), - SCM_UNDEFINED)); - argsCount--; - } - - StringTokenizer st(parameters); - for (int i = argsCount; i > 0; i--) { - if (i == 1) - param = st.rest(); - else - param = st.nextToken(); - args_list = gh_append2(args_list, - scm_listify (Utils::string2SCM(param), - SCM_UNDEFINED)); - } + StringTokenizer st (parameters); + for (int i = argsCount; i > 0; i--) + { + if (i == 1) + param = st.rest (); + else + param = st.nextToken (); + args_list = gh_append2 (args_list, + scm_listify (Utils::string2SCM (param), + SCM_UNDEFINED)); + } hunk ./source/Parser.C 1196 - - gh_catch(SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper, - (void *)&wd, (scm_t_catch_handler) Interp::ErrorHandler, - 0); + gh_catch (SCM_BOOL_T, (scm_t_catch_body) scm_apply_wrapper, + (void *) &wd, (scm_t_catch_handler) Interp::ErrorHandler, 0); hunk ./source/Parser.H 38 -struct userFunctionsStruct { - String name; - void (*function)(ServerConnection *, Person *, String, String); - int minLevel; - bool needsChannelName; -}; +// struct userFunctionsStruct { +// // String name; +// void (*function)(ServerConnection *, Person *, String, String); +// int minLevel; +// bool needsChannelName; +// }; hunk ./source/Parser.H 47 - String name; hunk ./source/Parser.H 55 - userFunction(String na, - void (*f)(ServerConnection *, Person *, - String, String), - int m, bool n + userFunction(void (*f)(ServerConnection *, Person *, + String, String) = 0, + int m = 0 , bool n = false hunk ./source/Parser.H 62 - : name(na), function(f), minLevel(m), needsChannelName(n) + : function(f), minLevel(m), needsChannelName(n) hunk ./source/Parser.H 68 -// scm_protect_object(scm_f); + if (scmFunc) + scm_gc_protect_object(scmFunc); hunk ./source/Parser.H 74 -// ~userFunction() -// { scm_unprotect_object(scmFunc); }; + ~userFunction() + { + if (scmFunc) + scm_gc_unprotect_object(scmFunc); + } hunk ./source/Parser.H 128 + hunk ./source/ScriptCommands.C 28 +#include "ServerQueue.H" hunk ./source/ScriptCommands.C 427 - - - hunk ./source/ScriptCommands.C 503 - std::list::iterator it = - Interp::bot->userFunctions.begin(); - for ( ; it != Interp::bot->userFunctions.end(); ++it) { - if ((*it)->name == commandName) - return SCM_BOOL_F; - } + if (Interp::bot->userFunctions[commandName]) + return SCM_BOOL_F; hunk ./source/ScriptCommands.C 509 - bool needsChannel = (bool)gh_scm2bool(scm_needsChannel); + bool needsChannel = gh_scm2bool(scm_needsChannel); hunk ./source/ScriptCommands.C 533 - Interp::bot->userFunctions.push_back(new userFunction(commandName, -(void (*)(ServerConnection *, Person *, String, String))0, minLevel, needsChannel, args, scm_function)); - + Interp::bot->userFunctions[commandName] = + new userFunction(0, minLevel, needsChannel, args, scm_function); + hunk ./source/ScriptCommands.C 548 - std::list::iterator it = - Interp::bot->userFunctions.begin(); - for ( ; it != Interp::bot->userFunctions.end(); ++it) { - if ((*it)->name == commandName) - break; - } - - if (it == Interp::bot->userFunctions.end()) + if (!Interp::bot->userFunctions[commandName]) hunk ./source/ScriptCommands.C 552 - Interp::bot->userFunctions.erase(it); - delete (*it); + Interp::bot->userFunctions.erase(commandName); hunk ./source/ScriptCommands.C 581 - return gh_bool2scm(Interp::bot->botInterp->DelTimer(timer)); + return SCM_BOOL (Interp::bot->botInterp->DelTimer(timer)); +} + +// Message sending +// FIXME: write these + +#define IQUEUE Interp::bot->serverConnection->queue + +SCM +ScriptCommands::sendCTCP(SCM to, SCM command , SCM message) +{ + VERIFY_STRING(to); + VERIFY_STRING(command); + VERIFY_STRING(message); + + IQUEUE->sendCTCP (Utils::scm2String (to), Utils::scm2String (command), + Utils::scm2String (message)); + return SCM_UNSPECIFIED; hunk ./source/ScriptCommands.C 601 + hunk ./source/ScriptCommands.H 80 + + // Message sending + static SCM sendCTCP(SCM, SCM, SCM); + /* + SCM sendCTCPReply(SCM, SCM, SCM); + SCM sendChannelMode(SCM); + SCM sendChannelMode(SCM, SCM, SCM); + SCM sendInvite(SCM, SCM); + SCM sendJoin(SCM, SCM); + SCM sendKick(SCM, SCM, SCM); + SCM sendNick(SCM); + SCM sendNotice(SCM, SCM); + SCM sendPart(SCM); + SCM sendPass(SCM); + SCM sendPing(SCM); + SCM sendPong(SCM); + SCM sendPrivmsg(SCM, SCM); + SCM sendQuit(SCM); + SCM sendTopic(SCM, SCM); + SCM sendUser(SCM, SCM); + SCM sendUserMode(SCM, SCM); + SCM sendUserhost(SCM); + SCM sendWho(SCM); + SCM sendWhois(SCM); + */ + hunk ./source/UserCommands.C 24 +#include hunk ./source/UserCommands.C 253 - std::list::iterator it; hunk ./source/UserCommands.C 260 - for (it = cnx->bot->userFunctions.begin(); it != - cnx->bot->userFunctions.end(); ++it) - if (newF == (*it)->name) { + if (cnx->bot->userFunctions[newF]) { hunk ./source/UserCommands.C 263 - } + } hunk ./source/UserCommands.C 266 - bool found = false; - userFunction *u; - for (it = cnx->bot->userFunctions.begin(); it != - cnx->bot->userFunctions.end(); ++it) - if (oldF == (*it)->name) { - found = true; - u = *it; - break; + if (!cnx->bot->userFunctions[oldF]) + { + from->sendNotice(String("\002I don't know the\002 ") + oldF + + " \002command."); + return; hunk ./source/UserCommands.C 272 - if (!found) { - from->sendNotice(String("\002I don't know the\002 ") + oldF + - " \002command."); - return; - } hunk ./source/UserCommands.C 274 - cnx->bot->userFunctions.push_back(new - userFunction((char *)(const char - *)newF, - u->function, - u->minLevel, - u->needsChannelName)); + cnx->bot->userFunctions[newF] = + new userFunction (*cnx->bot->userFunctions[oldF]); hunk ./source/UserCommands.C 581 - std::list::iterator it; + std::map >::iterator it; hunk ./source/UserCommands.C 583 - if ((*it)->minLevel <= level) { - result = result + (*it)->name + " "; - length += strlen((*it)->name) + 1; + if ((*it).second->minLevel <= level) { + result = result + (*it).first + " "; + length += (*it).first.length() + 1; }