Skip to content

Commit

Permalink
cs_akick: don't show channel doesn't exist message in enforce from ad…
Browse files Browse the repository at this point in the history
…ding akicks
  • Loading branch information
Adam- committed Mar 28, 2017
1 parent 274658f commit fb3ec7a
Showing 1 changed file with 27 additions and 15 deletions.
42 changes: 27 additions & 15 deletions modules/commands/cs_akick.cpp
Expand Up @@ -13,6 +13,31 @@

class CommandCSAKick : public Command
{
void Enforce(CommandSource &source, ChannelInfo *ci)
{
Channel *c = ci->c;
int count = 0;

if (!c)
{
return;
}

for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
ChanUserContainer *uc = it->second;
++it;

if (c->CheckKick(uc->user))
++count;
}

bool override = !source.AccessFor(ci).HasPriv("AKICK");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users";

source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count);
}

void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params)
{
Anope::string mask = params[2];
Expand Down Expand Up @@ -164,7 +189,7 @@ class CommandCSAKick : public Command

source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str());

this->DoEnforce(source, ci);
this->Enforce(source, ci);
}

void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> &params)
Expand Down Expand Up @@ -384,27 +409,14 @@ class CommandCSAKick : public Command
void DoEnforce(CommandSource &source, ChannelInfo *ci)
{
Channel *c = ci->c;
int count = 0;

if (!c)
{
source.Reply(CHAN_X_NOT_IN_USE, ci->name.c_str());
return;
}

for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
{
ChanUserContainer *uc = it->second;
++it;

if (c->CheckKick(uc->user))
++count;
}

bool override = !source.AccessFor(ci).HasPriv("AKICK");
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users";

source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count);
this->Enforce(source, ci);
}

void DoClear(CommandSource &source, ChannelInfo *ci)
Expand Down

0 comments on commit fb3ec7a

Please sign in to comment.