1
0
mirror of https://github.com/anope/anope.git synced 2026-07-01 01:26:39 +02:00

Cleanup of cs_tban

This commit is contained in:
Adam
2012-01-07 16:21:31 -05:00
parent 9e71394127
commit 830c5ca725
+16 -25
View File
@@ -35,23 +35,6 @@ class TempBan : public CallBack
}
};
static bool CanBanUser(CommandSource &source, Channel *c, User *u2)
{
User *u = source.u;
ChannelInfo *ci = c->ci;
bool ok = false;
if (!ci->AccessFor(u).HasPriv("BAN"))
source.Reply(ACCESS_DENIED);
else if (matches_list(c, u2, CMODE_EXCEPT))
source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), ci->name.c_str());
else if (u2->IsProtected())
source.Reply(ACCESS_DENIED);
else
ok = true;
return ok;
}
class CommandCSTBan : public Command
{
public:
@@ -71,18 +54,26 @@ class CommandCSTBan : public Command
User *u2;
if (!c)
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
else if (!c->ci)
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
else if (!c->ci->AccessFor(source.u).HasPriv("BAN"))
source.Reply(ACCESS_DENIED);
else if (!(u2 = finduser(nick)))
source.Reply(NICK_X_NOT_IN_USE, nick.c_str());
else if (matches_list(c, u2, CMODE_EXCEPT))
source.Reply(CHAN_EXCEPTED, u2->nick.c_str(), c->ci->name.c_str());
else if (u2->IsProtected())
source.Reply(ACCESS_DENIED);
else
if (CanBanUser(source, c, u2))
{
Anope::string mask;
get_idealban(c->ci, u2, mask);
c->SetMode(NULL, CMODE_BAN, mask);
new TempBan(dotime(time), c, mask);
{
time_t t = dotime(time);
Anope::string mask;
get_idealban(c->ci, u2, mask);
c->SetMode(NULL, CMODE_BAN, mask);
new TempBan(t, c, mask);
source.Reply(_("%s banned from %s, will auto-expire in %s second(s)."), mask.c_str(), c->name.c_str(), time.c_str());
}
source.Reply(_("%s banned from %s, will auto-expire in %s."), mask.c_str(), c->name.c_str(), duration(t).c_str());
}
return;
}