diff options
| author | Adam <Adam@anope.org> | 2017-10-07 21:10:47 -0400 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2017-10-07 21:10:47 -0400 |
| commit | 2312f1fbd06ac01bb55e1d99070cde05a09a5a17 (patch) | |
| tree | 69239628ed39e342650574f93d441f58d6d82b7b /modules | |
| parent | 286bffa2cd6a3f564334c5a4669ea3aadfb27a0a (diff) | |
No longer expose c->ci and ci->c
Diffstat (limited to 'modules')
35 files changed, 398 insertions, 342 deletions
diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index 26a448216..469f1f051 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -248,20 +248,22 @@ class BSAssign : public Module void OnInvite(User *source, Channel *c, User *targ) override { - ServiceBot *bi; - if (Anope::ReadOnly || !c->ci || targ->server != Me || !(bi = ServiceBot::Find(targ->nick, true))) + ServiceBot *bi = ServiceBot::Find(targ->nick, true); + ChanServ::Channel *ci = c->GetChannel(); + + if (Anope::ReadOnly || !ci || targ->server != Me || !bi) return; - ChanServ::AccessGroup access = c->ci->AccessFor(source); + ChanServ::AccessGroup access = ci->AccessFor(source); if (!access.HasPriv("ASSIGN") && !source->HasPriv("botserv/administration")) { - targ->SendMessage(bi, _("Access denied. You do not have privilege \002ASSIGN\002 on \002{0}\002."), c->ci->GetName()); + targ->SendMessage(bi, _("Access denied. You do not have privilege \002ASSIGN\002 on \002{0}\002."), ci->GetName()); return; } - if (nobot.HasExt(c->ci)) + if (nobot.HasExt(ci)) { - targ->SendMessage(bi, _("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), c->ci->GetName()); + targ->SendMessage(bi, _("Access denied. \002{0}\002 may not have a bot assigned to it because a Services Operator has disallowed it."), ci->GetName()); return; } @@ -271,14 +273,14 @@ class BSAssign : public Module return; } - if (c->ci->GetBot() == bi) + if (ci->GetBot() == bi) { - targ->SendMessage(bi, _("Bot \002{0}\002 is already assigned to \002{1}\002."), bi->nick, c->ci->GetName()); + targ->SendMessage(bi, _("Bot \002{0}\002 is already assigned to \002{1}\002."), bi->nick, ci->GetName()); return; } - bi->Assign(source, c->ci); - targ->SendMessage(bi, _("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, c->ci->GetName()); + bi->Assign(source, ci); + targ->SendMessage(bi, _("Bot \002{0}\002 has been assigned to \002{1}\002."), bi->nick, ci->GetName()); } void OnServiceBot(CommandSource &source, ServiceBot *bi, ChanServ::Channel *ci, InfoFormatter &info) override diff --git a/modules/botserv/control.cpp b/modules/botserv/control.cpp index 584e8eded..758f795f2 100644 --- a/modules/botserv/control.cpp +++ b/modules/botserv/control.cpp @@ -59,7 +59,8 @@ class CommandBSSay : public Command return; } - if (!ci->c || !ci->c->FindUser(ci->GetBot())) + Channel *c = ci->GetChannel(); + if (!c || !c->FindUser(ci->GetBot())) { source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName()); return; @@ -130,7 +131,8 @@ class CommandBSAct : public Command return; } - if (!ci->c || !ci->c->FindUser(ci->GetBot())) + Channel *c = ci->GetChannel(); + if (!c || !c->FindUser(ci->GetBot())) { source.Reply(_("Bot \002{0}\002 is not on channel \002{1}\002."), ci->GetBot()->nick, ci->GetName()); return; diff --git a/modules/botserv/kick.cpp b/modules/botserv/kick.cpp index b90a6e48e..2fbaf4c1b 100644 --- a/modules/botserv/kick.cpp +++ b/modules/botserv/kick.cpp @@ -1323,7 +1323,8 @@ class BSKick : public Module if (u->IsProtected()) return; - BanData::Data &bd = this->GetBanData(u, ci->c); + Channel *c = ci->GetChannel(); + BanData::Data &bd = this->GetBanData(u, c); ++bd.ttb[ttbtype]; if (ttb && bd.ttb[ttbtype] >= ttb) @@ -1332,15 +1333,15 @@ class BSKick : public Module Anope::string mask = ci->GetIdealBan(u); - ci->c->SetMode(NULL, "BAN", mask); + c->SetMode(NULL, "BAN", mask); EventManager::Get()->Dispatch(&Event::BotBan::OnBotBan, u, ci, mask); } - if (!ci->c->FindUser(u)) + if (!c->FindUser(u)) return; Anope::string buf = Anope::Format(message, std::forward<Args>(args)...); - ci->c->Kick(ci->GetBot(), u, buf); + c->Kick(ci->GetBot(), u, buf); } public: @@ -1518,10 +1519,10 @@ class BSKick : public Module * But FIRST we check whether the user is protected in any * way. */ - ChanServ::Channel *ci = c->ci; + ChanServ::Channel *ci = c->GetChannel(); if (ci == NULL) return; - KickerData *kd = c->ci->GetRef<KickerData *>(); + KickerData *kd = ci->GetRef<KickerData *>(); if (kd == NULL) return; @@ -1734,7 +1735,7 @@ class BSKick : public Module Channel *chan = it->second->chan; ++it; - if (chan->ci && kd->GetAmsgs() && !chan->ci->AccessFor(u).HasPriv("NOKICK")) + if (chan->GetChannel() && kd->GetAmsgs() && !chan->GetChannel()->AccessFor(u).HasPriv("NOKICK")) { TakeAction(ci, u, kd->GetTTBAmsgs(), TTB_AMSGS, _("Don't use AMSGs!")); return; diff --git a/modules/botserv/main/botserv.cpp b/modules/botserv/main/botserv.cpp index 8fb71f498..59a3e0ee1 100644 --- a/modules/botserv/main/botserv.cpp +++ b/modules/botserv/main/botserv.cpp @@ -52,21 +52,22 @@ class BotServCore : public Module, public BotServ::BotServService void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override { /* Do not allow removing bot modes on our service bots */ - if (chan->ci && chan->ci->GetBot() == user) + ChanServ::Channel *ci = chan->GetChannel(); + if (ci && ci->GetBot() == user) { const Anope::string &botmodes = Config->GetModule(this)->Get<Anope::string>("botmodes"); for (unsigned i = 0; i < botmodes.length(); ++i) - chan->SetMode(chan->ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), chan->ci->GetBot()->GetUID()); + chan->SetMode(ci->GetBot(), ModeManager::FindChannelModeByChar(botmodes[i]), ci->GetBot()->GetUID()); } } void OnBotAssign(User *sender, ChanServ::Channel *ci, ServiceBot *bi) override { - printf("on bot assign !\n"); - if (ci->c && ci->c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) + Channel *c = ci->GetChannel(); + if (c && c->users.size() >= Config->GetModule(this)->Get<unsigned>("minusers")) { ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("botmodes")); - bi->Join(ci->c, &status); + bi->Join(c, &status); } } @@ -108,7 +109,8 @@ class BotServCore : public Module, public BotServ::BotServService ModeManager::ProcessModes(); } - if (user->server != Me && c->ci && c->ci->GetBot()) + ChanServ::Channel *ci = c->GetChannel(); + if (user->server != Me && ci && ci->GetBot()) { /** * We let the bot join even if it was an ignored user, as if we don't, @@ -117,18 +119,20 @@ class BotServCore : public Module, public BotServ::BotServService * legit users - Rob **/ /* This is before the user has joined the channel, so check usercount + 1 */ - if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(c->ci->GetBot())) + if (c->users.size() + 1 >= Config->GetModule(this)->Get<unsigned>("minusers") && !c->FindUser(ci->GetBot())) { ChannelStatus status(Config->GetModule(this)->Get<Anope::string>("botmodes")); - c->ci->GetBot()->Join(c, &status); + ci->GetBot()->Join(c, &status); } } } void OnLeaveChannel(User *u, Channel *c) override { + ChanServ::Channel *ci = c->GetChannel(); + /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && c->ci->IsPersist()) + if (ci && ci->IsPersist()) return; /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately @@ -141,9 +145,9 @@ class BotServCore : public Module, public BotServ::BotServService if (inhabit && inhabit->HasExt(c)) return; - if (c->ci) + if (ci) { - ServiceBot *bot = c->ci->GetBot(); + ServiceBot *bot = ci->GetBot(); /* This is called prior to removing the user from the channnel, so c->users.size() - 1 should be safe */ if (bot && u != bot && c->users.size() - 1 <= Config->GetModule(this)->Get<unsigned>("minusers") && c->FindUser(bot)) @@ -203,9 +207,10 @@ class BotServCore : public Module, public BotServ::BotServService EventReturn OnChannelModeSet(Channel *c, const MessageSource &source, ChannelMode *mode, const Anope::string ¶m) override { - if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && c->ci && c->ci->GetBot() && c->FindUser(c->ci->GetBot())) + ChanServ::Channel *ci = c->GetChannel(); + if (source.GetUser() && !source.GetBot() && Config->GetModule(this)->Get<bool>("smartjoin") && mode->name == "BAN" && ci && ci->GetBot() && c->FindUser(ci->GetBot())) { - ServiceBot *bi = c->ci->GetBot(); + ServiceBot *bi = ci->GetBot(); Entry ban("BAN", param); if (ban.Matches(bi)) diff --git a/modules/chanserv/access.cpp b/modules/chanserv/access.cpp index c68af6e6f..32a6422cb 100644 --- a/modules/chanserv/access.cpp +++ b/modules/chanserv/access.cpp @@ -344,8 +344,8 @@ class CommandCSAccess : public Command ChanServ::ChanAccess *access = ci->GetAccess(number - 1); Anope::string timebuf; - if (ci->c) - for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) + if (Channel *c = ci->GetChannel()) + for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) { if (access->Matches(cit->second->user, cit->second->user->Account())) timebuf = "Now"; @@ -378,8 +378,8 @@ class CommandCSAccess : public Command continue; Anope::string timebuf; - if (ci->c) - for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end; ++cit) + if (Channel *c = ci->GetChannel()) + for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end; ++cit) { if (access->Matches(cit->second->user, cit->second->user->Account())) timebuf = "Now"; diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index d49a63ca5..9014ad9d6 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -209,9 +209,9 @@ class CommandCSAKick : public Command } /* Check excepts BEFORE we get this far */ - if (ci->c) + if (Channel *c = ci->GetChannel()) { - std::vector<Anope::string> modes = ci->c->GetModeList("EXCEPT"); + std::vector<Anope::string> modes = c->GetModeList("EXCEPT"); for (unsigned int i = 0; i < modes.size(); ++i) { if (Anope::Match(modes[i], mask)) @@ -510,7 +510,7 @@ class CommandCSAKick : public Command void DoEnforce(CommandSource &source, ChanServ::Channel *ci) { - Channel *c = ci->c; + Channel *c = ci->GetChannel(); int count = 0; if (!c) @@ -696,12 +696,13 @@ class CSAKick : public Module EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { - if (!c->ci || c->MatchesList(u, "EXCEPT")) + ChanServ::Channel *ci = c->GetChannel(); + if (!ci || c->MatchesList(u, "EXCEPT")) return EVENT_CONTINUE; - for (unsigned j = 0, end = c->ci->GetAkickCount(); j < end; ++j) + for (unsigned j = 0, end = ci->GetAkickCount(); j < end; ++j) { - AutoKick *ak = c->ci->GetAkick(j); + AutoKick *ak = ci->GetAkick(j); bool kick = false; if (ak->GetAccount()) diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp index cd6b70b1f..4e8c0ded7 100644 --- a/modules/chanserv/ban.cpp +++ b/modules/chanserv/ban.cpp @@ -61,7 +61,7 @@ class CommandCSBan : public Command return; } - Channel *c = ci->c; + Channel *c = ci->GetChannel(); if (c == NULL) { source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); @@ -213,7 +213,7 @@ class CommandCSBan : public Command continue; if (u != uc->user && ci->IsPeace() && u2_access >= u_access) continue; - else if (ci->c->MatchesList(uc->user, "EXCEPT")) + else if (c->MatchesList(uc->user, "EXCEPT")) continue; else if (uc->user->IsProtected()) continue; diff --git a/modules/chanserv/clone.cpp b/modules/chanserv/clone.cpp index c0ed04a64..341d80944 100644 --- a/modules/chanserv/clone.cpp +++ b/modules/chanserv/clone.cpp @@ -101,27 +101,25 @@ public: target_ci->SetTimeRegistered(Anope::CurTime); ChanServ::registered_channel_map& map = ChanServ::service->GetChannels(); map[target_ci->GetName()] = target_ci; - target_ci->c = Channel::Find(target_ci->GetName()); + Channel *target_channel = Channel::Find(target_ci->GetName()); if (ci->GetBot()) ci->GetBot()->Assign(u, target_ci); else target_ci->SetBot(nullptr); - if (target_ci->c) + if (target_channel) { - target_ci->c->ci = target_ci; + target_channel->CheckModes(); - target_ci->c->CheckModes(); - - target_ci->c->SetCorrectModes(u, true); + target_channel->SetCorrectModes(u, true); } - if (target_ci->c && !target_ci->c->topic.empty()) + if (target_channel && !target_channel->topic.empty()) { target_ci->SetLastTopic(target_ci->GetLastTopic()); - target_ci->SetLastTopicSetter(target_ci->c->topic_setter); - target_ci->SetLastTopicTime(target_ci->c->topic_time); + target_ci->SetLastTopicSetter(target_channel->topic_setter); + target_ci->SetLastTopicTime(target_channel->topic_time); } else { diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp index cd8718801..d85e5390d 100644 --- a/modules/chanserv/drop.cpp +++ b/modules/chanserv/drop.cpp @@ -65,7 +65,7 @@ class CommandCSDrop : public Command logger.Command(source, ci, _("{source} used {command} on {channel} (founder was: {0})"), ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none"); - Reference<Channel> c = ci->c; + Reference<Channel> c = ci->GetChannel(); ci->Delete(); source.Reply(_("Channel \002{0}\002 has been dropped."), chan); diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp index 85649f662..c9ca14acf 100644 --- a/modules/chanserv/enforce.cpp +++ b/modules/chanserv/enforce.cpp @@ -34,11 +34,12 @@ class CommandCSEnforce : public Command bool hadsecureops = ci->IsSecureOps(); ci->SetSecureOps(true); - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + Channel *c = ci->GetChannel(); + for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; - ci->c->SetCorrectModes(uc->user, false); + c->SetCorrectModes(uc->user, false); } if (!hadsecureops) @@ -51,8 +52,9 @@ class CommandCSEnforce : public Command { logger.Command(source, ci, _("{source} used {command} on {channel} to enforce restricted")); + Channel *c = ci->GetChannel(); std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; User *user = uc->user; @@ -70,8 +72,8 @@ class CommandCSEnforce : public Command Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("RESTRICTED enforced by ")) + source.GetNick(); - ci->c->SetMode(NULL, "BAN", mask); - ci->c->Kick(NULL, user, reason); + c->SetMode(NULL, "BAN", mask); + c->Kick(NULL, user, reason); } source.Reply(_("\002Restricted\002 enforced on \002{0}\002."), ci->GetName()); @@ -81,8 +83,9 @@ class CommandCSEnforce : public Command { logger.Command(source, ci, _("{source} used {command} on {channel} to enforce registered only")); + Channel *c = ci->GetChannel(); std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; User *user = uc->user; @@ -100,9 +103,9 @@ class CommandCSEnforce : public Command Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("REGONLY enforced by ")) + source.GetNick(); - if (!ci->c->HasMode("REGISTEREDONLY")) - ci->c->SetMode(NULL, "BAN", mask); - ci->c->Kick(NULL, user, reason); + if (!c->HasMode("REGISTEREDONLY")) + c->SetMode(NULL, "BAN", mask); + c->Kick(NULL, user, reason); } source.Reply(_("\002Registered only\002 enforced on \002{0}\002."), ci->GetName()); @@ -112,8 +115,9 @@ class CommandCSEnforce : public Command { logger.Command(source, ci, _("{source} used {command} on {channel} to enforce SSL only")); + Channel *c = ci->GetChannel(); std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; User *user = uc->user; @@ -131,9 +135,9 @@ class CommandCSEnforce : public Command Anope::string mask = ci->GetIdealBan(user); Anope::string reason = Language::Translate(user, _("SSLONLY enforced by ")) + source.GetNick(); - if (!ci->c->HasMode("SSL")) - ci->c->SetMode(NULL, "BAN", mask); - ci->c->Kick(NULL, user, reason); + if (!c->HasMode("SSL")) + c->SetMode(NULL, "BAN", mask); + c->Kick(NULL, user, reason); } source.Reply(_("\002SSL only\002 enforced on %s."), ci->GetName().c_str()); @@ -143,8 +147,9 @@ class CommandCSEnforce : public Command { logger.Command(source, ci, _("{source} used {command} on {channel} to enforce bans")); + Channel *c = ci->GetChannel(); std::vector<User *> users; - for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it) + for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) { ChanUserContainer *uc = it->second; User *user = uc->user; @@ -152,7 +157,7 @@ class CommandCSEnforce : public Command if (user->IsProtected()) continue; - if (ci->c->MatchesList(user, "BAN") && !ci->c->MatchesList(user, "EXCEPT")) + if (c->MatchesList(user, "BAN") && !c->MatchesList(user, "EXCEPT")) users.push_back(user); } @@ -161,7 +166,7 @@ class CommandCSEnforce : public Command User *user = users[i]; Anope::string reason = Language::Translate(user, _("BANS enforced by ")) + source.GetNick(); - ci->c->Kick(NULL, user, reason); + c->Kick(NULL, user, reason); } source.Reply(_("\002Bans\002 enforced on %s."), ci->GetName().c_str()); @@ -171,8 +176,9 @@ class CommandCSEnforce : public Command { logger.Command(source, ci, _("{source} used {command} on {channel} to enforce limit")); + Channel *c = ci->GetChannel(); Anope::string l_str; - if (!ci->c->GetParam("LIMIT", l_str)) + if (!c->GetParam("LIMIT", l_str)) { source.Reply(_("There is no limit is set on \002{0}\002."), ci->GetName()); return; @@ -193,7 +199,7 @@ class CommandCSEnforce : public Command std::vector<User *> users; /* The newer users are at the end of the list, so kick users starting from the end */ - for (Channel::ChanUserList::reverse_iterator it = ci->c->users.rbegin(), it_end = ci->c->users.rend(); it != it_end; ++it) + for (Channel::ChanUserList::reverse_iterator it = c->users.rbegin(), it_end = c->users.rend(); it != it_end; ++it) { ChanUserContainer *uc = it->second; User *user = uc->user; @@ -204,7 +210,7 @@ class CommandCSEnforce : public Command if (!ci->AccessFor(user).empty()) continue; - if (ci->c->users.size() - users.size() <= static_cast<unsigned>(l)) + if (c->users.size() - users.size() <= static_cast<unsigned>(l)) continue; users.push_back(user); @@ -215,7 +221,7 @@ class CommandCSEnforce : public Command User *user = users[i]; Anope::string reason = Language::Translate(user, _("LIMIT enforced by ")) + source.GetNick(); - ci->c->Kick(NULL, user, reason); + c->Kick(NULL, user, reason); } source.Reply(_("LIMIT enforced on \002{0}\002, \002{1]\002 users removed."), ci->GetName(), users.size()); @@ -240,7 +246,7 @@ class CommandCSEnforce : public Command return; } - if (!ci->c) + if (!ci->GetChannel()) { source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName()); return; diff --git a/modules/chanserv/entrymsg.cpp b/modules/chanserv/entrymsg.cpp index ec3f833fd..efcea8e9d 100644 --- a/modules/chanserv/entrymsg.cpp +++ b/modules/chanserv/entrymsg.cpp @@ -285,9 +285,10 @@ class CSEntryMessage : public Module void OnJoinChannel(User *u, Channel *c) override { - if (u && c && c->ci && u->server->IsSynced()) - for (EntryMsg *msg : c->ci->GetRefs<EntryMsg *>()) - u->SendMessage(c->ci->WhoSends(), "[{0}] {1}", c->ci->GetName(), msg->GetMessage()); + ChanServ::Channel *ci = c->GetChannel(); + if (ci && u->server->IsSynced()) + for (EntryMsg *msg : ci->GetRefs<EntryMsg *>()) + u->SendMessage(ci->WhoSends(), "[{0}] {1}", ci->GetName(), msg->GetMessage()); } }; diff --git a/modules/chanserv/getkey.cpp b/modules/chanserv/getkey.cpp index a1a3dd587..1f280ee52 100644 --- a/modules/chanserv/getkey.cpp +++ b/modules/chanserv/getkey.cpp @@ -46,7 +46,7 @@ class CommandCSGetKey : public Command } Anope::string key; - if (!ci->c || !ci->c->GetParam("KEY", key)) + if (!ci->GetChannel() || !ci->GetChannel()->GetParam("KEY", key)) { source.Reply(_("Channel \002{0}\002 does not have a key."), ci->GetName()); return; diff --git a/modules/chanserv/invite.cpp b/modules/chanserv/invite.cpp index 2f236b6c6..df8bee8f9 100644 --- a/modules/chanserv/invite.cpp +++ b/modules/chanserv/invite.cpp @@ -41,7 +41,7 @@ class CommandCSInvite : public Command return; } - ChanServ::Channel *ci = c->ci; + ChanServ::Channel *ci = c->GetChannel(); if (!ci) { source.Reply(_("Channel \002{0}\002 isn't registered."), c->name); diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index 6f9f06e60..1f89b0274 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -98,7 +98,7 @@ class CommandCSList : public Command { if (ci->IsPrivate() || ci->HasFieldS("CS_SUSPENDED")) continue; - if (ci->c && ci->c->HasMode("SECRET")) + if (ci->GetChannel() && ci->GetChannel()->HasMode("SECRET")) continue; if (mlocks) diff --git a/modules/chanserv/main/channel.cpp b/modules/chanserv/main/channel.cpp index a2d56b6ec..f4b0e2578 100644 --- a/modules/chanserv/main/channel.cpp +++ b/modules/chanserv/main/channel.cpp @@ -32,19 +32,13 @@ void ChannelImpl::Delete() Anope::Logger.Debug("Deleting channel {0}", this->GetName()); - if (this->c) + ::Channel *c = this->GetChannel(); + if (c) { - if (this->GetBot() && this->c->FindUser(this->GetBot())) - this->GetBot()->Part(this->c); - - /* Parting the service bot can cause the channel to go away */ - - if (this->c) + if (this->GetBot() && c->FindUser(this->GetBot())) { - if (this->c && this->c->CheckDelete()) - this->c->QueueForDeletion(); - - this->c = NULL; + this->GetBot()->Part(c); + c = nullptr; } } diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index 17716c3d4..2521ee22e 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -32,7 +32,6 @@ class ChanServCore : public Module , public ChanServ::ChanServService - , public EventHook<Event::ChannelCreate> , public EventHook<Event::BotDelete> , public EventHook<Event::BotPrivmsg> , public EventHook<Event::DelCore> @@ -61,7 +60,6 @@ class ChanServCore : public Module public: ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, PSEUDOCLIENT | VENDOR) , ChanServService(this) - , EventHook<Event::ChannelCreate>(this) , EventHook<Event::BotDelete>(this) , EventHook<Event::BotPrivmsg>(this) , EventHook<Event::DelCore>(this) @@ -115,15 +113,21 @@ class ChanServCore : public Module /** Constructor * @param chan The channel */ - ChanServTimer(Reference<ServiceBot> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")), ChanServ(cs), inhabit(i), c(chan) + ChanServTimer(Reference<ServiceBot> &cs, ExtensibleItem<bool> &i, Module *m, Channel *chan) : Timer(m, Config->GetModule(m)->Get<time_t>("inhabit", "15s")) + , ChanServ(cs) + , inhabit(i) + , c(chan) { if (!ChanServ || !c) return; + inhabit.Set(c, true); - if (!c->ci || !c->ci->GetBot()) + + ChanServ::Channel *ci = c->GetChannel(); + if (!ci || !ci->GetBot()) ChanServ->Join(c); - else if (!c->FindUser(c->ci->GetBot())) - c->ci->GetBot()->Join(c); + else if (!c->FindUser(ci->GetBot())) |
