summaryrefslogtreecommitdiff
path: root/src/modules/m_chghost.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_chghost.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_chghost.cpp')
-rw-r--r--src/modules/m_chghost.cpp49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/modules/m_chghost.cpp b/src/modules/m_chghost.cpp
index 6a5845e72..be8154013 100644
--- a/src/modules/m_chghost.cpp
+++ b/src/modules/m_chghost.cpp
@@ -25,40 +25,53 @@ using namespace std;
/* $ModDesc: Provides support for the CHGHOST command */
Server *Srv;
-
-void handle_chghost(char **parameters, int pcnt, userrec *user)
+
+
+class cmd_chghost : public command_t
{
- for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+ public:
+ cmd_chghost () : command_t("CHGHOST",'o',2)
+ {
+ this->source = "m_chghost.so";
+ }
+
+ void Handle(char **parameters, int pcnt, userrec *user)
{
- if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
+ for (unsigned int x = 0; x < strlen(parameters[1]); x++)
{
- if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
+ if (((tolower(parameters[1][x]) < 'a') || (tolower(parameters[1][x]) > 'z')) && (parameters[1][x] != '.'))
{
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
- return;
+ if (((parameters[1][x] < '0') || (parameters[1][x]> '9')) && (parameters[1][x] != '-'))
+ {
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
+ return;
+ }
}
- }
- } userrec* dest = Srv->FindNick(std::string(parameters[0]));
- if (dest)
- {
- Srv->ChangeHost(dest,parameters[1]);
- if (!Srv->IsUlined(user->server))
+ }
+ userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ if (dest)
{
- // fix by brain - ulines set hosts silently
- Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+ Srv->ChangeHost(dest,parameters[1]);
+ if (!Srv->IsUlined(user->server))
+ {
+ // fix by brain - ulines set hosts silently
+ Srv->SendOpers(std::string(user->nick)+" used CHGHOST to make the displayed host of "+std::string(dest->nick)+" become "+std::string(parameters[1]));
+ }
}
}
-}
+};
class ModuleChgHost : public Module
{
+ cmd_chghost* mycommand;
public:
ModuleChgHost(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("CHGHOST",handle_chghost,'o',2,"m_chghost.so");
+ mycommand = new cmd_chghost();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleChgHost()
@@ -67,7 +80,7 @@ class ModuleChgHost : public Module
virtual Version GetVersion()
{
- return Version(1,0,0,1,VF_VENDOR);
+ return Version(1,2,0,1,VF_VENDOR);
}
};