mirror of
https://github.com/anope/anope.git
synced 2026-07-05 20:53:13 +02:00
Added missing override capabilities and log calls to some ChanServ commands
This commit is contained in:
@@ -35,18 +35,14 @@ public:
|
||||
|
||||
User *u = source.GetUser();
|
||||
ChannelInfo *ci = ChannelInfo::Find(params[0]);
|
||||
bool override = false;
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelInfo *target_ci = ChannelInfo::Find(target);
|
||||
if (!target_ci)
|
||||
{
|
||||
@@ -55,8 +51,13 @@ public:
|
||||
}
|
||||
if (!source.IsFounder(ci) || !source.IsFounder(target_ci))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
if (!source.HasPriv("chanserv/administration"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else
|
||||
override = true;
|
||||
}
|
||||
|
||||
if (what.equals_ci("ALL"))
|
||||
@@ -151,7 +152,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Log(LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
|
||||
@@ -216,15 +216,15 @@ public:
|
||||
{
|
||||
if (log->extra == extra)
|
||||
{
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << (!log->command_name.empty() ? log->command_name : log->service_name) << " with method " << method << (extra == "" ? "" : " ") << extra;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to remove logging for " << command << " with method " << method << (extra == "" ? "" : " ") << extra;
|
||||
source.Reply(_("Logging for command %s on %s with log method %s%s%s has been removed."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
delete log;
|
||||
}
|
||||
else
|
||||
{
|
||||
log->extra = extra;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << (!log->command_name.empty() ? log->command_name : log->service_name) << " to method " << method << (extra == "" ? "" : " ") << extra;
|
||||
source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s has been removed."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to change logging for " << command << " to method " << method << (extra == "" ? "" : " ") << extra;
|
||||
source.Reply(_("Logging changed for command %s on %s, now using log method %s%s%s."), !log->command_name.empty() ? log->command_name.c_str() : log->service_name.c_str(), !log->command_service.empty() ? log->command_service.c_str() : "any service", method.c_str(), extra.empty() ? "" : " ", extra.empty() ? "" : extra.c_str());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -295,7 +295,7 @@ class CommandCSMode : public Command
|
||||
sep.GetToken(modes);
|
||||
|
||||
Anope::string pos = "+", neg = "-", pos_params, neg_params;
|
||||
|
||||
|
||||
int adding = -1;
|
||||
for (size_t i = 0; i < modes.length(); ++i)
|
||||
{
|
||||
@@ -761,25 +761,35 @@ class CommandCSModes : public Command
|
||||
AccessGroup u_access = source.AccessFor(ci), targ_access = ci->AccessFor(targ);
|
||||
const std::pair<bool, Anope::string> &m = modes[source.command];
|
||||
|
||||
bool can_override = source.HasPriv("chanserv/administration");
|
||||
bool override = false;
|
||||
|
||||
if (m.second.empty())
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.HasPriv("chanserv/administration"))
|
||||
if (u == targ ? !u_access.HasPriv(m.second + "ME") : !u_access.HasPriv(m.second))
|
||||
{
|
||||
if (u == targ ? !u_access.HasPriv(m.second + "ME") : !u_access.HasPriv(m.second))
|
||||
if (!can_override)
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else
|
||||
override = true;
|
||||
}
|
||||
|
||||
if (!m.first && u != targ && (targ->IsProtected() || (ci->HasExt("PEACE") && targ_access >= u_access)))
|
||||
if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->HasExt("PEACE") && targ_access >= u_access)))
|
||||
{
|
||||
if (!can_override)
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else
|
||||
override = true;
|
||||
}
|
||||
|
||||
if (!ci->c->FindUser(targ))
|
||||
@@ -793,7 +803,7 @@ class CommandCSModes : public Command
|
||||
else
|
||||
ci->c->RemoveMode(NULL, m.second, targ->GetUID());
|
||||
|
||||
Log(LOG_COMMAND, source, this, ci) << "on " << targ->nick;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "on " << targ->nick;
|
||||
}
|
||||
|
||||
const Anope::string GetDesc(CommandSource &source) const anope_override
|
||||
|
||||
@@ -28,11 +28,12 @@ class CommandCSSync : public Command
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
else if (ci->c == NULL)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
|
||||
else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE"))
|
||||
else if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && !source.HasPriv("chanserv/administration"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
Log(LOG_COMMAND, source, this, ci);
|
||||
bool override = !source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/kick");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
|
||||
|
||||
for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
|
||||
ci->c->SetCorrectModes(it->second->user, true);
|
||||
|
||||
@@ -42,6 +42,7 @@ class CommandCSUnban : public Command
|
||||
++count;
|
||||
}
|
||||
|
||||
Log(LOG_COMMAND, source, this, NULL) << "on all channels";
|
||||
source.Reply(_("You have been unbanned from %d channels."), count);
|
||||
|
||||
return;
|
||||
@@ -60,7 +61,7 @@ class CommandCSUnban : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.AccessFor(ci).HasPriv("UNBAN"))
|
||||
if (!source.AccessFor(ci).HasPriv("UNBAN") && !source.HasPriv("chanserv/kick"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -76,7 +77,8 @@ class CommandCSUnban : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
Log(LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
|
||||
bool override = !source.AccessFor(ci).HasPriv("UNBAN") && source.HasPriv("chanserv/kick");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to unban " << u2->nick;
|
||||
|
||||
ci->c->Unban(u2, source.GetUser() == u2);
|
||||
if (u2 == source.GetUser())
|
||||
|
||||
@@ -31,6 +31,7 @@ class CommandCSUp : public Command
|
||||
Channel *c = it->second->chan;
|
||||
c->SetCorrectModes(source.GetUser(), true);
|
||||
}
|
||||
Log(LOG_COMMAND, source, this, NULL) << "on all channels to update their status modes";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -51,6 +52,8 @@ class CommandCSUp : public Command
|
||||
}
|
||||
|
||||
User *u = User::Find(nick, true);
|
||||
bool override = false;
|
||||
|
||||
if (u == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
|
||||
@@ -65,11 +68,17 @@ class CommandCSUp : public Command
|
||||
{
|
||||
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
if (source.HasPriv("chanserv/administration"))
|
||||
override = true;
|
||||
else
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to update the status modes of " << u->nick;
|
||||
c->SetCorrectModes(u, true);
|
||||
}
|
||||
|
||||
@@ -114,6 +123,7 @@ class CommandCSDown : public Command
|
||||
Channel *c = it->second->chan;
|
||||
RemoveAll(source.GetUser(), c);
|
||||
}
|
||||
Log(LOG_COMMAND, source, this, NULL) << "on all channels to remove their status modes";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -134,6 +144,8 @@ class CommandCSDown : public Command
|
||||
}
|
||||
|
||||
User *u = User::Find(nick, true);
|
||||
bool override = false;
|
||||
|
||||
if (u == NULL)
|
||||
{
|
||||
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
|
||||
@@ -148,11 +160,17 @@ class CommandCSDown : public Command
|
||||
{
|
||||
if (c->ci->AccessFor(u) > c->ci->AccessFor(source.GetUser()))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
if (source.HasPriv("chanserv/administration"))
|
||||
override = true;
|
||||
else
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to remove the status modes from " << u->nick;
|
||||
RemoveAll(u, c);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user