diff options
author | Adam <Adam@anope.org> | 2010-11-24 21:40:56 -0600 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:36:19 -0500 |
commit | cb6ef574e3df5cc846247450b74ca37d265f319e (patch) | |
tree | 8ce3374a537c312af63c78125bfea4622bb188f0 /modules/core/cs_suspend.cpp | |
parent | 37e02a3594fdddc3d5a3df0501c528f42db6c4da (diff) |
Send replies from fantasy commands back to the channel, this will be expanded on later
Diffstat (limited to 'modules/core/cs_suspend.cpp')
-rw-r--r-- | modules/core/cs_suspend.cpp | 41 |
1 files changed, 15 insertions, 26 deletions
diff --git a/modules/core/cs_suspend.cpp b/modules/core/cs_suspend.cpp index 085ac6a65..97ff9c0c7 100644 --- a/modules/core/cs_suspend.cpp +++ b/modules/core/cs_suspend.cpp @@ -20,13 +20,13 @@ class CommandCSSuspend : public Command { } - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - Anope::string chan = params[0]; - Anope::string reason = params.size() > 1 ? params[1] : ""; - ChannelInfo *ci = cs_findchan(chan); + const Anope::string &reason = params.size() > 1 ? params[1] : ""; - Channel *c; + User *u = source.u; + ChannelInfo *ci = source.ci; + Channel *c = ci->c; /* Assumes that permission checking has already been done. */ if (Config->ForceForbidReason && reason.empty()) @@ -35,28 +35,22 @@ class CommandCSSuspend : public Command return MOD_CONT; } - if (chan[0] != '#') - { - u->SendMessage(ChanServ, CHAN_UNSUSPEND_ERROR); - return MOD_CONT; - } - /* You should not SUSPEND a FORBIDEN channel */ if (ci->HasFlag(CI_FORBIDDEN)) { - u->SendMessage(ChanServ, CHAN_MAY_NOT_BE_REGISTERED, chan.c_str()); + source.Reply(CHAN_MAY_NOT_BE_REGISTERED, ci->name.c_str()); return MOD_CONT; } if (readonly) - u->SendMessage(ChanServ, READ_ONLY_MODE); + source.Reply(READ_ONLY_MODE); ci->SetFlag(CI_SUSPENDED); ci->forbidby = u->nick; if (!reason.empty()) ci->forbidreason = reason; - if ((c = findchan(ci->name))) + if (c) { for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) { @@ -73,7 +67,7 @@ class CommandCSSuspend : public Command ircdproto->SendGlobops(ChanServ, "\2%s\2 used SUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); Log(LOG_ADMIN, u, this, ci) << (!reason.empty() ? reason : "No reason"); - u->SendMessage(ChanServ, CHAN_SUSPEND_SUCCEEDED, chan.c_str()); + u->SendMessage(ChanServ, CHAN_SUSPEND_SUCCEEDED, ci->name.c_str()); FOREACH_MOD(I_OnChanSuspend, OnChanSuspend(ci)); @@ -105,23 +99,18 @@ class CommandCSUnSuspend : public Command this->SetFlag(CFLAG_ALLOW_SUSPENDED); } - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) + CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) { - Anope::string chan = params[0]; - ChannelInfo *ci = cs_findchan(chan); + User *u = source.u; + ChannelInfo *ci = source.ci; - if (chan[0] != '#') - { - u->SendMessage(ChanServ, CHAN_UNSUSPEND_ERROR); - return MOD_CONT; - } if (readonly) - u->SendMessage(ChanServ, READ_ONLY_MODE); + source.Reply(READ_ONLY_MODE); /* Only UNSUSPEND already suspended channels */ if (!ci->HasFlag(CI_SUSPENDED)) { - u->SendMessage(ChanServ, CHAN_UNSUSPEND_FAILED, chan.c_str()); + source.Reply(CHAN_UNSUSPEND_FAILED, ci->name.c_str()); return MOD_CONT; } @@ -134,7 +123,7 @@ class CommandCSUnSuspend : public Command if (Config->WallForbid) ircdproto->SendGlobops(ChanServ, "\2%s\2 used UNSUSPEND on channel \2%s\2", u->nick.c_str(), ci->name.c_str()); - u->SendMessage(ChanServ, CHAN_UNSUSPEND_SUCCEEDED, chan.c_str()); + u->SendMessage(ChanServ, CHAN_UNSUSPEND_SUCCEEDED, ci->name.c_str()); FOREACH_MOD(I_OnChanUnsuspend, OnChanUnsuspend(ci)); |