summaryrefslogtreecommitdiff
path: root/src/modules/m_nicklock.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:10:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:10:38 +0000
commit293df6a8b55e89c127e60e92711ef0ef1027bff8 (patch)
treeda33b32cfdd5b6e93cabaf288316671af9a51297 /src/modules/m_nicklock.cpp
parent0d6f3c83f101e3cb1f6cd6768cc4d17de24db489 (diff)
Split all commands into seperate files and redid command system to take classes, not function pointers (function pointers suck ass)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2534 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_nicklock.cpp')
-rw-r--r--src/modules/m_nicklock.cpp92
1 files changed, 57 insertions, 35 deletions
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp
index efdfcca4d..37e9d49bd 100644
--- a/src/modules/m_nicklock.cpp
+++ b/src/modules/m_nicklock.cpp
@@ -27,64 +27,86 @@ using namespace std;
/* $ModDesc: Provides the NICKLOCK command, allows an oper to chage a users nick and lock them to it until they quit */
Server *Srv;
-
-void handle_nicklock(char **parameters, int pcnt, userrec *user)
+
+class cmd_nicklock : public command_t
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
- irc::string server;
- irc::string me;
+ public:
+ cmd_nicklock () : command_t("NICKLOCK", 'o', 2)
+ {
+ this->source = "m_nicklock.so";
+ }
- if (source)
+ void Handle(char **parameters, int pcnt, userrec *user)
{
- if (source->GetExt("nick_locked"))
- {
- WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
- return;
- }
- if (Srv->IsNick(std::string(parameters[1])))
- {
- server = user->server;
- me = Srv->GetServerName().c_str();
+ userrec* source = Srv->FindNick(std::string(parameters[0]));
+ irc::string server;
+ irc::string me;
- if (server == me)
+ if (source)
+ {
+ if (source->GetExt("nick_locked"))
{
- // give them a lock flag
- Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
- Srv->ChangeUserNick(source,std::string(parameters[1]));
- // only attempt to set their lockflag after we know the change succeeded
- source = Srv->FindNick(std::string(parameters[1]));
- if (source)
- source->Extend("nick_locked", "ON");
+ WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick);
+ return;
}
- else
+ if (Srv->IsNick(std::string(parameters[1])))
{
- WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
+ server = user->server;
+ me = Srv->GetServerName().c_str();
+
+ if (server == me)
+ {
+ // give them a lock flag
+ Srv->SendOpers(std::string(user->nick)+" used NICKLOCK to change and hold "+std::string(parameters[0])+" to "+parameters[1]);
+ Srv->ChangeUserNick(source,std::string(parameters[1]));
+ // only attempt to set their lockflag after we know the change succeeded
+ source = Srv->FindNick(std::string(parameters[1]));
+ if (source)
+ source->Extend("nick_locked", "ON");
+ }
+ else
+ {
+ WriteServ(user->fd,"947 %s %s :Can't lock the nickname of a non-local user",user->nick,source->nick);
+ }
}
}
}
-}
+};
-void handle_nickunlock(char **parameters, int pcnt, userrec *user)
+class cmd_nickunlock : public command_t
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
- if (source)
+ public:
+ cmd_nickunlock () : command_t("NICKUNLOCK", 'o', 1)
{
- source->Shrink("nick_locked");
- WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
- Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+ this->source = "m_nickunlock.so";
}
-}
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ userrec* source = Srv->FindNick(std::string(parameters[0]));
+ if (source)
+ {
+ source->Shrink("nick_locked");
+ WriteServ(user->fd,"945 %s %s :Nickname now unlocked.",user->nick,source->nick);
+ Srv->SendOpers(std::string(user->nick)+" used NICKUNLOCK on "+std::string(parameters[0]));
+ }
+ }
+};
class ModuleNickLock : public Module
{
+ cmd_nicklock* cmd1;
+ cmd_nickunlock* cmd2;
public:
ModuleNickLock(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("NICKLOCK",handle_nicklock,'o',2,"m_nicklock.so");
- Srv->AddCommand("NICKUNLOCK",handle_nickunlock,'o',1,"m_nicklock.so");
+ cmd1 = new cmd_nicklock();
+ cmd2 = new cmd_nickunlock();
+ Srv->AddCommand(cmd1);
+ Srv->AddCommand(cmd2);
}
virtual ~ModuleNickLock()