summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2012-01-07 16:21:31 -0500
committerAdam <Adam@anope.org>2012-01-07 16:21:31 -0500
commit830c5ca725a62179ce42b05ffb9a809cb6db7b69 (patch)
tree0763ce852f9d01085a75d469602995323389d0d6 /modules
parent9e713941277e8d745b1713a6500349a9d1ecb8e3 (diff)
Cleanup of cs_tban
Diffstat (limited to 'modules')
-rw-r--r--modules/commands/cs_tban.cpp43
1 files changed, 17 insertions, 26 deletions
diff --git a/modules/commands/cs_tban.cpp b/modules/commands/cs_tban.cpp
index 62f241059..109371577 100644
--- a/modules/commands/cs_tban.cpp
+++ b/modules/commands/cs_tban.cpp
@@ -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);
-
- source.Reply(_("%s banned from %s, will auto-expire in %s second(s)."), mask.c_str(), c->name.c_str(), time.c_str());
- }
+ {
+ 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."), mask.c_str(), c->name.c_str(), duration(t).c_str());
+ }
return;
}