]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
More conversion, and a note to client coders.
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 Jul 2008 19:58:28 +0000 (19:58 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 13 Jul 2008 19:58:28 +0000 (19:58 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10011 e03df62e-2008-0410-955e-edbf42e46eb7

include/numerics.h
src/command_parse.cpp
src/configreader.cpp

index 2679d7413b6d7541dc250570e135b6b277959ef5..23bac8abbcec8adfd1a2745c4b7cb42f0dd06474 100644 (file)
@@ -59,16 +59,42 @@ enum Numerics
         */
        ERR_NOSUCHNICK                                  =       401,
        ERR_TOOMANYCHANNELS                             =       405,
+       ERR_UNKNOWNCOMMAND                              =       421,
        ERR_NOMOTD                                              =       422,
        ERR_NORULES                                             =       434, // unrealircd
        ERR_USERNOTINCHANNEL                    =       441,
+       ERR_NOTREGISTERED                               =       451,
+       ERR_NEEDMOREPARAMS                              =       461,
+
+       /*
+        * A quick side-rant about the next group of numerics..
+        * There are clients out there that like to assume that just because they don't recieve a numeric
+        * they know, that they have joined the channel.
+        *
+        * If IRC was at all properly standardised, this may even be a semi-acceptable assumption to make,
+        * but that's not the case as we all know, so IT IS NOT ACCEPTABLE. Especially for Insp users, where
+        * differing modules MAY potentially choose to block joins and send NOTICEs or other text to the user
+        * instead!
+        *
+        * tl;dr version:
+        *   DON'T MAKE YOUR CLIENT ASSUME YOU JOINED UNLESS YOU RECIEVE A JOIN WITH YOUR DAMN NICK ON IT.
+        * Thanks.
+        *
+        *  -- A message from the IRC group for coder sanity, and w00t
+        */
        ERR_BADCHANNELKEY                               =       475,
        ERR_INVITEONLYCHAN                              =       473,
        ERR_CHANNELISFULL                               =       471,
        ERR_BANNEDFROMCHAN                              =       474,
+
        ERR_NOPRIVILEGES                                =       481, // rfc, beware though, we use this for other things opers may not do also
        ERR_CHANOPRIVSNEEDED                    =       482, // rfc, beware though, we use this for other things like trying to kick a uline
 
        ERR_UNKNOWNSNOMASK                              =       501, // not rfc. unrealircd?
-       ERR_USERSDONTMATCH                              =       502
+       ERR_USERSDONTMATCH                              =       502,
+
+       ERR_CANTUNLOADMODULE                    =       972, // insp-specific
+       RPL_UNLOADEDMODULE                              =       973, // insp-specific
+       ERR_CANTLOADMODULE                              =       974, // insp-specific
+       RPL_LOADEDMODULE                                =       975 // insp-specific
 };
index 5b8b5b7f95e2992161916c80348d8394e198a914..00e5402faa39f1edef011fa2b029d20ff4abdf32 100644 (file)
@@ -291,7 +291,7 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        {
                if (user->registered == REG_ALL)
                {
-                       user->WriteNumeric(421, "%s %s :Unknown command",user->nick.c_str(),command.c_str());
+                       user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s %s :Unknown command",user->nick.c_str(),command.c_str());
                }
                ServerInstance->stats->statsUnknown++;
                return true;
@@ -315,33 +315,33 @@ bool CommandParser::ProcessCommand(User *user, std::string &cmd)
        {
                if (!user->IsModeSet(cm->second->flags_needed))
                {
-                       user->WriteNumeric(481, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str());
+                       user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - You do not have the required operator privileges",user->nick.c_str());
                        return do_more;
                }
                if (!user->HasPermission(command))
                {
-                       user->WriteNumeric(481, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick.c_str(),user->oper.c_str(),command.c_str());
+                       user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper type %s does not have access to command %s",user->nick.c_str(),user->oper.c_str(),command.c_str());
                        return do_more;
                }
        }
        if ((user->registered == REG_ALL) && (!IS_OPER(user)) && (cm->second->IsDisabled()))
        {
                /* command is disabled! */
-               user->WriteNumeric(421, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str());
+               user->WriteNumeric(ERR_UNKNOWNCOMMAND, "%s %s :This command has been disabled.",user->nick.c_str(),command.c_str());
                ServerInstance->SNO->WriteToSnoMask('d', "%s denied for %s (%s@%s)",
                                command.c_str(), user->nick.c_str(), user->ident.c_str(), user->host.c_str());
                return do_more;
        }
        if (command_p.size() < cm->second->min_params)
        {
-               user->WriteNumeric(461, "%s %s :Not enough parameters.", user->nick.c_str(), command.c_str());
+               user->WriteNumeric(ERR_NEEDMOREPARAMS, "%s %s :Not enough parameters.", user->nick.c_str(), command.c_str());
                if ((ServerInstance->Config->SyntaxHints) && (user->registered == REG_ALL) && (cm->second->syntax.length()))
                        user->WriteNumeric(304, "%s :SYNTAX %s %s", user->nick.c_str(), cm->second->command.c_str(), cm->second->syntax.c_str());
                return do_more;
        }
        if ((user->registered != REG_ALL) && (!cm->second->WorksBeforeReg()))
        {
-               user->WriteNumeric(451, "%s :You have not registered",command.c_str());
+               user->WriteNumeric(ERR_NOTREGISTERED, "%s :You have not registered",command.c_str());
                return do_more;
        }
        else
index 8f6c93b1bf8e98baca123e7baaba2c54db5e90ba..561b5d8de1b2a93ee395575d2a1f1bb5a6459089 100644 (file)
@@ -128,7 +128,7 @@ void ServerConfig::Update005()
 void ServerConfig::Send005(User* user)
 {
        for (std::vector<std::string>::iterator line = ServerInstance->Config->isupport.begin(); line != ServerInstance->Config->isupport.end(); line++)
-               user->WriteNumeric(005, "%s %s", user->nick.c_str(), line->c_str());
+               user->WriteNumeric(RPL_ISUPPORT, "%s %s", user->nick.c_str(), line->c_str());
 }
 
 bool ServerConfig::CheckOnce(const char* tag, ConfigDataHash &newconf)
@@ -1268,14 +1268,14 @@ void ServerConfig::Read(bool bail, User* user)
                                        ServerInstance->SNO->WriteToSnoMask('A', "*** REHASH UNLOADED MODULE: %s",removing->c_str());
 
                                        if (user)
-                                               user->WriteNumeric(973, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str());
+                                               user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str());
 
                                        rem++;
                                }
                                else
                                {
                                        if (user)
-                                               user->WriteNumeric(972, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str());
+                                               user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str());
                                }
                        }
                }
@@ -1289,14 +1289,14 @@ void ServerConfig::Read(bool bail, User* user)
                                        ServerInstance->SNO->WriteToSnoMask('A', "*** REHASH LOADED MODULE: %s",adding->c_str());
 
                                        if (user)
-                                               user->WriteNumeric(975, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str());
+                                               user->WriteNumeric(RPL_LOADEDMODULE, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str());
 
                                        add++;
                                }
                                else
                                {
                                        if (user)
-                                               user->WriteNumeric(974, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
+                                               user->WriteNumeric(RPL_CANTLOADMODULE, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
                                }
                        }
                }