diff options
| author | Adam <Adam@anope.org> | 2014-05-28 12:07:29 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2014-05-28 12:07:54 -0400 |
| commit | f29e1cf383529a1a29f02b0669d973f5ee0b7a66 (patch) | |
| tree | 3c33db276dc9328235bbd572641521ed44458176 /modules/commands | |
| parent | 1253c70e0682fa1490c99c3d2869049a0e3fa2e0 (diff) | |
Move most of the core pseudoclient logic to modules
Diffstat (limited to 'modules/commands')
88 files changed, 886 insertions, 794 deletions
diff --git a/modules/commands/bs_assign.cpp b/modules/commands/bs_assign.cpp index 90fb7ed56..fe7938fc8 100644 --- a/modules/commands/bs_assign.cpp +++ b/modules/commands/bs_assign.cpp @@ -32,7 +32,7 @@ class CommandBSAssign : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -46,7 +46,7 @@ class CommandBSAssign : public Command return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (ci->HasExt("BS_NOBOT") || (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration"))) { source.Reply(ACCESS_DENIED); @@ -100,14 +100,14 @@ class CommandBSUnassign : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); return; } - AccessGroup access = source.AccessFor(ci); + ChanServ::AccessGroup access = source.AccessFor(ci); if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN")) { source.Reply(ACCESS_DENIED); @@ -157,7 +157,7 @@ class CommandBSSetNoBot : public Command void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) override { - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); const Anope::string &value = params[1]; if (Anope::ReadOnly) @@ -174,7 +174,7 @@ class CommandBSSetNoBot : public Command if (value.equals_ci("ON")) { - Log(LOG_ADMIN, source, this, ci) << "to enable nobot"; + Log(LOG_ADMIN, source, this, ci) << "to enable nobot"; ci->Extend<bool>("BS_NOBOT"); if (ci->bi) @@ -183,7 +183,7 @@ class CommandBSSetNoBot : public Command } else if (value.equals_ci("OFF")) { - Log(LOG_ADMIN, source, this, ci) << "to disable nobot"; + Log(LOG_ADMIN, source, this, ci) << "to disable nobot"; ci->Shrink<bool>("BS_NOBOT"); source.Reply(_("No-bot mode is now \002off\002 on channel %s."), ci->name.c_str()); @@ -230,7 +230,7 @@ class BSAssign : public Module if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = dynamic_cast<BotInfo *>(targ))) return; - AccessGroup access = c->ci->AccessFor(source); + ChanServ::AccessGroup access = c->ci->AccessFor(source); if (nobot.HasExt(c->ci) || (!access.HasPriv("ASSIGN") && !source->HasPriv("botserv/administration"))) { targ->SendMessage(bi, ACCESS_DENIED); @@ -253,7 +253,7 @@ class BSAssign : public Module targ->SendMessage(bi, _("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), c->name.c_str()); } - void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) override + void OnBotInfo(CommandSource &source, BotInfo *bi, ChanServ::Channel *ci, InfoFormatter &info) override { if (nobot.HasExt(ci)) info.AddOption(_("No bot")); diff --git a/modules/commands/bs_badwords.cpp b/modules/commands/bs_badwords.cpp index 082dae0bd..b410aced2 100644 --- a/modules/commands/bs_badwords.cpp +++ b/modules/commands/bs_badwords.cpp @@ -31,11 +31,11 @@ struct BadWordImpl : BadWord, Serializable struct BadWordsImpl : BadWords { - Serialize::Reference<ChannelInfo> ci; + Serialize::Reference<ChanServ::Channel> ci; typedef std::vector<BadWordImpl *> list; Serialize::Checker<list> badwords; - BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChannelInfo *>(obj)), badwords("BadWord") { } + BadWordsImpl(Extensible *obj) : ci(anope_dynamic_static_cast<ChanServ::Channel *>(obj)), badwords("BadWord") { } ~BadWordsImpl(); @@ -72,7 +72,7 @@ struct BadWordsImpl : BadWords { if (this->badwords->empty() || index >= this->badwords->size()) return; - + (*bwevents)(&Event::BadWordEvents::OnBadWordDel, ci, (*this->badwords)[index]); delete this->badwords->at(index); @@ -103,7 +103,7 @@ BadWordsImpl::~BadWordsImpl() BadWordImpl::~BadWordImpl() { - ChannelInfo *ci = ChannelInfo::Find(chan); + ChanServ::Channel *ci = ChanServ::Find(chan); if (ci) { BadWordsImpl *badwords = ci->GetExt<BadWordsImpl>("badwords"); @@ -123,13 +123,13 @@ Serializable* BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data) data["ci"] >> sci; data["word"] >> sword; - ChannelInfo *ci = ChannelInfo::Find(sci); + ChanServ::Channel *ci = ChanServ::Find(sci); if (!ci) return NULL; unsigned int n; data["type"] >> n; - + BadWordImpl *bw; if (obj) bw = anope_dynamic_static_cast<BadWordImpl *>(obj); @@ -141,20 +141,20 @@ Serializable* BadWordImpl::Unserialize(Serializable *obj, Serialize::Data &data) BadWordsImpl *bws = ci->Require<BadWordsImpl>("badwords"); bws->badwords->push_back(bw); - + return bw; } class BadwordsDelCallback : public NumberList { CommandSource &source; - ChannelInfo *ci; + ChanServ::Channel *ci; BadWords *bw; Command *c; unsigned deleted; bool override; public: - BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) + BadwordsDelCallback(CommandSource &_source, ChanServ::Channel *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), deleted(0), override(false) { if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration")) this->override = true; @@ -185,7 +185,7 @@ class BadwordsDelCallback : public NumberList class CommandBSBadwords : public Command { private: - void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoList(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST"; @@ -259,7 +259,7 @@ class CommandBSBadwords : public Command } } - void DoAdd(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoAdd(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { size_t pos = word.rfind(' '); BadWordType bwtype = BW_ANY; @@ -308,7 +308,7 @@ class CommandBSBadwords : public Command source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str()); } - void DoDelete(CommandSource &source, ChannelInfo *ci, const Anope::string &word) + void DoDelete(CommandSource &source, ChanServ::Channel *ci, const Anope::string &word) { BadWords *badwords = ci->GetExt<BadWords>("badwords"); @@ -354,7 +354,7 @@ class CommandBSBadwords : public Command badwords->Check(); } - void DoClear(CommandSource &source, ChannelInfo *ci) + void DoClear(CommandSource &source, ChanServ::Channel *ci) { bool override = !source.AccessFor(ci).HasPriv("BADWORDS"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR"; @@ -387,7 +387,7 @@ class CommandBSBadwords : public Command return; } - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_bot.cpp b/modules/commands/bs_bot.cpp index 9aa572f00..977d4b72f 100644 --- a/modules/commands/bs_bot.cpp +++ b/modules/commands/bs_bot.cpp @@ -73,7 +73,7 @@ class CommandBSBot : public Command * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (NickAlias::Find(nick)) + if (NickServ::FindNick(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -176,7 +176,7 @@ class CommandBSBot : public Command * if so. You need to drop the nick manually before you can use * it as a bot nick from now on -GD */ - if (NickAlias::Find(nick)) + if (NickServ::FindNick(nick)) { source.Reply(NICK_ALREADY_REGISTERED, nick.c_str()); return; @@ -210,10 +210,10 @@ class CommandBSBot : public Command { IRCD->SendClientIntroduction(bi); unsigned minusers = Config->GetBlock("botserv")->Get<unsigned>("minusers"); - const std::set<ChannelInfo *> &channels = bi->GetChannels(); - for (std::set<ChannelInfo *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) + const std::set<ChanServ::Channel *> &channels = bi->GetChannels(); + for (std::set<ChanServ::Channel *>::const_iterator it = channels.begin(), it_end = channels.end(); it != it_end; ++it) { - const ChannelInfo *ci = *it; + const ChanServ::Channel *ci = *it; if (ci->c && ci->c->users.size() >= minusers) bi->Join(ci->c); diff --git a/modules/commands/bs_control.cpp b/modules/commands/bs_control.cpp index 38745c191..0311a9df2 100644 --- a/modules/commands/bs_control.cpp +++ b/modules/commands/bs_control.cpp @@ -24,7 +24,7 @@ class CommandBSSay : public Command { const Anope::string &text = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); @@ -84,7 +84,7 @@ class CommandBSAct : public Command { Anope::string message = params[1]; - ChannelInfo *ci = ChannelInfo::Find(params[0]); + ChanServ::Channel *ci = ChanServ::Find(params[0]); if (ci == NULL) { source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str()); diff --git a/modules/commands/bs_info.cpp b/modules/commands/bs_info.cpp index 49775a053..88ac15a48 100644 --- a/modules/commands/bs_info.cpp +++ b/modules/commands/bs_info.cpp @@ -20,18 +20,13 @@ class CommandBSInfo : public Command void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi) { Anope::string buf; - for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it) + for (ChanServ::Channel *ci : bi->GetChannels()) { - const ChannelInfo *ci = it->second; - - if (ci->bi == bi) + buf += " " + ci->name + " "; + if (buf.length() > 300) { - buf += " " + ci->name + " "; - if (buf.length() > 300) - { - buffers.push_back(buf); - buf.clear(); - } + buffers.push_back(buf); + buf.clear(); } } if (!buf.empty()) @@ -51,7 +46,7 @@ class CommandBSInfo : public Command const Anope::string &query = params[0]; BotInfo *bi = BotInfo::Find(query, true); - ChannelInfo *ci = ChannelInfo::Find(query); + ChanServ::Channel *ci = ChanServ::Find(query); InfoFormatter info(source.nc); if (bi) diff --git a/modules/commands/bs_kick.cpp b/modules/commands/bs_kick.cpp index 3a4d78c93..7ffd9d353 100644 --- a/modules/commands/bs_kick.cpp +++ b/modules/commands/bs_kick.cpp @@ -28,15 +28,15 @@ struct KickerDataImpl : KickerData capsmin = capspercent = 0; floodlines = floodsecs = 0; repeattimes = 0; - + dontkickops = dontkickvoices = false; } - void Check(ChannelInfo *ci) override + void Check(ChanServ::Channel *ci) override { if (amsgs || badwords || bolds || caps || colors || flood || italics || repeat || reverses || underlines) return; - + ci->Shrink<KickerData>("kickerdata"); } @@ -46,10 +46,10 @@ struct KickerDataImpl : KickerData void ExtensibleSerialize(const Extensible *e, const Serializable *s, Serialize::Data &data) const override { - if (s->GetSerializableType()->GetName() != "ChannelInfo") + if (s->GetSerializableType()->GetName() != "ChanServ::Channel") return; - const ChannelInfo *ci = anope_dynamic_static_cast<const ChannelInfo *>(e); + const ChanServ::Channel *ci = anope_dynamic_static_cast<const ChanServ::Channel *>(e); KickerData *kd = this->Get(ci); if (kd == NULL) return; @@ -76,10 +76,10 @@ struct KickerDataImpl : KickerData void ExtensibleUnserialize(Extensible *e, Serializable *s, Serialize::Data &data) override { - if (s-> |
