From a635344582a13d935631fbe930d79d3788359c8a Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 25 Nov 2016 16:35:10 -0500 Subject: Rename most ext fields names to be consistent with everything else, add accessors for many --- modules/chanserv/akick.cpp | 22 ++-- modules/chanserv/ban.cpp | 14 ++- modules/chanserv/drop.cpp | 4 +- modules/chanserv/enforce.cpp | 6 +- modules/chanserv/kick.cpp | 14 ++- modules/chanserv/list.cpp | 16 ++- modules/chanserv/log.cpp | 8 +- modules/chanserv/main/chanaccess.cpp | 6 +- modules/chanserv/main/chanaccesstype.h | 4 +- modules/chanserv/main/channel.cpp | 178 +++++++++++++++++++++++++++++++-- modules/chanserv/main/channel.h | 78 +++++++++++++-- modules/chanserv/main/channeltype.cpp | 18 +++- modules/chanserv/main/channeltype.h | 6 +- modules/chanserv/main/chanserv.cpp | 19 ++-- modules/chanserv/mode.cpp | 14 +-- modules/chanserv/register.cpp | 2 +- modules/chanserv/seen.cpp | 2 +- modules/chanserv/set.cpp | 115 ++++++++++----------- modules/chanserv/set_misc.cpp | 2 +- modules/chanserv/topic.cpp | 31 +++--- modules/chanserv/updown.cpp | 4 +- 21 files changed, 392 insertions(+), 171 deletions(-) (limited to 'modules/chanserv') diff --git a/modules/chanserv/akick.cpp b/modules/chanserv/akick.cpp index d253d6fb5..1930cb20b 100644 --- a/modules/chanserv/akick.cpp +++ b/modules/chanserv/akick.cpp @@ -58,10 +58,10 @@ class AutoKickImpl : public AutoKick class AutoKickType : public Serialize::Type { public: - Serialize::ObjectField ci; + Serialize::ObjectField channel; Serialize::Field mask; - Serialize::ObjectField nc; + Serialize::ObjectField account; Serialize::Field reason; Serialize::Field creator; @@ -70,9 +70,9 @@ class AutoKickType : public Serialize::Type AutoKickType(Module *me) : Serialize::Type(me) - , ci(this, "ci", &AutoKickImpl::channel, true) + , channel(this, "channel", &AutoKickImpl::channel, true) , mask(this, "mask", &AutoKickImpl::mask) - , nc(this, "nc", &AutoKickImpl::account, true) + , account(this, "account", &AutoKickImpl::account, true) , reason(this, "reason", &AutoKickImpl::reason) , creator(this, "creator", &AutoKickImpl::creator) , addtime(this, "addtime", &AutoKickImpl::addtime) @@ -83,12 +83,12 @@ class AutoKickType : public Serialize::Type ChanServ::Channel *AutoKickImpl::GetChannel() { - return Get(&AutoKickType::ci); + return Get(&AutoKickType::channel); } void AutoKickImpl::SetChannel(ChanServ::Channel *ci) { - Set(&AutoKickType::ci, ci); + Set(&AutoKickType::channel, ci); } Anope::string AutoKickImpl::GetMask() @@ -103,12 +103,12 @@ void AutoKickImpl::SetMask(const Anope::string &mask) NickServ::Account *AutoKickImpl::GetAccount() { - return Get(&AutoKickType::nc); + return Get(&AutoKickType::account); } void AutoKickImpl::SetAccount(NickServ::Account *nc) { - Set(&AutoKickType::nc, nc); + Set(&AutoKickType::account, nc); } Anope::string AutoKickImpl::GetReason() @@ -170,7 +170,7 @@ class CommandCSAKick : public Command { /* Also don't try to complete the mask if this is a channel */ - if (mask.equals_ci(ci->GetName()) && ci->HasFieldS("PEACE")) + if (mask.equals_ci(ci->GetName()) && ci->IsPeace()) { source.Reply(_("Access denied.")); return; @@ -232,7 +232,7 @@ class CommandCSAKick : public Command ; /* Check whether target nick has equal/higher access * or whether the mask matches a user with higher/equal access - Viper */ - else if (ci->HasFieldS("PEACE") && nc) + else if (ci->IsPeace() && nc) { ChanServ::AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci); if (nc == ci->GetFounder() || nc_access >= u_access) @@ -241,7 +241,7 @@ class CommandCSAKick : public Command return; } } - else if (ci->HasFieldS("PEACE")) + else if (ci->IsPeace()) { #warning "peace" #if 0 diff --git a/modules/chanserv/ban.cpp b/modules/chanserv/ban.cpp index 552ef03bf..44e2752a5 100644 --- a/modules/chanserv/ban.cpp +++ b/modules/chanserv/ban.cpp @@ -127,7 +127,7 @@ class CommandCSBan : public Command { ChanServ::AccessGroup u2_access = ci->AccessFor(u2); - if (u != u2 && ci->HasFieldS("PEACE") && u2_access >= u_access && !source.HasPriv("chanserv/kick")) + if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasPriv("chanserv/kick")) { source.Reply(_("Access denied. \002{0}\002 has the same or more privileges than you on \002{1}\002."), u2->nick, ci->GetName()); return; @@ -151,7 +151,7 @@ class CommandCSBan : public Command Anope::string mask = ci->GetIdealBan(u2); - bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->HasFieldS("PEACE") && u2_access >= u_access); + bool override = !u_access.HasPriv("BAN") || (u != u2 && ci->IsPeace() && u2_access >= u_access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << mask; if (!c->HasMode(mode, mask)) @@ -170,13 +170,15 @@ class CommandCSBan : public Command if (block->Get("kick", "yes")) { - if (ci->HasFieldS("SIGNKICK") || (ci->HasFieldS("SIGNKICK_LEVEL") && !source.AccessFor(ci).HasPriv("SIGNKICK"))) + if (ci->IsSignKick() || (ci->IsSignKickLevel() && !source.AccessFor(ci).HasPriv("SIGNKICK"))) { signkickformat = signkickformat.replace_all_cs("%m", reason); c->Kick(ci->WhoSends(), u2, "%s", signkickformat.c_str()); } else + { c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + } } } else @@ -213,7 +215,7 @@ class CommandCSBan : public Command if (matched > 1 && !founder) continue; - if (u != uc->user && ci->HasFieldS("PEACE") && u2_access >= u_access) + if (u != uc->user && ci->IsPeace() && u2_access >= u_access) continue; else if (ci->c->MatchesList(uc->user, "EXCEPT")) continue; @@ -224,14 +226,16 @@ class CommandCSBan : public Command { ++kicked; - if (ci->HasFieldS("SIGNKICK") || (ci->HasFieldS("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) + if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) { reason += " (Matches " + mask + ")"; signkickformat = signkickformat.replace_all_cs("%m", reason); c->Kick(ci->WhoSends(), uc->user, "%s", signkickformat.c_str()); } else + { c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), mask.c_str()); + } } } } diff --git a/modules/chanserv/drop.cpp b/modules/chanserv/drop.cpp index 1bc880ae9..77ab7e55e 100644 --- a/modules/chanserv/drop.cpp +++ b/modules/chanserv/drop.cpp @@ -52,7 +52,7 @@ class CommandCSDrop : public Command return; } - if ((ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) + if ((ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -62,7 +62,7 @@ class CommandCSDrop : public Command if (MOD_RESULT == EVENT_STOP) return; - bool override = (ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); + bool override = (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->GetDisplay() : "none") << ")"; Reference c = ci->c; diff --git a/modules/chanserv/enforce.cpp b/modules/chanserv/enforce.cpp index 5a57d3cc2..c2a9fbe2d 100644 --- a/modules/chanserv/enforce.cpp +++ b/modules/chanserv/enforce.cpp @@ -32,8 +32,8 @@ class CommandCSEnforce : public Command * part of the code. This way we can enforce SECUREOPS even * if it's off. */ - bool hadsecureops = ci->HasFieldS("SECUREOPS"); - ci->SetS("SECUREOPS", true); + 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) { @@ -43,7 +43,7 @@ class CommandCSEnforce : public Command } if (!hadsecureops) - ci->UnsetS("SECUREOPS"); + ci->SetSecureOps(false); source.Reply(_("\002Secureops\002 enforced on \002{0}\002."), ci->GetName()); } diff --git a/modules/chanserv/kick.cpp b/modules/chanserv/kick.cpp index 4752d5940..a1ac7f62f 100644 --- a/modules/chanserv/kick.cpp +++ b/modules/chanserv/kick.cpp @@ -70,7 +70,7 @@ class CommandCSKick : public Command if (u2) { ChanServ::AccessGroup u2_access = ci->AccessFor(u2); - if (u != u2 && ci->HasFieldS("PEACE") && u2_access >= u_access && !source.HasPriv("chanserv/kick")) + if (u != u2 && ci->IsPeace() && u2_access >= u_access && !source.HasPriv("chanserv/kick")) source.Reply(_("Access denied. \002{0}\002 has the same or more privileges than you on \002{1}\002."), u2->nick, ci->GetName()); else if (u2->IsProtected()) source.Reply(_("Access denied. \002{0}\002 is protected and can not be kicked."), u2->nick); @@ -78,16 +78,18 @@ class CommandCSKick : public Command source.Reply(_("User \002{0}\002 is not on channel \002{1}\002."), u2->nick, c->name); else { - bool override = !u_access.HasPriv("KICK") || (u != u2 && ci->HasFieldS("PEACE") && u2_access >= u_access); + bool override = !u_access.HasPriv("KICK") || (u != u2 && ci->IsPeace() && u2_access >= u_access); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << u2->nick; - if (ci->HasFieldS("SIGNKICK") || (ci->HasFieldS("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) + if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) { signkickformat = signkickformat.replace_all_cs("%m", reason); c->Kick(ci->WhoSends(), u2, "%s", signkickformat.c_str()); } else + { c->Kick(ci->WhoSends(), u2, "%s", reason.c_str()); + } } } else if (u_access.HasPriv("FOUNDER")) @@ -108,21 +110,23 @@ class CommandCSKick : public Command ++matched; ChanServ::AccessGroup u2_access = ci->AccessFor(uc->user); - if (u != uc->user && ci->HasFieldS("PEACE") && u2_access >= u_access) + if (u != uc->user && ci->IsPeace() && u2_access >= u_access) continue; else if (uc->user->IsProtected()) continue; ++kicked; - if (ci->HasFieldS("SIGNKICK") || (ci->HasFieldS("SIGNKICK_LEVEL") && !u_access.HasPriv("SIGNKICK"))) + if (ci->IsSignKick() || (ci->IsSignKickLevel() && !u_access.HasPriv("SIGNKICK"))) { reason += " (Matches " + mask + ")"; signkickformat = signkickformat.replace_all_cs("%m", reason); c->Kick(ci->WhoSends(), uc->user, "%s", signkickformat.c_str()); } else + { c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), mask.c_str()); + } } } diff --git a/modules/chanserv/list.cpp b/modules/chanserv/list.cpp index c76d8661c..a60ae786c 100644 --- a/modules/chanserv/list.cpp +++ b/modules/chanserv/list.cpp @@ -85,7 +85,6 @@ class CommandCSList : public Command ListFormatter list(source.GetAccount()); list.AddColumn(_("Name")).AddColumn(_("Description")); - // XXX wtf Anope::map ordered_map; if (ChanServ::service) for (auto& it : ChanServ::service->GetChannels()) @@ -97,7 +96,7 @@ class CommandCSList : public Command if (!is_servadmin) { - if (ci->HasFieldS("CS_PRIVATE") || ci->HasFieldS("CS_SUSPENDED")) + if (ci->IsPrivate() || ci->HasFieldS("CS_SUSPENDED")) continue; if (ci->c && ci->c->HasMode("SECRET")) continue; @@ -113,7 +112,7 @@ class CommandCSList : public Command if (suspended && !ci->HasFieldS("CS_SUSPENDED")) continue; - if (channoexpire && !ci->HasFieldS("CS_NO_EXPIRE")) + if (channoexpire && !ci->IsNoExpire()) continue; if (pattern.equals_ci(ci->GetName()) || ci->GetName().equals_ci(spattern) || Anope::Match(ci->GetName(), pattern, false, true) || Anope::Match(ci->GetName(), spattern, false, true) || Anope::Match(ci->GetDesc(), pattern, false, true) || Anope::Match(ci->GetLastTopic(), pattern, false, true)) @@ -121,7 +120,7 @@ class CommandCSList : public Command if (((count + 1 >= from && count + 1 <= to) || (!from && !to)) && ++nchans <= listmax) { bool isnoexpire = false; - if (is_servadmin && (ci->HasFieldS("CS_NO_EXPIRE"))) + if (is_servadmin && ci->IsNoExpire()) isnoexpire = true; ListFormatter::ListEntry entry; @@ -217,13 +216,13 @@ class CommandCSSetPrivate : public Command if (params[1].equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable private"; - ci->SetS("CS_PRIVATE", true); + ci->SetPrivate(true); source.Reply(_("Private option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable private"; - ci->UnsetS("CS_PRIVATE"); + ci->SetPrivate(false); source.Reply(_("Private option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -252,14 +251,11 @@ class CSList : public Module CommandCSList commandcslist; CommandCSSetPrivate commandcssetprivate; - Serialize::Field priv; - public: CSList(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR) , EventHook(this) , commandcslist(this) , commandcssetprivate(this) - , priv(this, "CS_PRIVATE") { } @@ -268,7 +264,7 @@ class CSList : public Module if (!show_all) return; - if (priv.HasExt(ci)) + if (ci->IsPrivate()) info.AddOption(_("Private")); } }; diff --git a/modules/chanserv/log.cpp b/modules/chanserv/log.cpp index 32025e6b0..b62e03d0e 100644 --- a/modules/chanserv/log.cpp +++ b/modules/chanserv/log.cpp @@ -61,12 +61,12 @@ class LogSettingImpl : public LogSetting class LogSettingType : public Serialize::Type { public: - Serialize::ObjectField ci; + Serialize::ObjectField channel; Serialize::Field service_name, command_service, command_name, method, extra, creator; Serialize::Field created; LogSettingType(Module *me) : Serialize::Type(me) - , ci(this, "ci", &LogSettingImpl::channel, true) + , channel(this, "channel", &LogSettingImpl::channel, true) , service_name(this, "service_name", &LogSettingImpl::service_name) , command_service(this, "command_service", &LogSettingImpl::command_service) , command_name(this, "command_name", &LogSettingImpl::command_name) @@ -80,12 +80,12 @@ class LogSettingType : public Serialize::Type ChanServ::Channel *LogSettingImpl::GetChannel() { - return Get(&LogSettingType::ci); + return Get(&LogSettingType::channel); } void LogSettingImpl::SetChannel(ChanServ::Channel *ci) { - Set(&LogSettingType::ci, ci); + Set(&LogSettingType::channel, ci); } Anope::string LogSettingImpl::GetServiceName() diff --git a/modules/chanserv/main/chanaccess.cpp b/modules/chanserv/main/chanaccess.cpp index bf05cdf8b..75c70ed9c 100644 --- a/modules/chanserv/main/chanaccess.cpp +++ b/modules/chanserv/main/chanaccess.cpp @@ -23,12 +23,12 @@ ChanServ::Channel *ChanAccessImpl::GetChannel() { - return Get(&ChanAccessType::ci); + return Get(&ChanAccessType::channel); } -void ChanAccessImpl::SetChannel(ChanServ::Channel *ci) +void ChanAccessImpl::SetChannel(ChanServ::Channel *channel) { - Object::Set(&ChanAccessType::ci, ci); + Object::Set(&ChanAccessType::channel, channel); } Anope::string ChanAccessImpl::GetCreator() diff --git a/modules/chanserv/main/chanaccesstype.h b/modules/chanserv/main/chanaccesstype.h index c755a7df5..b93747be7 100644 --- a/modules/chanserv/main/chanaccesstype.h +++ b/modules/chanserv/main/chanaccesstype.h @@ -23,7 +23,7 @@ class ChanAccessType : public Serialize::Type static_assert(std::is_base_of::value, ""); public: - Serialize::ObjectField ci; + Serialize::ObjectField channel; Serialize::Field mask; Serialize::ObjectField obj; Serialize::Field creator; @@ -31,7 +31,7 @@ class ChanAccessType : public Serialize::Type Serialize::Field created; ChanAccessType(Module *me) : Serialize::Type(me) - , ci(this, "ci", &ChanServ::ChanAccess::channel, true) + , channel(this, "channel", &ChanServ::ChanAccess::channel, true) , mask(this, "mask", &ChanServ::ChanAccess::mask) , obj(this, "obj", &ChanServ::ChanAccess::object, true) , creator(this, "creator", &ChanServ::ChanAccess::creator) diff --git a/modules/chanserv/main/channel.cpp b/modules/chanserv/main/channel.cpp index 67a4c94ec..a35c80901 100644 --- a/modules/chanserv/main/channel.cpp +++ b/modules/chanserv/main/channel.cpp @@ -76,7 +76,7 @@ time_t ChannelImpl::GetTimeRegistered() return Get(&ChannelType::time_registered); } -void ChannelImpl::SetTimeRegistered(const time_t &t) +void ChannelImpl::SetTimeRegistered(time_t t) { Set(&ChannelType::time_registered, t); } @@ -86,7 +86,7 @@ time_t ChannelImpl::GetLastUsed() return Get(&ChannelType::last_used); } -void ChannelImpl::SetLastUsed(const time_t &t) +void ChannelImpl::SetLastUsed(time_t t) { Set(&ChannelType::last_used, t); } @@ -116,7 +116,7 @@ time_t ChannelImpl::GetLastTopicTime() return Get(&ChannelType::last_topic_time); } -void ChannelImpl::SetLastTopicTime(const time_t &t) +void ChannelImpl::SetLastTopicTime(time_t t) { Set(&ChannelType::last_topic_time, t); } @@ -126,7 +126,7 @@ int16_t ChannelImpl::GetBanType() return Get(&ChannelType::bantype); } -void ChannelImpl::SetBanType(const int16_t &i) +void ChannelImpl::SetBanType(int16_t i) { Set(&ChannelType::bantype, i); } @@ -136,19 +136,19 @@ time_t ChannelImpl::GetBanExpire() return Get(&ChannelType::banexpire); } -void ChannelImpl::SetBanExpire(const time_t &t) +void ChannelImpl::SetBanExpire(time_t t) { Set(&ChannelType::banexpire, t); } BotInfo *ChannelImpl::GetBI() { - return Get(&ChannelType::bi); + return Get(&ChannelType::servicebot); } void ChannelImpl::SetBI(BotInfo *bi) { - Set(&ChannelType::bi, bi); + Set(&ChannelType::servicebot, bi); } ServiceBot *ChannelImpl::GetBot() @@ -187,6 +187,166 @@ NickServ::Account *ChannelImpl::GetSuccessor() return Get(&ChannelType::successor); } +bool ChannelImpl::IsGreet() +{ + return Get(&ChannelType::greet); +} + +void ChannelImpl::SetGreet(bool greet) +{ + Set(&ChannelType::greet, greet); +} + +bool ChannelImpl::IsFantasy() +{ + return Get(&ChannelType::fantasy); +} + +void ChannelImpl::SetFantasy(bool fantasy) +{ + Set(&ChannelType::fantasy, fantasy); +} + +bool ChannelImpl::IsNoAutoop() +{ + return Get(&ChannelType::noautoop); +} + +void ChannelImpl::SetNoAutoop(bool noautoop) +{ + Set(&ChannelType::noautoop, noautoop); +} + +bool ChannelImpl::IsPeace() +{ + return Get(&ChannelType::peace); +} + +void ChannelImpl::SetPeace(bool peace) +{ + Set(&ChannelType::peace, peace); +} + +bool ChannelImpl::IsSecureFounder() +{ + return Get(&ChannelType::securefounder); +} + +void ChannelImpl::SetSecureFounder(bool securefounder) +{ + Set(&ChannelType::securefounder, securefounder); +} + +bool ChannelImpl::IsRestricted() +{ + return Get(&ChannelType::restricted); +} + +void ChannelImpl::SetRestricted(bool restricted) +{ + Set(&ChannelType::restricted, restricted); +} + +bool ChannelImpl::IsSecure() +{ + return Get(&ChannelType::secure); +} + +void ChannelImpl::SetSecure(bool secure) +{ + Set(&ChannelType::secure, secure); +} + +bool ChannelImpl::IsSecureOps() +{ + return Get(&ChannelType::secureops); +} + +void ChannelImpl::SetSecureOps(bool secureops) +{ + Set(&ChannelType::secureops, secureops); +} + +bool ChannelImpl::IsSignKick() +{ + return Get(&ChannelType::signkick); +} + +void ChannelImpl::SetSignKick(bool signkick) +{ + Set(&ChannelType::signkick, signkick); +} + +bool ChannelImpl::IsSignKickLevel() +{ + return Get(&ChannelType::signkicklevel); +} + +void ChannelImpl::SetSignKickLevel(bool signkicklevel) +{ + Set(&ChannelType::signkicklevel, signkicklevel); +} + +bool ChannelImpl::IsNoExpire() +{ + return Get(&ChannelType::noexpire); +} + +void ChannelImpl::SetNoExpire(bool noexpire) +{ + Set(&ChannelType::noexpire, noexpire); +} + +bool ChannelImpl::IsKeepModes() +{ + return Get(&ChannelType::keepmodes); +} + +void ChannelImpl::SetKeepModes(bool keepmodes) +{ + Set(&ChannelType::keepmodes, keepmodes); +} + +bool ChannelImpl::IsPersist() +{ + return Get(&ChannelType::persist); +} + +void ChannelImpl::SetPersist(bool persist) +{ + Set(&ChannelType::persist, persist); +} + +bool ChannelImpl::IsTopicLock() +{ + return Get(&ChannelType::topiclock); +} + +void ChannelImpl::SetTopicLock(bool topiclock) +{ + Set(&ChannelType::topiclock, topiclock); +} + +bool ChannelImpl::IsKeepTopic() +{ + return Get(&ChannelType::keeptopic); +} + +void ChannelImpl::SetKeepTopic(bool keeptopic) +{ + Set(&ChannelType::keeptopic, keeptopic); +} + +bool ChannelImpl::IsPrivate() +{ + return Get(&ChannelType::_private); +} + +void ChannelImpl::SetPrivate(bool _private) +{ + Set(&ChannelType::_private, _private); +} + ChanServ::ChanAccess *ChannelImpl::GetAccess(unsigned index) { std::vector a = GetRefs(); @@ -200,8 +360,8 @@ ChanServ::AccessGroup ChannelImpl::AccessFor(const User *u, bool updateLastUsed) if (u == NULL) return group; - const NickServ::Account *nc = u->Account(); - if (nc == NULL && !this->HasFieldS("NS_SECURE") && u->IsRecognized()) + NickServ::Account *nc = u->Account(); + if (nc == NULL && !nc->IsSecure() && u->IsRecognized()) { NickServ::Nick *na = NickServ::FindNick(u->nick); if (na != NULL) diff --git a/modules/chanserv/main/channel.h b/modules/chanserv/main/channel.h index 94f56ddd4..fd9a357eb 100644 --- a/modules/chanserv/main/channel.h +++ b/modules/chanserv/main/channel.h @@ -29,6 +29,22 @@ class ChannelImpl : public ChanServ::Channel int16_t bantype = 0; time_t banexpire = 0; BotInfo *bi = nullptr; + bool greet = false; + bool fantasy = false; + bool noautoop = false; + bool peace = false; + bool securefounder = false; + bool restricted = false; + bool secure = false; + bool secureops = false; + bool signkick = false; + bool signkicklevel = false; + bool noexpire = false; + bool keepmodes = false; + bool persist = false; + bool topiclock = false; + bool keeptopic = false; + bool _private = false; public: ChannelImpl(Serialize::TypeBase *type) : ChanServ::Channel(type) { } @@ -43,10 +59,10 @@ class ChannelImpl : public ChanServ::Channel void SetDesc(const Anope::string &) override; time_t GetTimeRegistered() override; - void SetTimeRegistered(const time_t &) override; + void SetTimeRegistered(time_t) override; time_t GetLastUsed() override; - void SetLastUsed(const time_t &) override; + void SetLastUsed(time_t) override; Anope::string GetLastTopic() override; void SetLastTopic(const Anope::string &) override; @@ -55,13 +71,13 @@ class ChannelImpl : public ChanServ::Channel void SetLastTopicSetter(const Anope::string &) override; time_t GetLastTopicTime() override; - void SetLastTopicTime(const time_t &) override; + void SetLastTopicTime(time_t) override; int16_t GetBanType() override; - void SetBanType(const int16_t &) override; + void SetBanType(int16_t) override; time_t GetBanExpire() override; - void SetBanExpire(const time_t &) override; + void SetBanExpire(time_t) override; BotInfo *GetBI() override; void SetBI(BotInfo *) override; @@ -77,11 +93,59 @@ class ChannelImpl : public ChanServ::Channel void SetSuccessor(NickServ::Account *nc) override; NickServ::Account *GetSuccessor() override; + bool IsGreet() override; + void SetGreet(bool) override; + + bool IsFantasy() override; + void SetFantasy(bool) override; + + bool IsNoAutoop() override; + void SetNoAutoop(bool) override; + + bool IsPeace() override; + void SetPeace(bool) override; + + bool IsSecureFounder() override; + void SetSecureFounder(bool) override; + + bool IsRestricted() override; + void SetRestricted(bool) override; + + bool IsSecure() override; + void SetSecure(bool) override; + + bool IsSecureOps() override; + void SetSecureOps(bool) override; + + bool IsSignKick() override; + void SetSignKick(bool) override; + + bool IsSignKickLevel() override; + void SetSignKickLevel(bool) override; + + bool IsNoExpire() override; + void SetNoExpire(bool) override; + + bool IsKeepModes() override; + void SetKeepModes(bool) override; + + bool IsPersist() override; + void SetPersist(bool) override; + + bool IsTopicLock() override; + void SetTopicLock(bool) override; + + bool IsKeepTopic() override; + void SetKeepTopic(bool) override; + + bool IsPrivate() override; + void SetPrivate(bool) override; + bool IsFounder(const User *user) override; - ChanServ::ChanAccess *GetAccess(unsigned index) /*const*/ override; + ChanServ::ChanAccess *GetAccess(unsigned index) override; ChanServ::AccessGroup AccessFor(const User *u, bool = true) override; ChanServ::AccessGroup AccessFor(NickServ::Account *nc, bool = true) override; - unsigned GetAccessCount()/* const*/ override; + unsigned GetAccessCount() override; void ClearAccess() override; AutoKick* AddAkick(const Anope::string &user, NickServ::Account *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0) override; diff --git a/modules/chanserv/main/channeltype.cpp b/modules/chanserv/main/channeltype.cpp index 37c290ef1..3f72cbb6b 100644 --- a/modules/chanserv/main/channeltype.cpp +++ b/modules/chanserv/main/channeltype.cpp @@ -32,7 +32,23 @@ ChannelType::ChannelType(Module *me) : Serialize::Type(me) , banexpire(this, "banexpire", &ChannelImpl::banexpire) , founder(this, "founder", &ChannelImpl::founder) , successor(this, "successor", &ChannelImpl::successor) - , bi(this, "bi", &ChannelImpl::bi) + , servicebot(this, "servicebot", &ChannelImpl::bi) + , greet(this, "greet", &ChannelImpl::greet) + , fantasy(this, "fantasy", &ChannelImpl::fantasy) + , noautoop(this, "noautoop", &ChannelImpl::noautoop) + , peace(this, "peace", &ChannelImpl::peace) + , securefounder(this, "securefounder", &ChannelImpl::securefounder) + , restricted(this, "restricted", &ChannelImpl::restricted) + , secure(this, "secure", &ChannelImpl::secure) + , secureops(this, "secureops", &ChannelImpl::secureops) + , signkick(this, "signkick", &ChannelImpl::signkick) + , signkicklevel(this, "signkicklevel", &ChannelImpl::signkicklevel) + , noexpire(this, "noexpire", &ChannelImpl::noexpire) + , keepmodes(this, "keepmodes", &ChannelImpl::keepmodes) + , persist(this, "persist", &ChannelImpl::persist) + , topiclock(this, "topiclock", &ChannelImpl::topiclock) + , keeptopic(this, "keeptopic", &ChannelImpl::keeptopic) + , _private(this, "private", &ChannelImpl::_private) { } diff --git a/modules/chanserv/main/channeltype.h b/modules/chanserv/main/channeltype.h index 1f1c92201..4f833c82b 100644 --- a/modules/chanserv/main/channeltype.h +++ b/modules/chanserv/main/channeltype.h @@ -45,7 +45,11 @@ class ChannelType : public Serialize::Type /* Who gets the channel if the founder nick is dropped or expires */ Serialize::ObjectField successor; - Serialize::ObjectField bi; + Serialize::ObjectField servicebot; + + Serialize::Field greet, fantasy, noautoop, peace, securefounder, + restricted, secure, secureops, signkick, signkicklevel, noexpire, keepmodes, + persist, topiclock, keeptopic, _private; ChannelType(Module *); diff --git a/modules/chanserv/main/chanserv.cpp b/modules/chanserv/main/chanserv.cpp index c6b30c2df..b6aedb0dd 100644 --- a/modules/chanserv/main/chanserv.cpp +++ b/modules/chanserv/main/chanserv.cpp @@ -249,16 +249,9 @@ class ChanServCore : public Module spacesepstream(conf->GetModule(this)->Get("defaults", "greet fantasy")).GetTokens(defaults); if (defaults.empty()) - { - defaults.push_back("KEEPTOPIC"); - defaults.push_back("CS_SECURE"); - defaults.push_back("SECUREFOUNDER"); - defaults.push_back("SIGNKICK"); - } + defaults = { "keeptopic", "secure", "securefounder", "signkick" }; else if (defaults[0].equals_ci("none")) - { defaults.clear(); - } always_lower = conf->GetModule(this)->Get("always_lower_ts"); } @@ -408,7 +401,7 @@ class ChanServCore : public Module void OnChannelSync(Channel *c) override { - bool perm = c->HasMode("PERM") || (c->ci && c->ci->HasFieldS("PERSIST")); + bool perm = c->HasMode("PERM") || (c->ci && c->ci->IsPersist()); if (!perm && !c->botchannel && (c->users.empty() || (c->users.size() == 1 && c->users.begin()->second->user->server == Me))) { this->Hold(c); @@ -470,7 +463,7 @@ class ChanServCore : public Module /* Find all persistent channels and create them, as we are about to finish burst to our uplink */ for (ChanServ::Channel *ci : Serialize::GetObjects()) { - if (ci->HasFieldS("PERSIST")) + if (ci->IsPersist()) { bool c; ci->c = Channel::FindOrCreate(ci->GetName(), c, ci->GetTimeRegistered()); @@ -508,9 +501,9 @@ class ChanServCore : public Module return; /* Mark the channel as persistent */ if (ci->c->HasMode("PERM")) - ci->SetS("PERSIST", true); + ci->SetPersist(true); /* Persist may be in def cflags, set it here */ - else if (ci->HasFieldS("PERSIST")) + else if (ci->IsPersist()) ci->c->SetMode(NULL, "PERM"); } @@ -550,7 +543,7 @@ class ChanServCore : public Module return; time_t chanserv_expire = Config->GetModule(this)->Get("expire", "14d"); - if (!ci->HasFieldS("CS_NO_EXPIRE") && chanserv_expire && !Anope::NoExpire && ci->GetLastUsed() != Anope::CurTime) + if (!ci->IsNoExpire() && chanserv_expire && !Anope::NoExpire && ci->GetLastUsed() != Anope::CurTime) info[_("Expires")] = Anope::strftime(ci->GetLastUsed() + chanserv_expire, source.GetAccount()); } diff --git a/modules/chanserv/mode.cpp b/modules/chanserv/mode.cpp index 7a9fd38d6..b20558bc0 100644 --- a/modules/chanserv/mode.cpp +++ b/modules/chanserv/mode.cpp @@ -56,13 +56,13 @@ class ModeLockImpl : public ModeLock class ModeLockType : public Serialize::Type { public: - Serialize::ObjectField ci; + Serialize::ObjectField channel; Serialize::Field set; Serialize::Field name, param, setter; Serialize::Field created; ModeLockType(Module *me) : Serialize::Type(me) - , ci(this, "ci", &ModeLockImpl::channel, true) + , channel(this, "channel", &ModeLockImpl::channel, true) , set(this, "set", &ModeLockImpl::set) , name(this, "name", &ModeLockImpl::name) , param(this, "param", &ModeLockImpl::param) @@ -74,12 +74,12 @@ class ModeLockType : public Serialize::Type ChanServ::Channel *ModeLockImpl::GetChannel() { - return Get(&ModeLockType::ci); + return Get(&ModeLockType::channel); } void ModeLockImpl::SetChannel(ChanServ::Channel *ci) { - Set(&ModeLockType::ci, ci); + Set(&ModeLockType::channel, ci); } bool ModeLockImpl::GetSet() @@ -574,7 +574,7 @@ class CommandCSMode : public Command ChanServ::AccessGroup targ_access = ci->AccessFor(uc->user); - if (uc->user->IsProtected() || (ci->HasFieldS("PEACE") && targ_access >= u_access && !can_override)) + if (uc->user->IsProtected() || (ci->IsPeace() && targ_access >= u_access && !can_override)) { source.Reply(_("You do not have the access to change the modes of \002{0}\002."), uc->user->nick.c_str()); continue; @@ -607,7 +607,7 @@ class CommandCSMode : public Command if (source.GetUser() != target) { ChanServ::AccessGroup targ_access = ci->AccessFor(target); - if (ci->HasFieldS("PEACE") && targ_access >= u_access && !can_override) + if (ci->IsPeace() && targ_access >= u_access && !can_override) { source.Reply(_("You do not have the access to change the modes of \002{0}\002"), target->nick); break; @@ -827,7 +827,7 @@ class CommandCSModes : public Command } } - if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->HasFieldS("PEACE") && targ_access >= u_access))) + if (!override && !m.first && u != targ && (targ->IsProtected() || (ci->IsPeace() && targ_access >= u_access))) { if (!can_override) { diff --git a/modules/chanserv/register.cpp b/modules/chanserv/register.cpp index 0c7d77a8f..1e2a6a2bd 100644 --- a/modules/chanserv/register.cpp +++ b/modules/chanserv/register.cpp @@ -42,7 +42,7 @@ class CommandCSRegister : public Command return; } - if (nc->HasFieldS("UNCONFIRMED")) + if (nc->IsUnconfirmed()) { source.Reply(_("You must confirm your account before you can register a channel.")); return; diff --git a/modules/chanserv/seen.cpp b/modules/chanserv/seen.cpp index 5a2237d8a..113691343 100644 --- a/modules/chanserv/seen.cpp +++ b/modules/chanserv/seen.cpp @@ -114,7 +114,7 @@ static bool ShouldHide(const Anope::string &channel, User *u) if (targetchan && targetchan->HasMode("SECRET")) return true; - else if (targetchan_ci && targetchan_ci->HasExt("CS_PRIVATE")) + else if (targetchan_ci && targetchan_ci->IsPrivate()) return true; else if (u && u->HasMode("PRIV")) return true; diff --git a/modules/chanserv/set.cpp b/modules/chanserv/set.cpp index 1d49629db..89eb4985a 100644 --- a/modules/chanserv/set.cpp +++ b/modules/chanserv/set.cpp @@ -118,13 +118,13 @@ class CommandCSSetAutoOp : public Command if (params[1].equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable autoop"; - ci->UnsetS("NOAUTOOP"); + ci->SetNoAutoop(false); source.Reply(_("Services will now automatically give modes to users in \002{0}\002."), ci->GetName()); } else if (params[1].equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable autoop"; - ci->SetS("NOAUTOOP", true); + ci->SetNoAutoop(true); source.Reply(_("Services will no longer automatically give modes to users in \002{0}\002."), ci->GetName()); } else @@ -296,7 +296,7 @@ class CommandCSSetFounder : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -374,7 +374,7 @@ class CommandCSSetKeepModes : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keep modes"; - ci->SetS("CS_KEEP_MODES", true); + ci->SetKeepModes(true); source.Reply(_("Keep modes for \002{0}\002 is now \002on\002."), ci->GetName()); if (ci->c) for (const std::pair &p : ci->c->GetModes()) @@ -388,7 +388,7 @@ class CommandCSSetKeepModes : public Command else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keep modes"; - ci->UnsetS("CS_KEEP_MODES"); + ci->SetKeepModes(false); source.Reply(_("Keep modes for \002{0}\002 is now \002off\002."), ci->GetName()); for (ChanServ::Mode *m : ci->GetRefs()) m->Delete(); @@ -447,13 +447,13 @@ class CommandCSSetPeace : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable peace"; - ci->SetS("PEACE", true); + ci->SetPeace(true); source.Reply(_("Peace option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable peace"; - ci->UnsetS("PEACE"); + ci->SetPeace(false); source.Reply(_("Peace option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -522,9 +522,9 @@ class CommandCSSetPersist : public Command if (params[1].equals_ci("ON")) { - if (!ci->HasFieldS("PERSIST")) + if (!ci->IsPersist()) { - ci->SetS("PERSIST", true); + ci->SetPersist(true); /* Channel doesn't exist, create it */ if (!ci->c) @@ -575,9 +575,9 @@ class CommandCSSetPersist : public Command } else if (params[1].equals_ci("OFF")) { - if (ci->HasFieldS("PERSIST")) + if (ci->IsPersist()) { - ci->UnsetS("PERSIST"); + ci->SetPersist(false); ServiceBot *ChanServ = Config->GetClient("ChanServ"), *BotServ = Config->GetClient("BotServ"); @@ -665,13 +665,13 @@ class CommandCSSetRestricted : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable restricted"; - ci->SetS("RESTRICTED", true); + ci->SetRestricted(true); source.Reply(_("Restricted access option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable restricted"; - ci->UnsetS("RESTRICTED"); + ci->SetRestricted(false); source.Reply(_("Restricted access option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -728,13 +728,13 @@ class CommandCSSetSecure : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure"; - ci->SetS("CS_SECURE", true); + ci->SetSecure(true); source.Reply(_("Secure option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure"; - ci->UnsetS("CS_SECURE"); + ci->SetSecure(false); source.Reply(_("Secure option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -784,7 +784,7 @@ class CommandCSSetSecureFounder : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -793,13 +793,13 @@ class CommandCSSetSecureFounder : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure founder"; - ci->SetS("SECUREFOUNDER", true); + ci->SetSecureFounder(true); source.Reply(_("Secure founder option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure founder"; - ci->UnsetS("SECUREFOUNDER"); + ci->SetSecureFounder(false); source.Reply(_("Secure founder option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -861,13 +861,13 @@ class CommandCSSetSecureOps : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable secure ops"; - ci->SetS("SECUREOPS", true); + ci->SetSecureOps(true); source.Reply(_("Secure ops option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable secure ops"; - ci->UnsetS("SECUREOPS"); + ci->SetSecureOps(false); source.Reply(_("Secure ops option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -924,22 +924,22 @@ class CommandCSSetSignKick : public Command if (param.equals_ci("ON")) { - ci->SetS("SIGNKICK", true); - ci->UnsetS("SIGNKICK_LEVEL"); + ci->SetSignKick(true); + ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002."), ci->GetName()); Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick"; } else if (param.equals_ci("LEVEL")) { - ci->SetS("SIGNKICK_LEVEL", true); - ci->UnsetS("SIGNKICK"); + ci->SetSignKick(false); + ci->SetSignKickLevel(true); source.Reply(_("Signed kick option for \002{0}\002 is now \002on\002, but depends of the privileges of the user that is using the command."), ci->GetName()); Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable sign kick level"; } else if (param.equals_ci("OFF")) { - ci->UnsetS("SIGNKICK"); - ci->UnsetS("SIGNKICK_LEVEL"); + ci->SetSignKick(false); + ci->SetSignKickLevel(false); source.Reply(_("Signed kick option for \002{0}\002 is now \002off\002."), ci->GetName()); Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable sign kick"; } @@ -991,7 +991,7 @@ class CommandCSSetSuccessor : public Command if (MOD_RESULT == EVENT_STOP) return; - if (MOD_RESULT != EVENT_ALLOW && (ci->HasFieldS("SECUREFOUNDER") ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) + if (MOD_RESULT != EVENT_ALLOW && (ci->IsSecureFounder() ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && source.permission.empty() && !source.HasPriv("chanserv/administration")) { source.Reply(_("Access denied. You do not have privilege \002{0}\002 on \002{1}\002."), "FOUNDER", ci->GetName()); return; @@ -1073,13 +1073,13 @@ class CommandCSSetNoexpire : public Command if (param.equals_ci("ON")) { Log(LOG_ADMIN, source, this, ci) << "to enable noexpire"; - ci->SetS("CS_NO_EXPIRE", true); + ci->SetNoExpire(true); source.Reply(_("Channel \002{0} will not\002 expire."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(LOG_ADMIN, source, this, ci) << "to disable noexpire"; - ci->UnsetS("CS_NO_EXPIRE"); + ci->SetNoExpire(false); source.Reply(_("Channel \002{0} will\002 expire."), ci->GetName()); } else @@ -1107,9 +1107,6 @@ class CSSet : public Module , public EventHook , public EventHook { - Serialize::Field noautoop, peace, securefounder, - restricted, secure, secureops, signkick, signkick_level, noexpire, keep_modes, persist; - CommandCSSet commandcsset; CommandCSSetAutoOp commandcssetautoop; CommandCSSetBanType commandcssetbantype; @@ -1143,18 +1140,6 @@ class CSSet : public Module , EventHook(this) , EventHook(this) - , noautoop(this, "NOAUTOOP") - , peace(this, "PEACE") - , securefounder(this, "SECUREFOUNDER") - , restricted(this, "RESTRICTED") - , secure(this, "CS_SECURE") - , secureops(this, "SECUREOPS") - , signkick(this, "SIGNKICK") - , signkick_level(this, "SIGNKICK_LEVEL") - , noexpire(this, "CS_NO_EXPIRE") - , keep_modes(this, "CS_KEEP_MODES") - , persist(this, "PERSIST") - , commandcsset(this) , commandcssetautoop(this) , commandcssetbantype(this) @@ -1187,14 +1172,14 @@ class CSSet : public Module void OnChannelSync(Channel *c) override { - if (c->ci && keep_modes.HasExt(c->ci)) + if (c->ci && c->ci->IsKeepModes()) for (ChanServ::Mode *m : c->ci->GetRefs()) c->SetMode(c->ci->WhoSends(), m->GetMode(), m->GetParam()); } EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) override { - if (!c->ci || !restricted.HasExt(c->ci) || c->MatchesList(u, "EXCEPT")) + if (!c->ci || !c->ci->IsRestricted() || c->MatchesList(u, "EXCEPT")) return EVENT_CONTINUE; if (c->ci->AccessFor(u).empty() && (!c->ci->GetFounder() || u->Account() != c->ci->GetFounder())) @@ -1205,9 +1190,11 @@ class CSSet : public Module void OnDelChan(ChanServ::Channel *ci) override { - if (ci->c && persist.HasExt(ci)) + if (ci->c && ci->IsPersist()) + { ci->c->RemoveMode(ci->WhoSends(), "PERM", "", false); - persist.Unset(ci); + ci->SetPersist(false); + } } EventReturn OnChannelModeSet(Channel *c, const MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) override @@ -1216,7 +1203,7 @@ class CSSet : public Module { /* Channel mode +P or so was set, mark this channel as persistent */ if (mode->name == "PERM") - persist.Set(c->ci, true); + c->ci->SetPersist(true); if (mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c))) { @@ -1238,7 +1225,7 @@ class CSSet : public Module if (mode->name == "PERM") { if (c->ci) - persist.Unset(c->ci); + c->ci->SetPersist(false); } if (c->ci && mode->type != MODE_STATUS && !c->syncing && Me->IsSynced() && (!inhabit || !inhabit->HasExt(c))) @@ -1251,7 +1238,7 @@ class CSSet : public Module void OnJoinChannel(User *u, Channel *c) override { - if (persist_lower_ts && c->ci && persist.HasExt(c->ci) && c->creation_time > c->ci->GetTimeRegistered()) + if (persist_lower_ts && c->ci && c->ci->IsPersist() && c->creation_time > c->ci->GetTimeRegistered()) { Log(LOG_DEBUG) << "Changing TS of " << c->name << " from " << c->creation_time << " to " << c->ci->GetTimeRegistered(); c->creation_time = c->ci->GetTimeRegistered(); @@ -1264,9 +1251,9 @@ class CSSet : public Module { if (chan->ci) { - if (noautoop.HasExt(chan->ci)) + if (chan->ci->IsNoAutoop()) give_modes = false; - if (secureops.HasExt(chan->ci)) + if (chan->ci->IsSecureOps()) // This overrides what chanserv does because it is loaded after chanserv take_modes = true; } @@ -1274,7 +1261,7 @@ class CSSet : public Module void OnPreChanExpire(ChanServ::Channel *ci, bool &expire) override { - if (noexpire.HasExt(ci)) + if (ci->IsNoExpire()) expire = false; } @@ -1283,25 +1270,25 @@ class CSSet : public Module if (!show_all) return; - if (peace.HasExt(ci)) + if (ci->IsPeace()) info.AddOption(_("Peace")); - if (restricted.HasExt(ci)) + if (ci->IsRestricted()) info.AddOption(_("Restricted access")); - if (secure.HasExt(ci)) + if (ci->IsSecure()) info.AddOption(_("Security")); - if (securefounder.HasExt(ci)) + if (ci->IsSecureFounder()) info.AddOption(_("Secure founder")); - if (secureops.HasExt(ci)) + if (ci->IsSecureOps()) info.AddOption(_("Secure ops")); - if (signkick.HasExt(ci) || signkick_level.HasExt(ci)) + if (ci->IsSignKick() || ci->IsSignKickLevel()) info.AddOption(_("Signed kicks")); - if (persist.HasExt(ci)) + if (ci->IsPersist()) info.AddOption(_("Persistent")); - if (noexpire.HasExt(ci)) + if (ci->IsNoExpire()) info.AddOption(_("No expire")); - if (keep_modes.HasExt(ci)) + if (ci->IsKeepModes()) info.AddOption(_("Keep modes")); - if (noautoop.HasExt(ci)) + if (ci->IsNoAutoop()) info.AddOption(_("No auto-op")); } }; diff --git a/modules/chanserv/set_misc.cpp b/modules/chanserv/set_misc.cpp index b2c0dc50c..ade42675d 100644 --- a/modules/chanserv/set_misc.cpp +++ b/modules/chanserv/set_misc.cpp @@ -53,7 +53,7 @@ class CSMiscDataType : public Serialize::Type Serialize::Field name, data; CSMiscDataType(Module *me) : Serialize::Type(me) - , owner(this, "owner", &CSMiscDataImpl::channel, true) + , owner(this, "channel", &CSMiscDataImpl::channel, true) , name(this, "name", &CSMiscDataImpl::name) , data(this, "data", &CSMiscDataImpl::data) { diff --git a/modules/chanserv/topic.cpp b/modules/chanserv/topic.cpp index 76a816c13..db4d25dbd 100644 --- a/modules/chanserv/topic.cpp +++ b/modules/chanserv/topic.cpp @@ -63,13 +63,13 @@ class CommandCSSetKeepTopic : public Command if (param.equals_ci("ON")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to enable keeptopic"; - ci->SetS("KEEPTOPIC", true); + ci->SetKeepTopic(true); source.Reply(_("Topic retention option for \002{0}\002 is now \002on\002."), ci->GetName()); } else if (param.equals_ci("OFF")) { Log(source.AccessFor(ci).HasPriv("SET") ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to disable keeptopic"; - ci->UnsetS("KEEPTOPIC"); + ci->SetKeepTopic(false); source.Reply(_("Topic retention option for \002{0}\002 is now \002off\002."), ci->GetName()); } else @@ -89,8 +89,6 @@ class CommandCSSetKeepTopic : public Command class CommandCSTopic : public Command { - ExtensibleRef topiclock; - void Lock(CommandSource &source, ChanServ::Channel *ci, const std::vector ¶ms) { if (Anope::ReadOnly) @@ -104,7 +102,7 @@ class CommandCSTopic : public Command if (MOD_RESULT == EVENT_STOP) return; - topiclock->Set(ci, true); + ci->SetTopicLock(true); source.Reply(_("Topic lock option for \002{0}\002 is now \002on\002."), ci->GetName()); } @@ -121,17 +119,17 @@ class CommandCSTopic : public Command if (MOD_RESULT == EVENT_STOP) return; - topiclock->Unset(ci); + ci->SetTopicLock(false); source.Reply(_("Topic lock option for \002{0}\002 is now \002off\002."), ci->GetName()); } void Set(CommandSource &source, ChanServ::Channel *ci, const Anope::string &topic) { - bool has_topiclock = topiclock->HasExt(ci); - topiclock->Unset(ci); + bool has_topiclock = ci->IsTopicLock(); + ci->SetTopicLock(false); ci->c->ChangeTopic(source.GetNick(), topic, Anope::CurTime); if (has_topiclock) - topiclock->Set(ci, true); + ci->SetTopicLock(true); bool override = !source.AccessFor(ci).HasPriv("TOPIC"); Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << (!topic.empty() ? "to change the topic to: " : "to unset the topic") << (!topic.empty() ? topic : ""); @@ -156,8 +154,7 @@ class CommandCSTopic : public Command } public: - CommandCSTopic(Module *creator) : Command(creator, "chanserv/topic", 2, 3), - topiclock("TOPICLOCK") + CommandCSTopic(Module *creator) : Command(creator, "chanserv/topic", 2, 3) { this->SetDesc(_("Manipulate the topic of the specified channel")); this->SetSyntax(_("\037channel\037 [SET] [\037topic\037]")); @@ -240,8 +237,6 @@ class CSTopic : public Module CommandCSTopic commandcstopic; CommandCSSetKeepTopic commandcssetkeeptopic; - Serialize::Field topiclock, keeptopic; - ServiceReference mlocks; public: @@ -251,8 +246,6 @@ class CSTopic : public Module , EventHook(this) , commandcstopic(this) , commandcssetkeeptopic(this) - , topiclock(this, "TOPICLOCK") - , keeptopic(this, "KEEPTOPIC") { } @@ -262,7 +255,7 @@ class CSTopic : public Module if (c->ci) { /* Update channel topic */ - if ((topiclock.HasExt(c->ci) || keeptopic.HasExt(c->ci)) && c->ci->GetLastTopic() != c->topic) + if ((c->ci->IsTopicLock() || c->ci->IsKeepTopic()) && c->ci->GetLastTopic() != c->topic) { c->ChangeTopic(!c->ci->GetLastTopicSetter().empty() ? c->ci->GetLastTopicSetter() : c->ci->WhoSends()->nick, c->ci->GetLastTopic(), c->ci->GetLastTopicTime() ? c->ci->GetLastTopicTime() : Anope::CurTime); } @@ -279,7 +272,7 @@ 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 (topiclock.HasExt(c->ci) && c->ci->GetLastTopic() != c->topic && (!source || !c->ci->AccessFor(source).HasPriv("TOPIC"))) + if (c->ci->IsTopicLock() && c->ci->GetLastTopic() != c->topic && (!source || !c->ci->AccessFor(source).HasPriv("TOPIC"))) { c->ChangeTopic(c->ci->GetLastTopicSetter(), c->ci->GetLastTopic(), c->ci->GetLastTopicTime()); } @@ -293,9 +286,9 @@ class CSTopic : public Module void OnChanInfo(CommandSource &source, ChanServ::Channel *ci, InfoFormatter &info, bool show_all) override { - if (keeptopic.HasExt(ci)) + if (ci->IsKeepTopic()) info.AddOption(_("Topic retention")); - if (topiclock.HasExt(ci)) + if (ci->IsTopicLock()) info.AddOption(_("Topic lock")); ModeLock *secret = mlocks ? mlocks->GetMLock(ci, "SECRET") : nullptr; diff --git a/modules/chanserv/updown.cpp b/modules/chanserv/updown.cpp index 8df6be26b..38ed65776 100644 --- a/modules/chanserv/updown.cpp +++ b/modules/chanserv/updown.cpp @@ -117,7 +117,7 @@ class CommandCSUp : public Command return; } - if (source.GetUser() && u != source.GetUser() && c->ci->HasFieldS("PEACE")) + if (source.GetUser() && u != source.GetUser() && c->ci->IsPeace()) { if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) { @@ -222,7 +222,7 @@ class CommandCSDown : public Command return; } - if (source.GetUser() && u != source.GetUser() && c->ci->HasFieldS("PEACE")) + if (source.GetUser() && u != source.GetUser() && c->ci->IsPeace()) { if (c->ci->AccessFor(u) >= c->ci->AccessFor(source.GetUser())) { -- cgit