summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:33:06 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:33:06 +0000
commit2e2d1fae4844088f7e0b9a71116e0eb3e149e4cc (patch)
tree544f6f31ec2c6f7714ebc4614a5623f6e6ec8a69
parentab9d8fd1af3ebf028506ec543f74fd13471742dd (diff)
Moved to new command system
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2536 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/m_saquit.cpp38
-rw-r--r--src/modules/m_sethost.cpp33
-rw-r--r--src/modules/m_setidle.cpp37
-rw-r--r--src/modules/m_setname.cpp29
4 files changed, 90 insertions, 47 deletions
diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp
index e864546e0..e1db742e0 100644
--- a/src/modules/m_saquit.cpp
+++ b/src/modules/m_saquit.cpp
@@ -35,33 +35,43 @@ using namespace std;
/* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */
Server *Srv;
-
-void handle_saquit(char **parameters, int pcnt, userrec *user)
+
+class cmd_saquit : public command_t
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
- if (dest)
+ public:
+ cmd_saquit () : command_t("SAQUIT",'o',2)
+ {
+ this->source = "m_saquit.so";
+ }
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- std::string line = "";
- for (int i = 1; i < pcnt - 1; i++)
+ userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ if (dest)
{
- line = line + std::string(parameters[i]) + " ";
+ std::string line = "";
+ for (int i = 1; i < pcnt - 1; i++)
+ {
+ line = line + std::string(parameters[i]) + " ";
+ }
+ line = line + std::string(parameters[pcnt-1]);
+
+ Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
+ Srv->QuitUser(dest, line);
}
- line = line + std::string(parameters[pcnt-1]);
-
- Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line);
- Srv->QuitUser(dest, line);
}
-}
-
+};
class ModuleSaquit : public Module
{
+ cmd_saquit* mycommand;
public:
ModuleSaquit(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("SAQUIT",handle_saquit,'o',2,"m_saquit.so");
+ mycommand = new cmd_saquit();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSaquit()
diff --git a/src/modules/m_sethost.cpp b/src/modules/m_sethost.cpp
index cdb01de4d..0894e8f24 100644
--- a/src/modules/m_sethost.cpp
+++ b/src/modules/m_sethost.cpp
@@ -26,33 +26,44 @@ using namespace std;
/* $ModDesc: Provides support for the SETHOST command */
Server *Srv;
-
-void handle_sethost(char **parameters, int pcnt, userrec *user)
+
+class cmd_sethost : public command_t
{
- for (unsigned int x = 0; x < strlen(parameters[0]); x++)
+ public:
+ cmd_sethost() : command_t("SETHOST",'o',1)
{
- if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.'))
+ this->source = "m_sethost.so";
+ }
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ for (unsigned int x = 0; x < strlen(parameters[0]); x++)
{
- if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-'))
+ if (((tolower(parameters[0][x]) < 'a') || (tolower(parameters[0][x]) > 'z')) && (parameters[0][x] != '.'))
{
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
- return;
+ if (((parameters[0][x] < '0') || (parameters[0][x]> '9')) && (parameters[0][x] != '-'))
+ {
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in hostname");
+ return;
+ }
}
}
+ Srv->ChangeHost(user,parameters[0]);
+ Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
}
- Srv->ChangeHost(user,parameters[0]);
- Srv->SendOpers(std::string(user->nick)+" used SETHOST to change their displayed host to "+std::string(parameters[0]));
-}
+};
class ModuleSetHost : public Module
{
+ cmd_sethost* mycommand;
public:
ModuleSetHost(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("SETHOST",handle_sethost,'o',1,"m_sethost.so");
+ mycommand = new cmd_sethost();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSetHost()
diff --git a/src/modules/m_setidle.cpp b/src/modules/m_setidle.cpp
index 3ec1719da..ffa84d479 100644
--- a/src/modules/m_setidle.cpp
+++ b/src/modules/m_setidle.cpp
@@ -26,31 +26,42 @@ using namespace std;
/* $ModDesc: Allows opers to set their idle time */
Server *Srv = NULL;
-
-void handle_setidle(char **parameters, int pcnt, userrec *user)
+
+class cmd_setidle : public command_t
{
- if (atoi(parameters[0]) < 1)
+ public:
+ cmd_setidle () : command_t("SETIDLE", 'o', 1)
{
- WriteServ(user->fd,"948 %s :Invalid idle time.",user->nick);
- return;
+ this->source = "m_setidle.so";
}
- user->idle_lastmsg = time(NULL) - atoi(parameters[0]);
- // minor tweak - we cant have signon time shorter than our idle time!
- if (user->signon > user->idle_lastmsg)
- user->signon = user->idle_lastmsg;
- Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
- WriteServ(user->fd,"944 %s :Idle time set.",user->nick);
-}
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ if (atoi(parameters[0]) < 1)
+ {
+ WriteServ(user->fd,"948 %s :Invalid idle time.",user->nick);
+ return;
+ }
+ user->idle_lastmsg = time(NULL) - atoi(parameters[0]);
+ // minor tweak - we cant have signon time shorter than our idle time!
+ if (user->signon > user->idle_lastmsg)
+ user->signon = user->idle_lastmsg;
+ Srv->SendOpers(std::string(user->nick)+" used SETIDLE to set their idle time to "+std::string(parameters[0])+" seconds");
+ WriteServ(user->fd,"944 %s :Idle time set.",user->nick);
+ }
+};
class ModuleSetIdle : public Module
{
+ cmd_setidle* mycommand;
public:
ModuleSetIdle(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("SETIDLE",handle_setidle,'o',1,"m_setidle.so");
+ mycommand = new cmd_setidle();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSetIdle()
diff --git a/src/modules/m_setname.cpp b/src/modules/m_setname.cpp
index 3b2d98aae..892d934c0 100644
--- a/src/modules/m_setname.cpp
+++ b/src/modules/m_setname.cpp
@@ -26,27 +26,38 @@ using namespace std;
/* $ModDesc: Provides support for the SETNAME command */
Server *Srv;
-
-void handle_setname(char **parameters, int pcnt, userrec *user)
+
+class cmd_setname : public command_t
{
- std::string line = "";
- for (int i = 0; i < pcnt-1; i++)
+ public:
+ cmd_setname () : command_t("SETNAME", 0, 1);
{
- line = line + std::string(parameters[i]);
+ this->source = "m_setname.so";
}
- line = line + std::string(parameters[pcnt-1]);
- Srv->ChangeGECOS(user,line);
-}
+
+ void Handle (char **parameters, int pcnt, userrec *user)
+ {
+ std::string line = "";
+ for (int i = 0; i < pcnt-1; i++)
+ {
+ line = line + std::string(parameters[i]);
+ }
+ line = line + std::string(parameters[pcnt-1]);
+ Srv->ChangeGECOS(user,line);
+ }
+};
class ModuleSetName : public Module
{
+ cmd_setname* mycommand;
public:
ModuleSetName(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("SETNAME",handle_setname,0,1,"m_setname.so");
+ mycommand = new cmd_setname();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSetName()