1
0
mirror of https://github.com/anope/anope.git synced 2026-07-05 08:53:12 +02:00

Allow /cs up and /cs down to take an optional nick arg

This commit is contained in:
Adam
2013-02-24 20:11:16 -05:00
parent 501503b7a5
commit 5d4db2b854
+75 -25
View File
@@ -16,34 +16,58 @@
class CommandCSUp : public Command
{
public:
CommandCSUp(Module *creator) : Command(creator, "chanserv/up", 0, 3)
CommandCSUp(Module *creator) : Command(creator, "chanserv/up", 0, 2)
{
this->SetDesc(_("Updates your status on a channel"));
this->SetSyntax(_("[\037channel\037]"));
this->RequireUser(true);
this->SetDesc(_("Updates a selected nicks status on a channel"));
this->SetSyntax(_("[\037channel\037 [\037nick\037]]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
User *u = source.GetUser();
if (params.empty())
for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
{
if (!source.GetUser())
return;
for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
{
Channel *c = (*it)->chan;
c->SetCorrectModes(u, true, false);
c->SetCorrectModes(source.GetUser(), true, false);
}
}
else
{
const Anope::string &channel = params[0];
Channel *c = Channel::Find(params[0]);
const Anope::string &nick = params.size() > 1 ? params[1] : source.GetNick();
Channel *c = Channel::Find(channel);
if (c == NULL)
{
source.Reply(CHAN_X_NOT_IN_USE, channel.c_str());
return;
}
else if (!c->ci)
{
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else
c->SetCorrectModes(u, true, false);
return;
}
User *u = User::Find(nick, true);
if (u == NULL)
{
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
return;
}
else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE"))
{
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
{
source.Reply(ACCESS_DENIED);
return;
}
}
c->SetCorrectModes(u, true, false);
}
}
@@ -52,7 +76,8 @@ class CommandCSUp : public Command
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Updates your status modes on a channel. If \037channel\037 is ommited\n"
source.Reply(_("Updates a selected nicks status modes on a channel. If \037nick\037 is\n"
"ommited then your status is updated. If \037channel\037 is ommited then\n"
"your channel status is updated on every channel you are in."));
return true;
}
@@ -72,34 +97,58 @@ class CommandCSDown : public Command
}
public:
CommandCSDown(Module *creator) : Command(creator, "chanserv/down", 0, 3)
CommandCSDown(Module *creator) : Command(creator, "chanserv/down", 0, 2)
{
this->SetDesc(_("Removes your status from a channel"));
this->SetSyntax(_("[\037channel\037]"));
this->RequireUser(true);
this->SetDesc(_("Removes a selected nicks status from a channel"));
this->SetSyntax(_("[\037channel\037 ]\037nick\037]]"));
}
void Execute(CommandSource &source, const std::vector<Anope::string> &params) anope_override
{
User *u = source.GetUser();
if (params.empty())
for (User::ChanUserList::iterator it = u->chans.begin(); it != u->chans.end(); ++it)
{
if (!source.GetUser())
return;
for (User::ChanUserList::iterator it = source.GetUser()->chans.begin(); it != source.GetUser()->chans.end(); ++it)
{
Channel *c = (*it)->chan;
RemoveAll(u, c);
RemoveAll(source.GetUser(), c);
}
}
else
{
const Anope::string &channel = params[0];
Channel *c = Channel::Find(params[0]);
const Anope::string &nick = params.size() > 1 ? params[1] : source.GetNick();
Channel *c = Channel::Find(channel);
if (c == NULL)
{
source.Reply(CHAN_X_NOT_IN_USE, channel.c_str());
return;
}
else if (!c->ci)
{
source.Reply(CHAN_X_NOT_REGISTERED, channel.c_str());
else
RemoveAll(u, c);
return;
}
User *u = User::Find(nick, true);
if (u == NULL)
{
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
return;
}
else if (source.GetUser() && u != source.GetUser() && c->ci->HasExt("PEACE"))
{
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
{
source.Reply(ACCESS_DENIED);
return;
}
}
RemoveAll(u, c);
}
}
@@ -107,7 +156,8 @@ class CommandCSDown : public Command
{
this->SendSyntax(source);
source.Reply(" ");
source.Reply(_("Removes your status modes on a channel. If \037channel\037 is ommited\n"
source.Reply(_("Removes a selected nicks status modes on a channel. If \037nick\037 is\n"
"ommited then your status is removed. If \037channel\037 is ommited then\n"
"your channel status is removed on every channel you are in."));
return true;
}