-// Sanick and +g support module by C.J.Edwards
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
#include <stdio.h>
#include <string>
/* $ModDesc: Provides support for SANICK command */
-Server *Srv;
-
-void handle_sanick(char **parameters, int pcnt, userrec *user)
+static Server *Srv;
+
+class cmd_sanick : public command_t
{
- userrec* source = Srv->FindNick(std::string(parameters[0]));
- if (source)
+ public:
+ cmd_sanick () : command_t("SANICK", 'o', 2)
+ {
+ this->source = "m_sanick.so";
+ }
+
+ void Handle (const char** parameters, int pcnt, userrec *user)
{
- if (Srv->IsNick(std::string(parameters[1])))
+ userrec* source = Srv->FindNick(std::string(parameters[0]));
+ if (source)
{
- // FIX by brain: Cant use source->nick here because if it traverses a server link then
- // source->nick becomes invalid as the object data moves in memory.
- Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
- Srv->ChangeUserNick(source,std::string(parameters[1]));
+ if (Srv->IsUlined(source->server))
+ {
+ WriteServ(user->fd,"990 %s :Cannot use an SA command on a u-lined client",user->nick);
+ return;
+ }
+ if (Srv->IsNick(std::string(parameters[1])))
+ {
+ // FIX by brain: Cant use source->nick here because if it traverses a server link then
+ // source->nick becomes invalid as the object data moves in memory.
+ Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]);
+ Srv->ChangeUserNick(source,std::string(parameters[1]));
+ }
}
}
-}
+};
class ModuleSanick : public Module
{
+ cmd_sanick* mycommand;
public:
- ModuleSanick()
+ ModuleSanick(Server* Me)
+ : Module::Module(Me)
{
- Srv = new Server;
- Srv->AddCommand("SANICK",handle_sanick,'o',2);
+ Srv = Me;
+ mycommand = new cmd_sanick();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSanick()
{
- delete Srv;
}
virtual Version GetVersion()
{
- return Version(1,0,0,1);
+ return Version(1,0,0,1,VF_VENDOR);
}
};
{
}
- virtual Module * CreateModule()
+ virtual Module * CreateModule(Server* Me)
{
- return new ModuleSanick;
+ return new ModuleSanick(Me);
}
};