diff options
author | Adam <Adam@anope.org> | 2010-11-15 23:07:13 -0500 |
---|---|---|
committer | Adam <Adam@anope.org> | 2010-12-12 19:33:59 -0500 |
commit | a85112172d842aa74aa5531788d383328d153e74 (patch) | |
tree | 7c2b02feb21f64b0b039992b92b86a09920a1eb5 /modules | |
parent | 5f18cb018dee9ff71efbfdd247a8dc4ca472b16b (diff) |
Removed and deprecated /cs set mlock, removed /cs clear, removed /os clearmodes, removed /cs akick (un)stick, added /cs clearusers
Diffstat (limited to 'modules')
-rw-r--r-- | modules/core/cs_akick.cpp | 91 | ||||
-rw-r--r-- | modules/core/cs_clear.cpp | 181 | ||||
-rw-r--r-- | modules/core/cs_clearusers.cpp | 87 | ||||
-rw-r--r-- | modules/core/cs_saset.cpp | 7 | ||||
-rw-r--r-- | modules/core/cs_set.cpp | 7 | ||||
-rw-r--r-- | modules/core/cs_set_mlock.cpp | 185 | ||||
-rw-r--r-- | modules/core/db_plain.cpp | 6 | ||||
-rw-r--r-- | modules/core/os_clearmodes.cpp | 189 | ||||
-rw-r--r-- | modules/extra/db_mysql.cpp | 7 |
9 files changed, 106 insertions, 654 deletions
diff --git a/modules/core/cs_akick.cpp b/modules/core/cs_akick.cpp index 175b20047..f539952d7 100644 --- a/modules/core/cs_akick.cpp +++ b/modules/core/cs_akick.cpp @@ -117,7 +117,7 @@ class AkickViewCallback : public AkickListCallback else timebuf = GetString(u, UNKNOWN); - u->SendMessage(ChanServ, akick->HasFlag(AK_STUCK) ? CHAN_AKICK_VIEW_FORMAT_STUCK : CHAN_AKICK_VIEW_FORMAT, index + 1, akick->HasFlag(AK_ISNICK) ? akick->nc->display.c_str() : akick->mask.c_str(), !akick->creator.empty() ? akick->creator.c_str() : GetString(u, UNKNOWN).c_str(), timebuf.c_str(), !akick->reason.empty() ? akick->reason.c_str() : GetString(u, NO_REASON).c_str()); + u->SendMessage(ChanServ, CHAN_AKICK_VIEW_FORMAT, index + 1, akick->HasFlag(AK_ISNICK) ? akick->nc->display.c_str() : akick->mask.c_str(), !akick->creator.empty() ? akick->creator.c_str() : GetString(u, UNKNOWN).c_str(), timebuf.c_str(), !akick->reason.empty() ? akick->reason.c_str() : GetString(u, NO_REASON).c_str()); if (akick->last_used) u->SendMessage(ChanServ, CHAN_AKICK_LAST_USED, do_strftime(akick->last_used).c_str()); @@ -270,89 +270,6 @@ class CommandCSAKick : public Command this->DoEnforce(u, ci); } - void DoStick(User *u, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) - { - NickAlias *na; - NickCore *nc; - Anope::string mask = params[2]; - unsigned i, end; - AutoKick *akick; - - if (!ci->GetAkickCount()) - { - u->SendMessage(ChanServ, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; - } - - na = findnick(mask); - nc = na ? na->nc : NULL; - - for (i = 0, end = ci->GetAkickCount(); i < end; ++i) - { - akick = ci->GetAkick(i); - - if (akick->HasFlag(AK_ISNICK)) - continue; - if (mask.equals_ci(akick->mask)) - break; - } - - if (i == end) - { - u->SendMessage(ChanServ, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; - } - - bool override = !check_access(u, ci, CA_AKICK); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "STICK " << akick->mask; - - akick->SetFlag(AK_STUCK); - u->SendMessage(ChanServ, CHAN_AKICK_STUCK, akick->mask.c_str(), ci->name.c_str()); - - if (ci->c) - stick_mask(ci, akick); - } - - void DoUnStick(User *u, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) - { - NickAlias *na; - NickCore *nc; - AutoKick *akick; - unsigned i, end; - Anope::string mask = params[2]; - - if (!ci->GetAkickCount()) - { - u->SendMessage(ChanServ, CHAN_AKICK_LIST_EMPTY, ci->name.c_str()); - return; - } - - na = findnick(mask); - nc = na ? na->nc : NULL; - - for (i = 0, end = ci->GetAkickCount(); i < end; ++i) - { - akick = ci->GetAkick(i); - - if (akick->HasFlag(AK_ISNICK)) - continue; - if (mask.equals_ci(akick->mask)) - break; - } - - if (i == end) - { - u->SendMessage(ChanServ, CHAN_AKICK_NOT_FOUND, mask.c_str(), ci->name.c_str()); - return; - } - - bool override = !check_access(u, ci, CA_AKICK); - Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "UNSTICK " << akick->mask; - - akick->UnsetFlag(AK_STUCK); - u->SendMessage(ChanServ, CHAN_AKICK_UNSTUCK, akick->mask.c_str(), ci->name.c_str()); - } - void DoDel(User *u, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { Anope::string mask = params[2]; @@ -542,7 +459,7 @@ class CommandCSAKick : public Command ChannelInfo *ci = cs_findchan(chan); - if (mask.empty() && (cmd.equals_ci("ADD") || cmd.equals_ci("STICK") || cmd.equals_ci("UNSTICK") || cmd.equals_ci("DEL"))) + if (mask.empty() && (cmd.equals_ci("ADD") || cmd.equals_ci("DEL"))) this->OnSyntaxError(u, cmd); else if (!check_access(u, ci, CA_AKICK) && !u->Account()->HasPriv("chanserv/access/modify")) u->SendMessage(ChanServ, ACCESS_DENIED); @@ -550,10 +467,6 @@ class CommandCSAKick : public Command u->SendMessage(ChanServ, CHAN_AKICK_DISABLED); else if (cmd.equals_ci("ADD")) this->DoAdd(u, ci, params); - else if (cmd.equals_ci("STICK")) - this->DoStick(u, ci, params); - else if (cmd.equals_ci("UNSTICK")) - this->DoUnStick(u, ci, params); else if (cmd.equals_ci("DEL")) this->DoDel(u, ci, params); else if (cmd.equals_ci("LIST")) diff --git a/modules/core/cs_clear.cpp b/modules/core/cs_clear.cpp deleted file mode 100644 index e9763dbdf..000000000 --- a/modules/core/cs_clear.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" - -class CommandCSClear : public Command -{ - public: - CommandCSClear() : Command("CLEAR", 2, 2) - { - } - - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) - { - Anope::string chan = params[0]; - Anope::string what = params[1]; - Channel *c = findchan(chan); - ChannelInfo *ci = c ? c->ci : NULL; - Anope::string modebuf; - - ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER); - ChannelMode *admin = ModeManager::FindChannelModeByName(CMODE_PROTECT); - ChannelMode *op = ModeManager::FindChannelModeByName(CMODE_OP); - ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP); - ChannelMode *voice = ModeManager::FindChannelModeByName(CMODE_VOICE); - - if (c) - // XXX - Log(LOG_COMMAND, u, this, ci) << what; - - if (!c) - u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str()); - else if (!check_access(u, ci, CA_CLEAR)) - u->SendMessage(ChanServ, ACCESS_DENIED); - else if (what.equals_ci("bans")) - { - c->ClearBans(); - - u->SendMessage(ChanServ, CHAN_CLEARED_BANS, chan.c_str()); - } - else if (ModeManager::FindChannelModeByName(CMODE_EXCEPT) && what.equals_ci("excepts")) - { - c->ClearExcepts(); - - u->SendMessage(ChanServ, CHAN_CLEARED_EXCEPTS, chan.c_str()); - } - else if (ModeManager::FindChannelModeByName(CMODE_INVITE) && what.equals_ci("invites")) - { - c->ClearInvites(); - - u->SendMessage(ChanServ, CHAN_CLEARED_INVITES, chan.c_str()); - } - else if (what.equals_ci("modes")) - { - c->ClearModes(); - check_modes(c); - - u->SendMessage(ChanServ, CHAN_CLEARED_MODES, chan.c_str()); - } - else if (what.equals_ci("ops")) - { - if (ircd->svsmode_ucmode) - { - if (owner) - { - modebuf = "-" + owner->ModeChar; - - ircdproto->SendSVSModeChan(c, modebuf, ""); - } - if (admin) - { - modebuf = "-" + admin->ModeChar; - - ircdproto->SendSVSModeChan(c, modebuf, ""); - } - if (op) - { - modebuf = "-" + op->ModeChar; - - ircdproto->SendSVSModeChan(c, modebuf, ""); - } - } - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_OWNER)) - c->RemoveMode(NULL, owner, uc->user->nick); - if (uc->Status->HasFlag(CMODE_PROTECT)) - c->RemoveMode(NULL, admin, uc->user->nick); - if (uc->Status->HasFlag(CMODE_OP)) - c->RemoveMode(NULL, op, uc->user->nick); - } - } - - u->SendMessage(ChanServ, CHAN_CLEARED_OPS, chan.c_str()); - } - else if ((halfop && what.equals_ci("hops")) || (voice && what.equals_ci("voices"))) - { - ChannelMode *cm = what.equals_ci("hops") ? halfop : voice; - - if (ircd->svsmode_ucmode) - { - modebuf = "-" + cm->ModeChar; - - ircdproto->SendSVSModeChan(c, modebuf, ""); - } - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(cm->Name)) - c->RemoveMode(NULL, cm, uc->user->nick); - } - } - } - else if (what.equals_ci("users")) - { - Anope::string buf = "CLEAR USERS command from " + u->nick; - - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) - { - UserContainer *uc = *it++; - - c->Kick(NULL, uc->user, "%s", buf.c_str()); - } - - u->SendMessage(ChanServ, CHAN_CLEARED_USERS, chan.c_str()); - } - else - SyntaxError(ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); - - return MOD_CONT; - } - - bool OnHelp(User *u, const Anope::string &subcommand) - { - u->SendMessage(ChanServ, CHAN_HELP_CLEAR); - return true; - } - - void OnSyntaxError(User *u, const Anope::string &subcommand) - { - SyntaxError(ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); - } - - void OnServHelp(User *u) - { - u->SendMessage(ChanServ, CHAN_HELP_CMD_CLEAR); - } -}; - -class CSClear : public Module -{ - CommandCSClear commandcsclear; - - public: - CSClear(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) - { - this->SetAuthor("Anope"); - this->SetType(CORE); - - this->AddCommand(ChanServ, &commandcsclear); - } -}; - -MODULE_INIT(CSClear) diff --git a/modules/core/cs_clearusers.cpp b/modules/core/cs_clearusers.cpp new file mode 100644 index 000000000..55c6f684e --- /dev/null +++ b/modules/core/cs_clearusers.cpp @@ -0,0 +1,87 @@ +/* ChanServ core functions + * + * (C) 2003-2010 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + * Based on the original code of Epona by Lara. + * Based on the original code of Services by Andy Church. + */ + +/*************************************************************************/ + +#include "module.h" + +class CommandCSClearUsers : public Command +{ + public: + CommandCSClearUsers() : Command("CLEARUSERS", 1, 1) + { + } + + CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) + { + Anope::string chan = params[0]; + Anope::string what = params[1]; + Channel *c = findchan(chan); + ChannelInfo *ci = c ? c->ci : NULL; + Anope::string modebuf; + + ChannelMode *owner = ModeManager::FindChannelModeByName(CMODE_OWNER); + ChannelMode *admin = ModeManager::FindChannelModeByName(CMODE_PROTECT); + ChannelMode *op = ModeManager::FindChannelModeByName(CMODE_OP); + ChannelMode *halfop = ModeManager::FindChannelModeByName(CMODE_HALFOP); + ChannelMode *voice = ModeManager::FindChannelModeByName(CMODE_VOICE); + + if (!c) + u->SendMessage(ChanServ, CHAN_X_NOT_IN_USE, chan.c_str()); + else if (!check_access(u, ci, CA_CLEAR)) + u->SendMessage(ChanServ, ACCESS_DENIED); + + Anope::string buf = "CLEAR USERS command from " + u->nick + " (" + u->Account()->display + ")"; + + for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ) + { + UserContainer *uc = *it++; + + c->Kick(NULL, uc->user, "%s", buf.c_str()); + } + + u->SendMessage(ChanServ, CHAN_CLEARED_USERS, chan.c_str()); + + return MOD_CONT; + } + + bool OnHelp(User *u, const Anope::string &subcommand) + { + u->SendMessage(ChanServ, CHAN_HELP_CLEAR); + return true; + } + + void OnSyntaxError(User *u, const Anope::string &subcommand) + { + SyntaxError(ChanServ, u, "CLEAR", CHAN_CLEAR_SYNTAX); + } + + void OnServHelp(User *u) + { + u->SendMessage(ChanServ, CHAN_HELP_CMD_CLEAR); + } +}; + +class CSClearUsers : public Module +{ + CommandCSClearUsers commandcsclearusers; + + public: + CSClearUsers(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) + { + this->SetAuthor("Anope"); + this->SetType(CORE); + + this->AddCommand(ChanServ, &commandcsclearusers); + } +}; + +MODULE_INIT(CSClearUsers) diff --git a/modules/core/cs_saset.cpp b/modules/core/cs_saset.cpp index 0e485e540..491e5725f 100644 --- a/modules/core/cs_saset.cpp +++ b/modules/core/cs_saset.cpp @@ -36,6 +36,13 @@ class CommandCSSASet : public Command return MOD_CONT; } + // XXX Remove after 1.9.4 release + if (params[1].equals_ci("MLOCK")) + { + u->SendMessage(ChanServ, CHAN_SET_MLOCK_DEPRECATED); + return MOD_CONT; + } + Command *c = this->FindCommand(params[1]); if (c) diff --git a/modules/core/cs_set.cpp b/modules/core/cs_set.cpp index fe37e7ea6..04721cab8 100644 --- a/modules/core/cs_set.cpp +++ b/modules/core/cs_set.cpp @@ -41,6 +41,13 @@ class CommandCSSet : public Command return MOD_CONT; } + // XXX Remove after 1.9.4 release + if (params[1].equals_ci("MLOCK")) + { + u->SendMessage(ChanServ, CHAN_SET_MLOCK_DEPRECATED); + return MOD_CONT; + } + Command *c = this->FindCommand(params[1]); if (c) diff --git a/modules/core/cs_set_mlock.cpp b/modules/core/cs_set_mlock.cpp deleted file mode 100644 index 2556653a2..000000000 --- a/modules/core/cs_set_mlock.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/* ChanServ core functions - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" - -class CommandCSSetMLock : public Command -{ - public: - CommandCSSetMLock(const Anope::string &cpermission = "") : Command("MLOCK", 1, 0, cpermission) - { - } - - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) - { - ChannelInfo *ci = cs_findchan(params[0]); - if (!ci) - throw CoreException("NULL ci in CommandCSSetMLock"); - - int add = -1; /* 1 if adding, 0 if deleting, -1 if neither */ - ChannelMode *cm; - unsigned paramcount = 2; - - ci->ClearMLock(); - ci->ClearParams(); - - if (ModeManager::FindChannelModeByName(CMODE_REGISTERED)) - ci->SetMLock(CMODE_REGISTERED, true); - - Anope::string modes = params[1]; - for (Anope::string::const_iterator ch = modes.begin(), end = modes.end(); ch != end; ++ch) - { - switch (*ch) - { - case '+': - add = 1; - continue; - case '-': - add = 0; - continue; - default: - if (add < 0) - continue; - } - - if ((cm = ModeManager::FindChannelModeByChar(*ch))) - { - if (cm->Type == MODE_STATUS || cm->Type == MODE_LIST || !cm->CanSet(u)) - u->SendMessage(ChanServ, CHAN_SET_MLOCK_IMPOSSIBLE_CHAR, *ch); - else if (add) - { - ci->RemoveMLock(cm->Name); - - if (cm->Type == MODE_PARAM) - { - if (paramcount >= params.size()) - continue; - - Anope::string param = params[paramcount++]; - - ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm); - - if (!cmp || !cmp->IsValid(param)) - continue; - - ci->SetMLock(cmp->Name, true, param); - } - else - ci->SetMLock(cm->Name, true); - } - else - ci->SetMLock(cm->Name, false); - } - else - u->SendMessage(ChanServ, CHAN_SET_MLOCK_UNKNOWN_CHAR, *ch); - } - - /* We can't mlock +L if +l is not mlocked as well. */ - if (ModeManager::FindChannelModeByName(CMODE_REDIRECT) && ci->HasMLock(CMODE_REDIRECT, true) && !ci->HasMLock(CMODE_LIMIT, true)) - { - ci->RemoveMLock(CMODE_REDIRECT); - u->SendMessage(ChanServ, CHAN_SET_MLOCK_L_REQUIRED); - } - - /* Some ircd we can't set NOKNOCK without INVITE */ - /* So check if we need there is a NOKNOCK MODE and that we need INVITEONLY */ - if (ModeManager::FindChannelModeByName(CMODE_NOKNOCK) && ircd->knock_needs_i && ci->HasMLock(CMODE_NOKNOCK, true) && !ci->HasMLock(CMODE_INVITE, true)) - { - ci->RemoveMLock(CMODE_NOKNOCK); - u->SendMessage(ChanServ, CHAN_SET_MLOCK_K_REQUIRED); - } - - /* Since we always enforce mode r there is no way to have no - * mode lock at all. - */ - if (!get_mlock_modes(ci, 0).empty()) - u->SendMessage(ChanServ, CHAN_MLOCK_CHANGED, ci->name.c_str(), get_mlock_modes(ci, 0).c_str()); - - /* Implement the new lock. */ - if (ci->c) - check_modes(ci->c); - - return MOD_CONT; - } - - bool OnHelp(User *u, const Anope::string &) - { - u->SendMessage(ChanServ, CHAN_HELP_SET_MLOCK, "SET"); - return true; - } - - void OnSyntaxError(User *u, const Anope::string &) - { - // XXX - SyntaxError(ChanServ, u, "SET", CHAN_SET_SYNTAX); - } - - void OnServHelp(User *u) - { - u->SendMessage(ChanServ, CHAN_HELP_CMD_SET_MLOCK); - } -}; - -class CommandCSSASetMLock : public CommandCSSetMLock -{ - public: - CommandCSSASetMLock() : CommandCSSetMLock("chanserv/saset/mlock") - { - } - - bool OnHelp(User *u, const Anope::string &) - { - u->SendMessage(ChanServ, CHAN_HELP_SET_MLOCK, "SASET"); - return true; - } - - void OnSyntaxError(User *u, const Anope::string &) - { - // XXX - SyntaxError(ChanServ, u, "SASET", CHAN_SASET_SYNTAX); - } -}; - -class CSSetMLock : public Module -{ - CommandCSSetMLock commandcssetmlock; - CommandCSSASetMLock commandcssasetmlock; - - public: - CSSetMLock(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) - { - this->SetAuthor("Anope"); - this->SetType(CORE); - - Command *c = FindCommand(ChanServ, "SET"); - if (c) - c->AddSubcommand(&commandcssetmlock); - - c = FindCommand(ChanServ, "SASET"); - if (c) - c->AddSubcommand(&commandcssasetmlock); - } - - ~CSSetMLock() - { - Command *c = FindCommand(ChanServ, "SET"); - if (c) - c->DelSubcommand(&commandcssetmlock); - - c = FindCommand(ChanServ, "SASET"); - if (c) - c->DelSubcommand(&commandcssasetmlock); - } -}; - -MODULE_INIT(CSSetMLock) diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp index 19acd810d..d6f7963d5 100644 --- a/modules/core/db_plain.cpp +++ b/modules/core/db_plain.cpp @@ -710,7 +710,7 @@ class DBPlain : public Module } else if (key.equals_ci("AKICK")) { - bool Stuck = params[0].equals_ci("STUCK"); + // 0 is the old stuck bool Nick = params[1].equals_ci("NICK"); NickCore *nc = NULL; if (Nick) @@ -728,8 +728,6 @@ class DBPlain : public Module ak = ci->AddAkick(params[3], nc, params.size() > 6 ? params[6] : "", params[4].is_pos_number_only() ? convertTo<time_t>(params[4]) : 0, params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : 0); else ak = ci->AddAkick(params[3], params[2], params.size() > 6 ? params[6] : "", params[4].is_pos_number_only() ? convertTo<time_t>(params[4]) : 0, params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : 0); - if (Stuck) - ak->SetFlag(AK_STUCK); if (Nick) ak->SetFlag(AK_ISNICK); @@ -968,7 +966,7 @@ class DBPlain : public Module db << "MD ACCESS " << ci->GetAccess(k)->nc->display << " " << ci->GetAccess(k)->level << " " << ci->GetAccess(k)->last_seen << " " << ci->GetAccess(k)->creator << endl; for (unsigned k = 0, end = ci->GetAkickCount(); k < end; ++k) { - db << "MD AKICK " << (ci->GetAkick(k)->HasFlag(AK_STUCK) ? "STUCK " : "UNSTUCK ") << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? "NICK " : "MASK ") << + db << "MD AKICK 0 " << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? "NICK " : "MASK ") << (ci->GetAkick(k)->HasFlag(AK_ISNICK) ? ci->GetAkick(k)->nc->display : ci->GetAkick(k)->mask) << " " << ci->GetAkick(k)->creator << " " << ci->GetAkick(k)->addtime << " " << ci->last_used << " :"; if (!ci->GetAkick(k)->reason.empty()) db << ci->GetAkick(k)->reason; diff --git a/modules/core/os_clearmodes.cpp b/modules/core/os_clearmodes.cpp deleted file mode 100644 index 0042ac58f..000000000 --- a/modules/core/os_clearmodes.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* OperServ core functions - * - * (C) 2003-2010 Anope Team - * Contact us at team@anope.org - * - * Please read COPYING and README for further details. - * - * Based on the original code of Epona by Lara. - * Based on the original code of Services by Andy Church. - */ - -/*************************************************************************/ - -#include "module.h" - -class CommandOSClearModes : public Command -{ - public: - CommandOSClearModes() : Command("CLEARMODES", 1, 2, "operserv/clearmodes") - { - } - - CommandReturn Execute(User *u, const std::vector<Anope::string> ¶ms) - { - Anope::string chan = params[0]; - Channel *c; - int all = 0; - ChannelMode *cm; - Anope::string buf; - - if (!(c = findchan(chan))) - { - u->SendMessage(OperServ, CHAN_X_NOT_IN_USE, chan.c_str()); - return MOD_CONT; - } - else if (c->bouncy_modes) - { - u->SendMessage(OperServ, OPER_BOUNCY_MODES_U_LINE); - return MOD_CONT; - } - else - { - Anope::string s = params.size() > 1 ? params[1] : ""; - if (!s.empty()) - { - if (s.equals_ci("ALL")) - all = 1; - else - { - this->OnSyntaxError(u, ""); - return MOD_CONT; - } - } - - if (Config->WallOSClearmodes) - ircdproto->SendGlobops(OperServ, "%s used CLEARMODES%s on %s", u->nick.c_str(), all ? " ALL" : "", chan.c_str()); - if (all) - { - /* Clear mode +o */ - if (ircd->svsmode_ucmode) - ircdproto->SendSVSModeChan(c, "-o", ""); - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_OP)) - c->RemoveMode(NULL, CMODE_OP, uc->user->nick); - } - } - - /* Clear mode +v */ - if (ircd->svsmode_ucmode) - ircdproto->SendSVSModeChan(c, "-v", ""); - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_VOICE)) - c->RemoveMode(NULL, CMODE_VOICE, uc->user->nick); - } - } - - /* Clear mode +h */ - if (ModeManager::FindChannelModeByName(CMODE_HALFOP)) - { - if (ircd->svsmode_ucmode) - ircdproto->SendSVSModeChan(c, "-h", ""); - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_HALFOP)) - c->RemoveMode(NULL, CMODE_HALFOP, uc->user->nick); - } - } - } - - /* Clear mode Owners */ - if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER))) - { - buf = "-" + cm->ModeChar; - - if (ircd->svsmode_ucmode) - ircdproto->SendSVSModeChan(c, buf, ""); - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_OWNER)) - c->RemoveMode(NULL, CMODE_OWNER, uc->user->nick); - } - } - } - - /* Clear mode protected or admins */ - if ((cm = ModeManager::FindChannelModeByName(CMODE_PROTECT))) - { - buf = "-" + cm->ModeChar; - - if (ircd->svsmode_ucmode) - ircdproto->SendSVSModeChan(c, buf, ""); - else - { - for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) - { - UserContainer *uc = *it; - - if (uc->Status->HasFlag(CMODE_PROTECT)) - c->RemoveMode(NULL, CMODE_PROTECT, uc->user->nick); - } - } - } - } - - - c->ClearModes(); - c->ClearBans(); - c->ClearExcepts(); - c->ClearInvites(); - } - - if (all) - u->SendMessage(OperServ, OPER_CLEARMODES_ALL_DONE, chan.c_str()); - else - u->SendMessage(OperServ, OPER_CLEARMODES_DONE, chan.c_str()); - - return MOD_CONT; - } - - bool OnHelp(User *u, const Anope::string &subcommand) - { - u->SendMessage(OperServ, OPER_HELP_CLEARMODES); - return true; - } - - void OnSyntaxError(User *u, const Anope::string &subcommand) - { - SyntaxError(OperServ, u, "CLEARMODES", OPER_CLEARMODES_SYNTAX); - } - - void OnServHelp(User *u) - { - u->SendMessage(OperServ, OPER_HELP_CMD_CLEARMODES); - } -}; - -class OSClearModes : public Module -{ - CommandOSClearModes commandosclearmodes; - - public: - OSClearModes(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator) - { - this->SetAuthor("Anope"); - this->SetType(CORE); - - this->AddCommand(OperServ, &commandosclearmodes); - } -}; - -MODULE_INIT(OSClearModes) diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp index 6f18077f8..147a35229 100644 --- a/modules/extra/db_mysql.cpp +++ b/modules/extra/db_mysql.cpp @@ -752,21 +752,16 @@ class DBMySQL : public Module NickCore *nc = NULL; spacesepstream sep(r.Get(i, "flags")); Anope::string flag, mask; - bool stuck = false; while (sep.GetToken(flag)) { if (flag.equals_cs("ISNICK")) nc = findcore(r.Get(i, "mask")); - else if (flag.equals_cs("STUCK")) - stuck = true; AutoKick *ak; if (nc) ak = ci->AddAkick(r.Get(i, "creator"), nc, r.Get(i, "reason"), atol(r.Get(i, "created").c_str()), atol(r.Get(i, "last_used").c_str())); else ak = ci->AddAkick(r.Get(i, "creator"), r.Get(i, "mask"), r.Get(i, "reason"), atol(r.Get(i, "created").c_str()), atol(r.Get(i, "last_used").c_str())); - if (stuck) - ak->SetFlag(AK_STUCK); if (nc) ak->SetFlag(AK_ISNICK); } @@ -1268,7 +1263,7 @@ class DBMySQL : public Module void OnAkickAdd(ChannelInfo *ci, AutoKick *ak) { this->RunQuery("INSERT INTO `anope_cs_akick` (channel, flags, mask, reason, creator, created, last_used) VALUES('" + this->Escape(ci->name) + "', '" + - (ak->HasFlag(AK_ISNICK) ? "ISNICK " : "") + (ak->HasFlag(AK_STUCK) ? "STUCK " : "") + "', '" + + (ak->HasFlag(AK_ISNICK) ? "ISNICK" : "") + "', '" + this->Escape(ak->HasFlag(AK_ISNICK) ? ak->nc->display : ak->mask) + "', '" + this->Escape(ak->reason) + "', '" + this->Escape(ak->creator) + "', " + stringify(ak->addtime) + ", " + stringify(ak->last_used) + ")"); } |