summaryrefslogtreecommitdiff
path: root/src/modules/m_sapart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/m_sapart.cpp')
-rw-r--r--src/modules/m_sapart.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp
index 21e2f7fbe..026a3bd7d 100644
--- a/src/modules/m_sapart.cpp
+++ b/src/modules/m_sapart.cpp
@@ -25,35 +25,46 @@ using namespace std;
/* $ModDesc: Provides support for unreal-style SAPART command */
Server *Srv;
-
-void handle_sapart(char **parameters, int pcnt, userrec *user)
+
+class cmd_sapart : public command_t
{
- userrec* dest = Srv->FindNick(std::string(parameters[0]));
- if (dest)
+ public:
+ cmd_sapart () : command_t("SAPART", 'o', 2)
+ {
+ this->source = "m_sapart.so";
+ }
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+ userrec* dest = Srv->FindNick(std::string(parameters[0]));
+ if (dest)
{
- if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ','))
- {
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
- return;
- }
- }
+ for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+ {
+ if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ','))
+ {
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name");
+ return;
+ }
+ }
- Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
- Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
+ Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]);
+ Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick));
+ }
}
-}
+};
class ModuleSapart : public Module
{
+ cmd_sapart* mycommand;
public:
ModuleSapart(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("SAPART",handle_sapart,'o',2,"m_sapart.so");
+ mycommand = new cmd_sapart();
+ Srv->AddCommand(mycommand);
}
virtual ~ModuleSapart()