summaryrefslogtreecommitdiff
path: root/src/modules/m_remove.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:23:50 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2005-12-16 18:23:50 +0000
commitab9d8fd1af3ebf028506ec543f74fd13471742dd (patch)
treed95fd9303718109daa304bd602dc69af1ebb1b05 /src/modules/m_remove.cpp
parent293df6a8b55e89c127e60e92711ef0ef1027bff8 (diff)
Porting to new command system
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2535 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_remove.cpp')
-rw-r--r--src/modules/m_remove.cpp126
1 files changed, 68 insertions, 58 deletions
diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp
index a72b41da0..7962d6a1d 100644
--- a/src/modules/m_remove.cpp
+++ b/src/modules/m_remove.cpp
@@ -36,88 +36,98 @@ int chartolevel(std::string privs)
else
return 1;
}
-
-void handle_remove(char **parameters, int pcnt, userrec *user)
+
+class cmd_remove : public command_t
{
- /* Look up the user we're meant to be removing from the channel */
- userrec* target = Srv->FindNick(std::string(parameters[0]));
- /* And the channel we're meant to be removing them from */
- chanrec* channel = Srv->FindChannel(std::string(parameters[1]));
- /* And see if the person calling the command has access to use it on the channel */
- std::string privs = Srv->ChanMode(user, channel);
- /* Check what privs the person being removed has */
- std::string targetprivs = Srv->ChanMode(target, channel);
- int tlevel;
- int ulevel;
- int n = 2;
- std::string result;
-
- /* This turns all the parameters after the first two into a single string, so the part reason can be multi-word */
- while (n < pcnt)
+ public:
+ cmd_remove () : command_t("REMOVE", 0, 2)
{
- result=result + std::string(" ") + std::string(parameters[n]);
- n++;
+ this->source = "m_remove.so";
}
-
- /* If the target nick exists... */
- if (target && channel)
+
+ void Handle (char **parameters, int pcnt, userrec *user)
{
- for (unsigned int x = 0; x < strlen(parameters[1]); x++)
+ /* Look up the user we're meant to be removing from the channel */
+ userrec* target = Srv->FindNick(std::string(parameters[0]));
+ /* And the channel we're meant to be removing them from */
+ chanrec* channel = Srv->FindChannel(std::string(parameters[1]));
+ /* And see if the person calling the command has access to use it on the channel */
+ std::string privs = Srv->ChanMode(user, channel);
+ /* Check what privs the person being removed has */
+ std::string targetprivs = Srv->ChanMode(target, channel);
+ int tlevel;
+ int ulevel;
+ int n = 2;
+ std::string result;
+
+ /* This turns all the parameters after the first two into a single string, so the part reason can be multi-word */
+ while (n < pcnt)
{
- 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;
- }
+ result=result + std::string(" ") + std::string(parameters[n]);
+ n++;
}
- /* This is adding support for the +q and +a channel modes, basically if they are enabled, and the remover has them set. */
- /* Then we change the @|%|+ to & if they are +a, or ~ if they are +q */
- if (user->GetExt("cm_protect_"+std::string(channel->name)))
- privs = std::string("&");
- if (user->GetExt("cm_founder_"+std::string(channel->name)))
- privs = std::string("~");
+ /* If the target nick exists... */
+ if (target && channel)
+ {
+ 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;
+ }
+ }
- /* Now it's the same idea, except for the target */
- if (target->GetExt("cm_protect_"+std::string(channel->name)))
- targetprivs = std::string("&");
- if (target->GetExt("cm_founder_"+std::string(channel->name)))
- targetprivs = std::string("~");
+ /* This is adding support for the +q and +a channel modes, basically if they are enabled, and the remover has them set. */
+ /* Then we change the @|%|+ to & if they are +a, or ~ if they are +q */
+ if (user->GetExt("cm_protect_"+std::string(channel->name)))
+ privs = std::string("&");
+ if (user->GetExt("cm_founder_"+std::string(channel->name)))
+ privs = std::string("~");
+
+ /* Now it's the same idea, except for the target */
+ if (target->GetExt("cm_protect_"+std::string(channel->name)))
+ targetprivs = std::string("&");
+ if (target->GetExt("cm_founder_"+std::string(channel->name)))
+ targetprivs = std::string("~");
+
+ tlevel = chartolevel(targetprivs);
+ ulevel = chartolevel(privs);
- tlevel = chartolevel(targetprivs);
- ulevel = chartolevel(privs);
-
- /* If the user calling the command is either an admin, owner, operator or a half-operator on the channel */
- if(ulevel > 1)
- {
- /* For now, we'll let everyone remove their level and below, eg ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) */
- if(ulevel >= tlevel)
+ /* If the user calling the command is either an admin, owner, operator or a half-operator on the channel */
+ if(ulevel > 1)
{
- Srv->PartUserFromChannel(target,std::string(parameters[1]), "Remove by "+std::string(user->nick)+":"+result);
- Srv->SendTo(NULL,user,"NOTICE "+std::string(channel->name)+" : "+std::string(user->nick)+" removed "+std::string(target->nick)+ " from the channel");
- Srv->SendTo(NULL,target,"NOTICE "+std::string(target->nick)+" :*** "+std::string(user->nick)+" removed you from "+std::string(channel->name)+" with the message:"+std::string(result));
+ /* For now, we'll let everyone remove their level and below, eg ops can remove ops, halfops, voices, and those with no mode (no moders actually are set to 1) */
+ if(ulevel >= tlevel)
+ {
+ Srv->PartUserFromChannel(target,std::string(parameters[1]), "Remove by "+std::string(user->nick)+":"+result);
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(channel->name)+" : "+std::string(user->nick)+" removed "+std::string(target->nick)+ " from the channel");
+ Srv->SendTo(NULL,target,"NOTICE "+std::string(target->nick)+" :*** "+std::string(user->nick)+" removed you from "+std::string(channel->name)+" with the message:"+std::string(result));
+ }
+ else
+ {
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** You do not have access to remove "+std::string(target->nick)+" from the "+std::string(channel->name));
+ }
}
else
{
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** You do not have access to remove "+std::string(target->nick)+" from the "+std::string(channel->name));
+ Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** You do not have access to use /remove on "+std::string(channel->name));
}
}
- else
- {
- Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** You do not have access to use /remove on "+std::string(channel->name));
- }
}
-}
-
+};
class ModuleRemove : public Module
{
+ cmd_remove* mycommand;
public:
ModuleRemove(Server* Me)
: Module::Module(Me)
{
Srv = Me;
- Srv->AddCommand("REMOVE", handle_remove, 0, 3, "m_remove.so");
+ mycommand = new cmd_remove();
+ Srv->AddCommand(mycommand);
}
virtual void On005Numeric(std::string &output)