diff options
-rw-r--r-- | include/inspircd.h | 1 | ||||
-rw-r--r-- | include/numerics.h | 41 | ||||
-rw-r--r-- | src/channels.cpp | 18 |
3 files changed, 51 insertions, 9 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index dbbd8ba01..5e5ebce42 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -40,6 +40,7 @@ #include <climits> #include "inspircd_config.h" +#include "numerics.h" #include "uid.h" #include "users.h" #include "channels.h" diff --git a/include/numerics.h b/include/numerics.h new file mode 100644 index 000000000..6a587a5b3 --- /dev/null +++ b/include/numerics.h @@ -0,0 +1,41 @@ +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * InspIRCd: (C) 2002-2008 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * + * This program is free but copyrighted software; see + * the file COPYING for details. + * + * --------------------------------------------------- + */ + +/* + * This file is aimed providing a string that is easier to use than using the numeric + * directly. + * + * Thanks to Darom, jackmcbarn and Brain for suggesting and discussing this. + * + * Please note that the list may not be exhaustive, it'll be done when I have + * nothing better to do with my time. -- w00t (jul 13, 2008) + */ + +enum Numerics +{ + /* + * Reply range of numerics. + */ + RPL_TOPIC = 332, + RPL_TOPICTIME = 333, + + + /* + * Error range of numerics. + */ + ERR_TOOMANYCHANNELS = 405, + ERR_BADCHANNELKEY = 475, + ERR_INVITEONLYCHAN = 473, + ERR_CHANNELISFULL = 471, + ERR_BANNEDFROMCHAN = 474 +}; diff --git a/src/channels.cpp b/src/channels.cpp index f169efb87..c9e0209d9 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -229,7 +229,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= user->GetMaxChans()) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); + user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -239,7 +239,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= Instance->Config->OperMaxChans) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); + user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -247,7 +247,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (user->chans.size() >= Instance->Config->MaxChans) { - user->WriteNumeric(405, "%s %s :You are on too many channels",user->nick.c_str(), cn); + user->WriteNumeric(ERR_TOOMANYCHANNELS, "%s %s :You are on too many channels",user->nick.c_str(), cn); return NULL; } } @@ -310,7 +310,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if ((!key) || Ptr->key == key) { - user->WriteNumeric(475, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str()); + user->WriteNumeric(ERR_BADCHANNELKEY, "%s %s :Cannot join channel (Incorrect channel key)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } @@ -323,7 +323,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (!user->IsInvited(Ptr->name.c_str())) { - user->WriteNumeric(473, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str()); + user->WriteNumeric(ERR_INVITEONLYCHAN, "%s %s :Cannot join channel (Invite only)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } @@ -337,7 +337,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (Ptr->GetUserCounter() >= Ptr->limit) { - user->WriteNumeric(471, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str()); + user->WriteNumeric(ERR_CHANNELISFULL, "%s %s :Cannot join channel (Channel is full)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } @@ -346,7 +346,7 @@ Channel* Channel::JoinUser(InspIRCd* Instance, User *user, const char* cn, bool { if (Ptr->IsBanned(user)) { - user->WriteNumeric(474, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str()); + user->WriteNumeric(ERR_BANNEDFROMCHAN, "%s %s :Cannot join channel (You're banned)",user->nick.c_str(), Ptr->name.c_str()); return NULL; } } @@ -416,8 +416,8 @@ Channel* Channel::ForceChan(InspIRCd* Instance, Channel* Ptr, User* user, const { if (Ptr->topicset) { - user->WriteNumeric(332, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str()); - user->WriteNumeric(333, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset); + user->WriteNumeric(RPL_TOPIC, "%s %s :%s", user->nick.c_str(), Ptr->name.c_str(), Ptr->topic.c_str()); + user->WriteNumeric(RPL_TOPICTIME, "%s %s %s %lu", user->nick.c_str(), Ptr->name.c_str(), Ptr->setby.c_str(), (unsigned long)Ptr->topicset); } Ptr->UserList(user); } |