summaryrefslogtreecommitdiff
path: root/modules/chanserv
diff options
context:
space:
mode:
Diffstat (limited to 'modules/chanserv')
-rw-r--r--modules/chanserv/access.cpp8
-rw-r--r--modules/chanserv/akick.cpp13
-rw-r--r--modules/chanserv/ban.cpp4
-rw-r--r--modules/chanserv/clone.cpp16
-rw-r--r--modules/chanserv/drop.cpp2
-rw-r--r--modules/chanserv/enforce.cpp48
-rw-r--r--modules/chanserv/entrymsg.cpp7
-rw-r--r--modules/chanserv/getkey.cpp2
-rw-r--r--modules/chanserv/invite.cpp2
-rw-r--r--modules/chanserv/list.cpp2
-rw-r--r--modules/chanserv/main/channel.cpp16
-rw-r--r--modules/chanserv/main/chanserv.cpp86
-rw-r--r--modules/chanserv/mode.cpp73
-rw-r--r--modules/chanserv/register.cpp3
-rw-r--r--modules/chanserv/set.cpp102
-rw-r--r--modules/chanserv/statusupdate.cpp9
-rw-r--r--modules/chanserv/suspend.cpp9
-rw-r--r--modules/chanserv/sync.cpp7
-rw-r--r--modules/chanserv/topic.cpp41
-rw-r--r--modules/chanserv/unban.cpp12
-rw-r--r--modules/chanserv/updown.cpp22
21 files changed, 256 insertions, 228 deletions
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()))
+ ci->GetBot()->Join(c);
/* Set +ntsi to prevent rejoin */
c->SetMode(NULL, "NOEXTERNAL");
@@ -146,14 +150,17 @@ class ChanServCore : public Module
c->RemoveMode(NULL, "SECRET");
c->RemoveMode(NULL, "INVITE");
- if (!c->ci || !c->ci->GetBot())
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci || !ci->GetBot())
{
if (ChanServ)
ChanServ->Part(c);
}
/* If someone has rejoined this channel in the meantime, don't part the bot */
else if (c->users.size() <= 1)
- c->ci->GetBot()->Part(c);
+ {
+ ci->GetBot()->Part(c);
+ }
}
};
@@ -248,13 +255,6 @@ class ChanServCore : public Module
defaults.clear();
}
- void OnChannelCreate(Channel *c) override
- {
- c->ci = Find(c->name);
- if (c->ci)
- c->ci->c = c;
- }
-
void OnBotDelete(ServiceBot *bi) override
{
if (bi == ChanServ)
@@ -324,14 +324,15 @@ class ChanServCore : public Module
void OnDelChan(ChanServ::Channel *ci) override
{
- if (ci->c)
- {
- ci->c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false);
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
+ return;
- const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
- if (!require.empty())
- ci->c->SetModes(ci->WhoSends(), false, "-%s", require.c_str());
- }
+ c->RemoveMode(ci->WhoSends(), "REGISTERED", "", false);
+
+ const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
+ if (!require.empty())
+ c->SetModes(ci->WhoSends(), false, "-%s", require.c_str());
}
EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> &params) override
@@ -371,7 +372,8 @@ class ChanServCore : public Module
if (!c)
return;
- if (c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (ci)
c->SetMode(nullptr, "REGISTERED", "", false);
else
c->RemoveMode(nullptr, "REGISTERED", "", false);
@@ -379,7 +381,7 @@ class ChanServCore : public Module
const Anope::string &require = Config->GetModule(this)->Get<Anope::string>("require");
if (!require.empty())
{
- if (c->ci)
+ if (ci)
c->SetModes(nullptr, false, "+%s", require.c_str());
else
c->SetModes(nullptr, false, "-%s", require.c_str());
@@ -396,7 +398,8 @@ class ChanServCore : public Module
void OnChannelSync(Channel *c) override
{
- bool perm = c->HasMode("PERM") || (c->ci && c->ci->IsPersist());
+ ChanServ::Channel *ci = c->GetChannel();
+ bool perm = c->HasMode("PERM") || (ci && ci->IsPersist());
if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me)))
{
this->Hold(c);
@@ -425,10 +428,11 @@ class ChanServCore : public Module
if (Anope::CurTime - ci->GetLastUsed() >= chanserv_expire)
{
- if (ci->c)
+ Channel *c = ci->GetChannel();
+ if (c)
{
time_t last_used = ci->GetLastUsed();
- for (Channel::ChanUserList::const_iterator cit = ci->c->users.begin(), cit_end = ci->c->users.end(); cit != cit_end && last_used == ci->GetLastUsed(); ++cit)
+ for (Channel::ChanUserList::const_iterator cit = c->users.begin(), cit_end = c->users.end(); cit != cit_end && last_used == ci->GetLastUsed(); ++cit)
ci->AccessFor(cit->second->user);
expire = last_used == ci->GetLastUsed();
}
@@ -465,14 +469,14 @@ class ChanServCore : public Module
{
if (ci->IsPersist())
{
- bool c;
- ci->c = Channel::FindOrCreate(ci->GetName(), c, ci->GetTimeRegistered());
+ bool created;
+ Channel *c = Channel::FindOrCreate(ci->GetName(), created, ci->GetTimeRegistered());
if (ModeManager::FindChannelModeByName("PERM") != NULL)
{
- if (c)
- IRCD->Send<messages::MessageChannel>(ci->c);
- ci->c->SetMode(NULL, "PERM");
+ if (created)
+ IRCD->Send<messages::MessageChannel>(c);
+ c->SetMode(NULL, "PERM");
}
else
{
@@ -483,12 +487,12 @@ class ChanServCore : public Module
bi->Assign(nullptr, ci);
}
- if (ci->GetBot() != nullptr && ci->c->FindUser(ci->GetBot()) == nullptr)
+ if (ci->GetBot() != nullptr && c->FindUser(ci->GetBot()) == nullptr)
{
Anope::string botmodes = Config->GetModule("botserv/main")->Get<Anope::string>("botmodes",
Config->GetModule("chanserv/main")->Get<Anope::string>("botmodes"));
ChannelStatus status(botmodes);
- ci->GetBot()->Join(ci->c, &status);
+ ci->GetBot()->Join(c, &status);
}
}
}
@@ -502,24 +506,26 @@ class ChanServCore : public Module
for (unsigned i = 0; i < defaults.size(); ++i)
ci->SetS<bool>(defaults[i].upper(), true);
- if (!ci->c)
+ Channel *c = ci->GetChannel();
+ if (!c)
return;
/* Mark the channel as persistent */
- if (ci->c->HasMode("PERM"))
+ if (c->HasMode("PERM"))
ci->SetPersist(true);
/* Persist may be in def cflags, set it here */
else if (ci->IsPersist())
- ci->c->SetMode(NULL, "PERM");
+ c->SetMode(NULL, "PERM");
}
void OnJoinChannel(User *u, Channel *c) override
{
- if (!c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci)
return;
- time_t ts = c->ci->GetChannelTS();
+ time_t ts = ci->GetChannelTS();
if (ts == 0)
- ts = c->ci->GetTimeRegistered();
+ ts = ci->GetTimeRegistered();
if (c->creation_time > ts)
{
diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp
index 686b97514..7d7f7c85d 100644
--- a/modules/chanserv/mode.cpp
+++ b/modules/chanserv/mode.cpp
@@ -270,7 +270,7 @@ class CommandCSMode : public Command
return source.AccessFor(ci).HasPriv(cm->name + (self ? "ME" : ""));
}
- void DoLock(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
+ void DoLock(CommandSource &source, ChanServ::Channel *ci, Channel *c, const std::vector<Anope::string> &params)
{
User *u = source.GetUser();
const Anope::string &subcommand = params[2];
@@ -340,7 +340,7 @@ class CommandCSMode : public Command
break;
}
- if (cm->type == MODE_LIST && ci->c && IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) >= IRCD->GetMaxListFor(ci->c))
+ if (cm->type == MODE_LIST && c && IRCD->GetMaxListFor(c) && c->HasMode(cm->name) >= IRCD->GetMaxListFor(c))
{
source.Reply(_("List for mode \002{0}\002 is full."), cm->mchar);
break;
@@ -386,8 +386,8 @@ class CommandCSMode : public Command
source.Reply(_("Nothing to do."));
}
- if (ci->c)
- ci->c->CheckModes();
+ if (c)
+ c->CheckModes();
}
else if (subcommand.equals_ci("DEL") && !param.empty())
{
@@ -489,7 +489,7 @@ class CommandCSMode : public Command
}
}
- void DoSet(CommandSource &source, ChanServ::Channel *ci, const std::vector<Anope::string> &params)
+ void DoSet(CommandSource &source, ChanServ::Channel *ci, Channel *c, const std::vector<Anope::string> &params)
{
User *u = source.GetUser();
@@ -512,7 +512,7 @@ class CommandCSMode : public Command
case '*':
if (adding == -1 || !has_access)
break;
- for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && ci->c; ++j)
+ for (unsigned j = 0; j < ModeManager::GetChannelModes().size() && c; ++j)
{
ChannelMode *cm = ModeManager::GetChannelModes()[j];
@@ -521,9 +521,9 @@ class CommandCSMode : public Command
if (cm->type == MODE_REGULAR || (!adding && cm->type == MODE_PARAM))
{
if (adding)
- ci->c->SetMode(NULL, cm);
+ c->SetMode(NULL, cm);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
}
}
}
@@ -540,9 +540,9 @@ class CommandCSMode : public Command
if (!has_access)
break;
if (adding)
- ci->c->SetMode(NULL, cm);
+ c->SetMode(NULL, cm);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
break;
case MODE_PARAM:
if (!has_access)
@@ -550,9 +550,9 @@ class CommandCSMode : public Command
if (adding && !sep.GetToken(param))
break;
if (adding)
- ci->c->SetMode(NULL, cm, param);
+ c->SetMode(NULL, cm, param);
else
- ci->c->RemoveMode(NULL, cm);
+ c->RemoveMode(NULL, cm);
break;
case MODE_STATUS:
{
@@ -569,7 +569,7 @@ class CommandCSMode : public Command
break;
}
- for (Channel::ChanUserList::const_iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
+ for (Channel::ChanUserList::const_iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
{
ChanUserContainer *uc = it->second;
@@ -584,9 +584,9 @@ class CommandCSMode : public Command
if (Anope::Match(uc->user->GetMask(), param))
{
if (adding)
- ci->c->SetMode(NULL, cm, uc->user->GetUID());
+ c->SetMode(NULL, cm, uc->user->GetUID());
else
- ci->c->RemoveMode(NULL, cm, uc->user->GetUID());
+ c->RemoveMode(NULL, cm, uc->user->GetUID());
}
}
}
@@ -622,9 +622,9 @@ class CommandCSMode : public Command
}
if (adding)
- ci->c->SetMode(NULL, cm, target->GetUID());
+ c->SetMode(NULL, cm, target->GetUID());
else
- ci->c->RemoveMode(NULL, cm, target->GetUID());
+ c->RemoveMode(NULL, cm, target->GetUID());
}
break;
}
@@ -635,15 +635,15 @@ class CommandCSMode : public Command
break;
if (adding)
{
- if (IRCD->GetMaxListFor(ci->c) && ci->c->HasMode(cm->name) < IRCD->GetMaxListFor(ci->c))
- ci->c->SetMode(NULL, cm, param);
+ if (IRCD->GetMaxListFor(c) && c->HasMode(cm->name) < IRCD->GetMaxListFor(c))
+ c->SetMode(NULL, cm, param);
}
else
{
- std::vector<Anope::string> v = ci->c->GetModeList(cm->name);
+ std::vector<Anope::string> v = c->GetModeList(cm->name);
for (unsigned j = 0; j < v.size(); ++j)
if (Anope::Match(v[j], param))
- ci->c->RemoveMode(NULL, cm, v[j]);
+ c->RemoveMode(NULL, cm, v[j]);
}
}
}
@@ -664,7 +664,7 @@ class CommandCSMode : public Command
new_params.push_back(params[0]);
new_params.push_back("SET");
new_params.push_back("-*");
- this->DoSet(source, ci, new_params);
+ this->DoSet(source, ci, ci->GetChannel(), new_params);
return;
}
@@ -697,7 +697,7 @@ class CommandCSMode : public Command
new_params.push_back("SET");
new_params.push_back("-" + stringify(cm->mchar));
new_params.push_back("*");
- this->DoSet(source, ci, new_params);
+ this->DoSet(source, ci, ci->GetChannel(), new_params);
}
public:
@@ -721,6 +721,8 @@ class CommandCSMode : public Command
return;
}
+ Channel *c = ci->GetChannel();
+
if (subcommand.equals_ci("LOCK") && params.size() > 2)
{
if (!source.AccessFor(ci).HasPriv("MODE") && !source.HasOverridePriv("chanserv/administration"))
@@ -729,15 +731,19 @@ class CommandCSMode : public Command
return;
}
- this->DoLock(source, ci, params);
+ this->DoLock(source, ci, c, params);
+ return;
}
- else if (!ci->c)
+
+ if (!c)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
+ return;
}
- else if (subcommand.equals_ci("SET") && params.size() > 2)
+
+ if (subcommand.equals_ci("SET") && params.size() > 2)
{
- this->DoSet(source, ci, params);
+ this->DoSet(source, ci, c, params);
}
else if (subcommand.equals_ci("CLEAR"))
{
@@ -807,7 +813,8 @@ class CommandCSModes : public Command
return;
}
- if (!ci->c)
+ Channel *c = ci->GetChannel();
+ if (!c)
{
source.Reply(_("Channel \002%s\002 doesn't exist."), ci->GetName());
return;
@@ -838,16 +845,16 @@ class CommandCSModes : public Command
}
}
- if (!ci->c->FindUser(targ))
+ if (!c->FindUser(targ))
{
source.Reply(_("User \002{0}\002 is not on channel \002{1}\002."), targ->nick, ci->GetName());
return;
}
if (m.first)
- ci->c->SetMode(NULL, m.second, targ->GetUID());
+ c->SetMode(NULL, m.second, targ->GetUID());
else
- ci->c->RemoveMode(NULL, m.second, targ->GetUID());
+ c->RemoveMode(NULL, m.second, targ->GetUID());
logger.Command(source, ci, _("{source} used {command} on {channel} on {3}"), targ->nick);
}
@@ -935,10 +942,10 @@ class CSMode : public Module
void OnCheckModes(Reference<Channel> &c) override
{
- if (!c || !c->ci)
+ if (!c || !c->GetChannel())
return;
- ModeLocks::ModeList locks = modelock.GetMLock(c->ci);
+ ModeLocks::ModeList locks = modelock.GetMLock(c->GetChannel());
for (ModeLock *ml : locks)
{
ChannelMode *cm = ModeManager::FindChannelModeByName(ml->GetName());
diff --git a/modules/chanserv/register.cpp b/modules/chanserv/register.cpp
index de3e555bc..00fc00927 100644
--- a/modules/chanserv/register.cpp
+++ b/modules/chanserv/register.cpp
@@ -107,9 +107,6 @@ class CommandCSRegister : public Command
ci->SetLastUsed(Anope::CurTime);
ci->SetBanType(2);
- ci->c = c;
- c->ci = ci;
-
if (c && !c->topic.empty())
{
ci->SetLastTopic(c->topic);
diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp
index b35d3ae51..bab6da8bc 100644
--- a/modules/chanserv/set.cpp
+++ b/modules/chanserv/set.cpp
@@ -384,8 +384,8 @@ class CommandCSSetKeepModes : public Command
ci->SetKeepModes(true);
source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), ci->GetName());
- if (ci->c)
- for (const std::pair<Anope::string, Anope::string> &p : ci->c->GetModes())
+ if (Channel *c = ci->GetChannel())
+ for (const std::pair<Anope::string, Anope::string> &p : c->GetModes())
{
ChanServ::Mode *mode = Serialize::New<ChanServ::Mode *>();
mode->SetChannel(ci);
@@ -538,10 +538,11 @@ class CommandCSSetPersist : public Command
ci->SetPersist(true);
/* Channel doesn't exist, create it */
- if (!ci->c)
+ Channel *c = ci->GetChannel();
+ if (!c)
{
bool created;
- Channel *c = Channel::FindOrCreate(ci->GetName(), created);
+ c = Channel::FindOrCreate(ci->GetName(), created);
if (ci->GetBot())
{
ChannelStatus status(BotModes());
@@ -554,8 +555,8 @@ class CommandCSSetPersist : public Command
/* Set the perm mode */
if (cm)
{
- if (ci->c && !ci->c->HasMode("PERM"))
- ci->c->SetMode(NULL, cm);
+ if (c && !c->HasMode("PERM"))
+ c->SetMode(NULL, cm);
/* Add it to the channels mlock */
if (mlocks)
mlocks->SetMLock(ci, cm, true, "", source.GetNick());
@@ -573,10 +574,10 @@ class CommandCSSetPersist : public Command
}
ChanServ->Assign(NULL, ci);
- if (!ci->c->FindUser(ChanServ))
+ if (!c->FindUser(ChanServ))
{
ChannelStatus status(BotModes());
- ChanServ->Join(ci->c, &status);
+ ChanServ->Join(c, &status);
}
}
}
@@ -597,8 +598,9 @@ class CommandCSSetPersist : public Command
/* Unset perm mode */
if (cm)
{
- if (ci->c && ci->c->HasMode("PERM"))
- ci->c->RemoveMode(NULL, cm);
+ Channel *c = ci->GetChannel();
+ if (c && c->HasMode("PERM"))
+ c->RemoveMode(NULL, cm);
/* Remove from mlock */
if (mlocks)
mlocks->RemoveMLock(ci, cm, true);
@@ -1130,17 +1132,20 @@ class CSSet : public Module
void OnChannelSync(Channel *c) override
{
- if (c->ci && c->ci->IsKeepModes())
- for (ChanServ::Mode *m : c->ci->GetRefs<ChanServ::Mode *>())
- c->SetMode(c->ci->WhoSends(), m->GetMode(), m->GetParam());
+ ChanServ::Channel *ci = c->GetChannel();
+ if (ci && ci->IsKeepModes())
+ for (ChanServ::Mode *m : ci->GetRefs<ChanServ::Mode *>())
+ c->SetMode(ci->WhoSends(), m->GetMode(), m->GetParam());
}
EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
- if (!c->ci || !c->ci->IsRestricted() || c->MatchesList(u, "EXCEPT"))
+ ChanServ::Channel *ci = c->GetChannel();
+
+ if (!ci || !ci->IsRestricted() || c->MatchesList(u, "EXCEPT"))
return EVENT_CONTINUE;
- if (c->ci->AccessFor(u).empty() && (!c->ci->GetFounder() || u->Account() != c->ci->GetFounder()))
+ if (ci->AccessFor(u).empty() && (!ci->GetFounder() || u->Account() != ci->GetFounder()))
return EVENT_STOP;
return EVENT_CONTINUE;
@@ -1148,30 +1153,32 @@ class CSSet : public Module
void OnDelChan(ChanServ::Channel *ci) override
{
- if (ci->c && ci->IsPersist())
+ Channel *c = ci->GetChannel();
+ if (c && ci->IsPersist())
{
- ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false);
+ c->RemoveMode(ci->WhoSends(), "PERM", "", false);
ci->SetPersist(false);
}
}
EventReturn OnChannelModeSet(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
- if (c->ci)
- {
- /* Channel mode +P or so was set, mark this channel as persistent */
- if (mode->name == "PERM")
- c->ci->SetPersist(true);
+ ChanServ::Channel *ci = c->GetChannel();
+ if (ci == nullptr)
+ return EVENT_CONTINUE;
- if (mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c)))
+ /* Channel mode +P or so was set, mark this channel as persistent */
+ if (mode->name == "PERM")
+ ci->SetPersist(true);
+
+ if (mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c)))
+ {
+ ChanServ::Mode *m = Serialize::New<ChanServ::Mode *>();
+ if (m != nullptr)
{
- ChanServ::Mode *m = Serialize::New<ChanServ::Mode *>();
- if (m != nullptr)
- {
- m->SetChannel(c->ci);
- m->SetMode(mode->name);
- m->SetParam(param);
- }
+ m->SetChannel(ci);
+ m->SetMode(mode->name);
+ m->SetParam(param);
}
}
@@ -1180,14 +1187,16 @@ class CSSet : public Module
EventReturn OnChannelModeUnset(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string &param) override
{
+ ChanServ::Channel *ci = c->GetChannel();
+
if (mode->name == "PERM")
{
- if (c->ci)
- c->ci->SetPersist(false);
+ if (ci)
+ ci->SetPersist(false);
}
- if (c->ci && mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c)))
- for (ChanServ::Mode *m : c->ci->GetRefs<ChanServ::Mode *>())
+ if (ci && mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c)))
+ for (ChanServ::Mode *m : ci->GetRefs<ChanServ::Mode *>())
if (m->GetMode() == mode->name && m->GetParam().equals_ci(param))
m->Delete();
@@ -1196,10 +1205,12 @@ class CSSet : public Module
void OnJoinChannel(User *u, Channel *c) override
{
- if (persist_lower_ts && c->ci && c->ci->IsPersist() && c->creation_time > c->ci->GetTimeRegistered())
+ ChanServ::Channel *ci = c->GetChannel();
+
+ if (persist_lower_ts && ci && ci->IsPersist() && c->creation_time > ci->GetTimeRegistered())
{
- logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, c->ci->GetTimeRegistered());
- c->creation_time = c->ci->GetTimeRegistered();
+ logger.Debug("Changing TS of {0} from {1} to {2}", c->name, c->creation_time, ci->GetTimeRegistered());
+ c->creation_time = ci->GetTimeRegistered();
IRCD->Send<messages::MessageChannel>(c);
c->Reset();
}
@@ -1207,14 +1218,15 @@ class CSSet : public Module
void OnSetCorrectModes(User *user, Channel *chan, ChanServ::AccessGroup &access, bool &give_modes, bool &take_modes) override
{
- if (chan->ci)
- {
- if (chan->ci->IsNoAutoop())
- give_modes = false;
- if (chan->ci->IsSecureOps() && !user->HasPriv("chanserv/administration"))
- // This overrides what chanserv does because it is loaded after chanserv
- take_modes = true;
- }
+ ChanServ::Channel *ci = chan->GetChannel();
+ if (ci == nullptr)
+ return;
+
+ if (ci->IsNoAutoop())
+ give_modes = false;
+ if (ci->IsSecureOps() && !user->HasPriv("chanserv/administration"))
+ // This overrides what chanserv does because it is loaded after chanserv
+ take_modes = true;
}
void OnPreChanExpire(ChanServ::Channel *ci, bool &expire) override
diff --git a/modules/chanserv/statusupdate.cpp b/modules/chanserv/statusupdate.cpp
index 32918f1d3..90586daea 100644
--- a/modules/chanserv/statusupdate.cpp
+++ b/modules/chanserv/statusupdate.cpp
@@ -25,10 +25,11 @@ class StatusUpdate : public Module
{
void ApplyModes(ChanServ::Channel *ci, ChanServ::ChanAccess *access, bool set)
{
- if (ci->c == nullptr)
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
return;
- 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)
{
User *user = it->second->user;
@@ -40,11 +41,11 @@ class StatusUpdate : public Module
{
ChannelModeStatus *cms = ModeManager::GetStatusChannelModesByRank()[i];
if (!ag.HasPriv("AUTO" + cms->name))
- ci->c->RemoveMode(NULL, cms, user->GetUID());
+ c->RemoveMode(NULL, cms, user->GetUID());
}
if (set)
- ci->c->SetCorrectModes(user, true);
+ c->SetCorrectModes(user, true);
}
}
}
diff --git a/modules/chanserv/suspend.cpp b/modules/chanserv/suspend.cpp
index e730ddf49..2d72924e3 100644
--- a/modules/chanserv/suspend.cpp
+++ b/modules/chanserv/suspend.cpp
@@ -173,11 +173,11 @@ class CommandCSSuspend : public Command
si->SetWhen(Anope::CurTime);
si->SetExpires(expiry_secs ? expiry_secs + Anope::CurTime : 0);
- if (ci->c)
+ if (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;
@@ -186,7 +186,7 @@ class CommandCSSuspend : public Command
}
for (unsigned i = 0; i < users.size(); ++i)
- ci->c->Kick(NULL, users[i], !reason.empty() ? reason : Language::Translate(users[i], _("This channel has been suspended.")));
+ c->Kick(NULL, users[i], !reason.empty() ? reason : Language::Translate(users[i], _("This channel has been suspended.")));
}
logger.Admin(source, ci, _("{source} used {command} on {channel} ({0}), expires on {1}"),
@@ -329,7 +329,8 @@ class CSSuspend : public Module
EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override
{
- if (u->HasMode("OPER") || !c->ci || !c->ci->GetRef<CSSuspendInfo *>())
+ ChanServ::Channel *ci = c->GetChannel();
+ if (u->HasMode("OPER") || !ci || !ci->GetRef<CSSuspendInfo *>())
return EVENT_CONTINUE;
reason = Language::Translate(u, _("This channel may not be used."));
diff --git a/modules/chanserv/sync.cpp b/modules/chanserv/sync.cpp
index 117003577..0ff7ebdd0 100644
--- a/modules/chanserv/sync.cpp
+++ b/modules/chanserv/sync.cpp
@@ -39,7 +39,8 @@ class CommandCSSync : public Command
return;
}
- if (ci->c == NULL)
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
@@ -53,8 +54,8 @@ class CommandCSSync : public Command
logger.Command(source, ci, _("{source} used {command} on {channel}"));
- for (Channel::ChanUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
- ci->c->SetCorrectModes(it->second->user, true);
+ for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it)
+ c->SetCorrectModes(it->second->user, true);
source.Reply(_("All user modes on \002{0}\002 have been synced."));
}
diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp
index 93c990507..85bcf1426 100644
--- a/modules/chanserv/topic.cpp
+++ b/modules/chanserv/topic.cpp
@@ -129,7 +129,7 @@ class CommandCSTopic : public Command
{
bool has_topiclock = ci->IsTopicLock();
ci->SetTopicLock(false);
- ci->c->ChangeTopic(source.GetNick(), topic, Anope::CurTime);
+ ci->GetChannel()->ChangeTopic(source.GetNick(), topic, Anope::CurTime);
if (has_topiclock)
ci->SetTopicLock(true);
@@ -144,9 +144,9 @@ class CommandCSTopic : public Command
const Anope::string &topic = params[2];
Anope::string new_topic;
- if (!ci->c->topic.empty())
+ if (!ci->GetChannel()->topic.empty())
{
- new_topic = ci->c->topic + " " + topic;
+ new_topic = ci->GetChannel()->topic + " " + topic;
ci->SetLastTopic("");
}
else
@@ -192,7 +192,7 @@ class CommandCSTopic : public Command
{
this->Unlock(source, ci, params);
}
- else if (!ci->c)
+ else if (!ci->GetChannel())
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
}
@@ -256,21 +256,23 @@ class CSTopic : public Module
void OnChannelSync(Channel *c) override
{
- if (c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci)
+ return;
+
+ /* Update channel topic */
+ if ((ci->IsTopicLock() || ci->IsKeepTopic()) && ci->GetLastTopic() != c->topic)
{
- /* Update channel topic */
- if ((c->ci->IsTopicLock() || c->ci->IsKeepTopic()) && c->ci->GetLastTopic() != c->topic)
- {
- ServiceBot *sender = c->ci->WhoSends();
- c->ChangeTopic(!c->ci->GetLastTopicSetter().empty() ? c->ci->GetLastTopicSetter() : (sender ? sender->nick : Me->GetName()),
- c->ci->GetLastTopic(), c->ci->GetLastTopicTime() ? c->ci->GetLastTopicTime() : Anope::CurTime);
- }
+ ServiceBot *sender = ci->WhoSends();
+ c->ChangeTopic(!ci->GetLastTopicSetter().empty() ? ci->GetLastTopicSetter() : (sender ? sender->nick : Me->GetName()),
+ ci->GetLastTopic(), ci->GetLastTopicTime() ? ci->GetLastTopicTime() : Anope::CurTime);
}
}
void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) override
{
- if (!c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci)
return;
/* We only compare the topics here, not the time or setter. This is because some (old) IRCds do not
@@ -278,15 +280,15 @@ class CSTopic : public Module
* This desyncs what is really set with what we have stored, and we end up resetting the topic often when
* it is not required
*/
- if (c->ci->IsTopicLock() && c->ci->GetLastTopic() != c->topic && (!source || !c->ci->AccessFor(source).HasPriv("TOPIC")))
+ if (ci->IsTopicLock() && ci->GetLastTopic() != c->topic && (!source || !ci->AccessFor(source).HasPriv("TOPIC")))
{
- c->ChangeTopic(c->ci->GetLastTopicSetter(), c->ci->GetLastTopic(), c->ci->GetLastTopicTime());
+ c->ChangeTopic(ci->GetLastTopicSetter(), ci->GetLastTopic(), ci->GetLastTopicTime());
}
else
{
- c->ci->SetLastTopic(c->topic);
- c->ci->SetLastTopicSetter(c->topic_setter);
- c->ci->SetLastTopicTime(c->topic_ts);
+ ci->SetLastTopic(c->topic);
+ ci->SetLastTopicSetter(c->topic_setter);
+ ci->SetLastTopicTime(c->topic_ts);
}
}
@@ -298,7 +300,8 @@ class CSTopic : public Module
info.AddOption(_("Topic lock"));
ModeLock *secret = mlocks ? mlocks->GetMLock(ci, "SECRET") : nullptr;
- if (!ci->GetLastTopic().empty() && (show_all || ((!secret || secret->GetSet() == false) && (!ci->c || !ci->c->HasMode("SECRET")))))
+ Channel *c = ci->GetChannel();
+ if (!ci->GetLastTopic().empty() && (show_all || ((!secret || secret->GetSet() == false) && (!c || !c->HasMode("SECRET")))))
{
info[_("Last topic")] = ci->GetLastTopic();
info[_("Topic set by")] = ci->GetLastTopicSetter();
diff --git a/modules/chanserv/unban.cpp b/modules/chanserv/unban.cpp
index 56d13758d..716b2f576 100644
--- a/modules/chanserv/unban.cpp
+++ b/modules/chanserv/unban.cpp
@@ -46,11 +46,11 @@ class CommandCSUnban : public Command
for (ChanServ::Channel *ci : source.GetAccount()->GetRefs<ChanServ::Channel *>())
{
- if (!ci->c || !source.AccessFor(ci).HasPriv("UNBAN"))
+ if (!ci->GetChannel() || !source.AccessFor(ci).HasPriv("UNBAN"))
continue;
for (unsigned int j = 0; j < modes.size(); ++j)
- if (ci->c->Unban(source.GetUser(), modes[j]->name, true))
+ if (ci->GetChannel()->Unban(source.GetUser(), modes[j]->name, true))
++count;
}
@@ -68,7 +68,7 @@ class CommandCSUnban : public Command
return;
}
- if (ci->c == NULL)
+ if (ci->GetChannel() == NULL)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
@@ -94,12 +94,12 @@ class CommandCSUnban : public Command
logger.Command(source, _("{source} used {command} on {channel} to unban {0}"), u2->nick);
for (unsigned i = 0; i < modes.size(); ++i)
- ci->c->Unban(u2, modes[i]->name, source.GetUser() == u2);
+ ci->GetChannel()->Unban(u2, modes[i]->name, source.GetUser() == u2);
if (u2 == source.GetUser())
- source.Reply(_("You have been unbanned from \002{0}\002."), ci->c->name);
+ source.Reply(_("You have been unbanned from \002{0}\002."), ci->GetChannel()->name);
else
- source.Reply(_("\002{0}\002 has been unbanned from \002{1}\002."), u2->nick, ci->c->name);
+ source.Reply(_("\002{0}\002 has been unbanned from \002{1}\002."), u2->nick, ci->GetChannel()->name);
}
bool OnHelp(CommandSource &source, const Anope::string &subcommand) override
diff --git a/modules/chanserv/updown.cpp b/modules/chanserv/updown.cpp
index 0909fa35c..44dd9dc55 100644
--- a/modules/chanserv/updown.cpp
+++ b/modules/chanserv/updown.cpp
@@ -23,14 +23,15 @@ class CommandCSUp : public Command
{
void SetModes(User *u, Channel *c)
{
- if (!c->ci)
+ ChanServ::Channel *ci = c->GetChannel();
+ if (!ci)
return;
/* whether or not we are giving modes */
bool giving = true;
/* whether or not we have given a mode */
bool given = false;
- ChanServ::AccessGroup u_access = c->ci->AccessFor(u);
+ ChanServ::AccessGroup u_access = ci->AccessFor(u);
for (unsigned i = 0; i < ModeManager::GetStatusChannelModesByRank().size(); ++i)
{
@@ -83,7 +84,8 @@ class CommandCSUp : public Command
return;
}
- if (ci->c == NULL)
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
@@ -91,7 +93,6 @@ class CommandCSUp : public Command
User *u = User::Find(nick, true);
User *srcu = source.GetUser();
- Channel *c = ci->c;
if (u == NULL)
{
@@ -111,9 +112,9 @@ class CommandCSUp : public Command
return;
}
- if (source.GetUser() && u != source.GetUser() && c->ci->IsPeace())
+ if (source.GetUser() && u != source.GetUser() && ci->IsPeace())
{
- if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser()))
+ if (ci->AccessFor(u) >= ci->AccessFor(source.GetUser()))
{
if (!source.HasOverridePriv("chanserv/administration"))
{
@@ -179,15 +180,14 @@ class CommandCSDown : public Command
return;
}
- if (ci->c == NULL)
+ Channel *c = ci->GetChannel();
+ if (c == nullptr)
{
source.Reply(_("Channel \002{0}\002 doesn't exist."), ci->GetName());
return;
}
User *u = User::Find(nick, true);
- Channel *c = ci->c;
-
User *srcu = source.GetUser();
if (u == NULL)
@@ -208,9 +208,9 @@ class CommandCSDown : public Command
return;
}
- if (source.GetUser() && u != source.GetUser() && c->ci->IsPeace())
+ if (source.GetUser() && u != source.GetUser() && ci->IsPeace())
{
- if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser()))
+ if (ci->AccessFor(u) >= ci->AccessFor(source.GetUser()))
{
if (!source.HasPriv("chanserv/administration"))
{