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 --- data/chanserv.example.conf | 10 +- data/nickserv.example.conf | 12 +- include/modules/chanserv/channel.h | 70 ++++++++++-- include/modules/memoserv.h | 3 + include/modules/nickserv/account.h | 53 ++++++++- include/modules/nickserv/ajoin.h | 4 +- include/modules/nickserv/nick.h | 5 +- modules/botserv/assign.cpp | 2 +- modules/botserv/badwords.cpp | 2 +- modules/botserv/main/botserv.cpp | 4 +- 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 +- modules/database/flatfile.cpp | 2 +- modules/database/old.cpp | 78 +++++++------ modules/fantasy.cpp | 11 +- modules/greet.cpp | 23 ++-- modules/hostserv/request.cpp | 2 +- modules/memoserv/info.cpp | 20 ++-- modules/memoserv/main/memoinfo.cpp | 11 ++ modules/memoserv/main/memoinfo.h | 4 + modules/memoserv/main/memoinfotype.cpp | 1 + modules/memoserv/main/memoinfotype.h | 1 + modules/memoserv/main/memoserv.cpp | 6 +- modules/memoserv/send.cpp | 2 +- modules/memoserv/set.cpp | 41 +++---- modules/nickserv/ajoin.cpp | 12 +- modules/nickserv/alist.cpp | 6 +- modules/nickserv/cert.cpp | 8 +- modules/nickserv/group.cpp | 4 +- modules/nickserv/info.cpp | 26 ++--- modules/nickserv/list.cpp | 22 ++-- modules/nickserv/main/account.cpp | 170 +++++++++++++++++++++++++++ modules/nickserv/main/account.h | 63 ++++++++++ modules/nickserv/main/accounttype.cpp | 17 +++ modules/nickserv/main/accounttype.h | 4 + modules/nickserv/main/nick.cpp | 14 ++- modules/nickserv/main/nick.h | 4 + modules/nickserv/main/nickserv.cpp | 32 +++--- modules/nickserv/main/nicktype.cpp | 3 +- modules/nickserv/main/nicktype.h | 4 +- modules/nickserv/recover.cpp | 6 +- modules/nickserv/register.cpp | 22 ++-- modules/nickserv/resetpass.cpp | 2 +- modules/nickserv/set.cpp | 80 ++++++------- modules/nickserv/set_misc.cpp | 2 +- modules/nickserv/suspend.cpp | 4 +- modules/protocol/inspircd20.cpp | 6 +- modules/protocol/ratbox.cpp | 2 +- modules/protocol/unreal.cpp | 2 +- modules/webcpanel/pages/chanserv/drop.cpp | 2 +- modules/webcpanel/pages/chanserv/set.cpp | 63 ++++------ modules/webcpanel/pages/nickserv/alist.cpp | 4 +- modules/webcpanel/pages/nickserv/info.cpp | 63 ++++------ src/users.cpp | 4 +- 73 files changed, 1060 insertions(+), 521 deletions(-) diff --git a/data/chanserv.example.conf b/data/chanserv.example.conf index c60a58621..22881217c 100644 --- a/data/chanserv.example.conf +++ b/data/chanserv.example.conf @@ -65,27 +65,27 @@ module * - keeptopic: Retain topic when the channel is not in use * - peace: Disallow users from kicking or removing modes from others who are of the same * access level or superior - * - cs_private: Hide the channel from ChanServ's LIST command + * - private: Hide the channel from ChanServ's LIST command * - restricted: Kick/ban users who are restricted from the channel - * - cs_secure: Enable channel security, requiring the user to be identified with NickServ in + * - secure: Enable channel security, requiring the user to be identified with NickServ in * order to be considered for being on the access list of the channel * - secureops: Only allow operator status to be given if the user is on the access list * - securefounder: Only allow the real founder of the channel to drop the channel, change it's * password, or change the founder or successor * - signkick: Use of ChanServ's KICK command will cause the user's nick to be signed to the kick. - * - signkick_level: Same as above, but the kick will not be signed if the user is at the same access + * - signkicklevel: Same as above, but the kick will not be signed if the user is at the same access * level or superior to the target * - topiclock: Disallow the topic to be changed except with ChanServ's TOPIC command * - persist: Keep the channel open at all times * - noautoop: Disables autoop on the channel - * - cs_keep_modes: Enables keep modes on the channel, which retains modes when the channel is + * - keepmodes: Enables keep modes on the channel, which retains modes when the channel is * not in use. * - none: No defaults * * This directive is optional, if left blank, the options will default to keeptopic, chanserv/secure, securefounder, * and signkick. If you really want no defaults, use "none" by itself as the option. */ - defaults = "keeptopic peace cs_secure securefounder signkick" + defaults = "keeptopic peace secure securefounder signkick" /* * The maximum number of channels which may be registered to a single nickname. diff --git a/data/nickserv.example.conf b/data/nickserv.example.conf index 1f07831c4..ceef600ab 100644 --- a/data/nickserv.example.conf +++ b/data/nickserv.example.conf @@ -83,11 +83,11 @@ module * * The options are: * - killprotect: Kill nick if not identified within 60 seconds - * - kill_quick: Kill nick if not identified within 20 seconds, this one overrides the above + * - killquick: Kill nick if not identified within 20 seconds, this one overrides the above * option and the above must be specified with this one - * - ns_secure: Enable nickname security, requiring the nick's password before any operations + * - secure: Enable nickname security, requiring the nick's password before any operations * can be done on it - * - ns_private: Hide the nick from NickServ's LIST command + * - private: Hide the nick from NickServ's LIST command * - hide_email: Hide's the nick's e-mail address from NickServ's INFO command * - hide_mask: Hide's the nick's last or current user@host from NickServ's INFO command * - hide_quit: Hide's the nick's last quit message @@ -97,13 +97,13 @@ module * - autoop: User will be automatically opped in channels they enter and have access to * - msg: Services messages will be sent as PRIVMSGs instead of NOTICEs, requires * options:useprivmsg to be enabled as well - * - ns_keepmodes: Enables keepmodes, which retains user modes across sessions - * - ns_no_expire: Enables no expire. Unconfirmed expire overrules this. + * - keepmodes: Enables keepmodes, which retains user modes across sessions + * - noexpire: Enables no expire. Unconfirmed expire overrules this. * * This directive is optional, if left blank, the options will default to nickserv/secure, memo_signon, and * memo_receive. If you really want no defaults, use "none" by itself as the option. */ - defaults = "ns_secure ns_private hide_email hide_mask memo_signon memo_receive autoop" + defaults = "secure private hide_email hide_mask memo_signon memo_receive autoop" /* * The minimum length of time between consecutive uses of NickServ's REGISTER command. This diff --git a/include/modules/chanserv/channel.h b/include/modules/chanserv/channel.h index 3ba5e7561..29e8ef9d7 100644 --- a/include/modules/chanserv/channel.h +++ b/include/modules/chanserv/channel.h @@ -27,12 +27,10 @@ class CoreExport Channel : public Serialize::Object public: ::Channel *c = nullptr; /* Pointer to channel, if the channel exists */ - protected: - using Serialize::Object::Object; - - public: static constexpr const char *const NAME = "channel"; + using Serialize::Object::Object; + virtual Anope::string GetName() anope_abstract; virtual void SetName(const Anope::string &) anope_abstract; @@ -40,10 +38,10 @@ class CoreExport Channel : public Serialize::Object virtual void SetDesc(const Anope::string &) anope_abstract; virtual time_t GetTimeRegistered() anope_abstract; - virtual void SetTimeRegistered(const time_t &) anope_abstract; + virtual void SetTimeRegistered(time_t) anope_abstract; virtual time_t GetLastUsed() anope_abstract; - virtual void SetLastUsed(const time_t &) anope_abstract; + virtual void SetLastUsed(time_t) anope_abstract; virtual Anope::string GetLastTopic() anope_abstract; virtual void SetLastTopic(const Anope::string &) anope_abstract; @@ -52,13 +50,13 @@ class CoreExport Channel : public Serialize::Object virtual void SetLastTopicSetter(const Anope::string &) anope_abstract; virtual time_t GetLastTopicTime() anope_abstract; - virtual void SetLastTopicTime(const time_t &) anope_abstract; + virtual void SetLastTopicTime(time_t) anope_abstract; virtual int16_t GetBanType() anope_abstract; - virtual void SetBanType(const int16_t &) anope_abstract; + virtual void SetBanType(int16_t) anope_abstract; virtual time_t GetBanExpire() anope_abstract; - virtual void SetBanExpire(const time_t &) anope_abstract; + virtual void SetBanExpire(time_t) anope_abstract; virtual BotInfo *GetBI() anope_abstract; virtual void SetBI(BotInfo *) anope_abstract; @@ -66,6 +64,58 @@ class CoreExport Channel : public Serialize::Object virtual ServiceBot *GetBot() anope_abstract; virtual void SetBot(ServiceBot *) anope_abstract; + /** Whether or not greets are enabled. + */ + virtual bool IsGreet() anope_abstract; + virtual void SetGreet(bool) anope_abstract; + + /** Whether or not fantasy is enabled. + */ + virtual bool IsFantasy() anope_abstract; + virtual void SetFantasy(bool) anope_abstract; + + virtual bool IsNoAutoop() anope_abstract; + virtual void SetNoAutoop(bool) anope_abstract; + + virtual bool IsPeace() anope_abstract; + virtual void SetPeace(bool) anope_abstract; + + virtual bool IsSecureFounder() anope_abstract; + virtual void SetSecureFounder(bool) anope_abstract; + + virtual bool IsRestricted() anope_abstract; + virtual void SetRestricted(bool) anope_abstract; + + virtual bool IsSecure() anope_abstract; + virtual void SetSecure(bool) anope_abstract; + + virtual bool IsSecureOps() anope_abstract; + virtual void SetSecureOps(bool) anope_abstract; + + virtual bool IsSignKick() anope_abstract; + virtual void SetSignKick(bool) anope_abstract; + + virtual bool IsSignKickLevel() anope_abstract; + virtual void SetSignKickLevel(bool) anope_abstract; + + virtual bool IsNoExpire() anope_abstract; + virtual void SetNoExpire(bool) anope_abstract; + + virtual bool IsKeepModes() anope_abstract; + virtual void SetKeepModes(bool) anope_abstract; + + virtual bool IsPersist() anope_abstract; + virtual void SetPersist(bool) anope_abstract; + + virtual bool IsTopicLock() anope_abstract; + virtual void SetTopicLock(bool) anope_abstract; + + virtual bool IsKeepTopic() anope_abstract; + virtual void SetKeepTopic(bool) anope_abstract; + + virtual bool IsPrivate() anope_abstract; + virtual void SetPrivate(bool) anope_abstract; + /** Is the user the real founder? * @param user The user * @return true or false @@ -198,4 +248,4 @@ class CoreExport Channel : public Serialize::Object }; -} // namespace ChanServ \ No newline at end of file +} // namespace ChanServ diff --git a/include/modules/memoserv.h b/include/modules/memoserv.h index 1268facef..8c39b5a5e 100644 --- a/include/modules/memoserv.h +++ b/include/modules/memoserv.h @@ -144,6 +144,9 @@ namespace MemoServ virtual int16_t GetMemoMax() anope_abstract; virtual void SetMemoMax(const int16_t &) anope_abstract; + virtual bool IsHardMax() anope_abstract; + virtual void SetHardMax(bool) anope_abstract; + virtual std::vector GetMemos() anope_abstract; virtual std::vector GetIgnores() anope_abstract; }; diff --git a/include/modules/nickserv/account.h b/include/modules/nickserv/account.h index f0ba144f7..511b1220f 100644 --- a/include/modules/nickserv/account.h +++ b/include/modules/nickserv/account.h @@ -24,13 +24,13 @@ namespace NickServ /* A registered account. Each account must have a Nick with the same nick as the * account's display. - * It matters that Base is here before Extensible (it is inherited by Serializable) */ class CoreExport Account : public Serialize::Object { public: static constexpr const char *const NAME = "account"; +#warning "this gets lost" /* Last time an email was sent to this user */ time_t lastmail = 0; /* Users online now logged into this account */ @@ -53,6 +53,57 @@ class CoreExport Account : public Serialize::Object virtual Oper *GetOper() anope_abstract; virtual void SetOper(Oper *) anope_abstract; + virtual Anope::string GetGreet() anope_abstract; + virtual void SetGreet(const Anope::string &) anope_abstract; + + virtual bool IsUnconfirmed() anope_abstract; + virtual void SetUnconfirmed(bool) anope_abstract; + + virtual bool IsPrivate() anope_abstract; + virtual void SetPrivate(bool) anope_abstract; + + virtual bool IsAutoOp() anope_abstract; + virtual void SetAutoOp(bool) anope_abstract; + + virtual bool IsKeepModes() anope_abstract; + virtual void SetKeepModes(bool) anope_abstract; + + virtual bool IsKillProtect() anope_abstract; + virtual void SetKillProtect(bool) anope_abstract; + + virtual bool IsKillQuick() anope_abstract; + virtual void SetKillQuick(bool) anope_abstract; + + virtual bool IsKillImmed() anope_abstract; + virtual void SetKillImmed(bool) anope_abstract; + + virtual bool IsMsg() anope_abstract; + virtual void SetMsg(bool) anope_abstract; + + virtual bool IsSecure() anope_abstract; + virtual void SetSecure(bool) anope_abstract; + + virtual bool IsMemoSignon() anope_abstract; + virtual void SetMemoSignon(bool) anope_abstract; + + virtual bool IsMemoReceive() anope_abstract; + virtual void SetMemoReceive(bool) anope_abstract; + + virtual bool IsMemoMail() anope_abstract; + virtual void SetMemoMail(bool) anope_abstract; + + virtual bool IsHideEmail() anope_abstract; + virtual void SetHideEmail(bool) anope_abstract; + + virtual bool IsHideMask() anope_abstract; + virtual void SetHideMask(bool) anope_abstract; + + virtual bool IsHideStatus() anope_abstract; + virtual void SetHideStatus(bool) anope_abstract; + + virtual bool IsHideQuit() anope_abstract; + virtual void SetHideQuit(bool) anope_abstract; + /** Changes the display for this account * @param na The new display, must be grouped to this account. */ diff --git a/include/modules/nickserv/ajoin.h b/include/modules/nickserv/ajoin.h index c23eecbe9..9f060402c 100644 --- a/include/modules/nickserv/ajoin.h +++ b/include/modules/nickserv/ajoin.h @@ -25,8 +25,8 @@ class AutoJoin : public Serialize::Object public: static constexpr const char *const NAME = "autojoin"; - virtual NickServ::Account *GetOwner() anope_abstract; - virtual void SetOwner(NickServ::Account *acc) anope_abstract; + virtual NickServ::Account *GetAccount() anope_abstract; + virtual void SetAccount(NickServ::Account *acc) anope_abstract; virtual Anope::string GetChannel() anope_abstract; virtual void SetChannel(const Anope::string &c) anope_abstract; diff --git a/include/modules/nickserv/nick.h b/include/modules/nickserv/nick.h index 604bc02d6..3579e7d0d 100644 --- a/include/modules/nickserv/nick.h +++ b/include/modules/nickserv/nick.h @@ -55,6 +55,9 @@ class CoreExport Nick : public Serialize::Object virtual Account *GetAccount() anope_abstract; virtual void SetAccount(Account *acc) anope_abstract; + + virtual bool IsNoExpire() anope_abstract; + virtual void SetNoExpire(bool) anope_abstract; }; -} // namespace NickServ \ No newline at end of file +} // namespace NickServ diff --git a/modules/botserv/assign.cpp b/modules/botserv/assign.cpp index 95691b6a9..eca103e9f 100644 --- a/modules/botserv/assign.cpp +++ b/modules/botserv/assign.cpp @@ -140,7 +140,7 @@ class CommandBSUnassign : public Command return; } - if (ci->HasFieldS("PERSIST") && !ModeManager::FindChannelModeByName("PERM")) + if (ci->IsPersist() && !ModeManager::FindChannelModeByName("PERM")) { source.Reply(_("You cannot unassign bots while persist is set on the channel.")); return; diff --git a/modules/botserv/badwords.cpp b/modules/botserv/badwords.cpp index 1348c8aff..914e89ea9 100644 --- a/modules/botserv/badwords.cpp +++ b/modules/botserv/badwords.cpp @@ -50,7 +50,7 @@ class BadWordsType : public Serialize::Type Serialize::Field type; BadWordsType(Module *me) : Serialize::Type(me) - , channel(this, "ci", &BadWordImpl::channel, true) + , channel(this, "channel", &BadWordImpl::channel, true) , word(this, "word", &BadWordImpl::word) , type(this, "type", &BadWordImpl::type) { diff --git a/modules/botserv/main/botserv.cpp b/modules/botserv/main/botserv.cpp index a297db153..c6e1c6413 100644 --- a/modules/botserv/main/botserv.cpp +++ b/modules/botserv/main/botserv.cpp @@ -127,7 +127,7 @@ class BotServCore : public Module, public BotServ::BotServService void OnLeaveChannel(User *u, Channel *c) override { /* Channel is persistent, it shouldn't be deleted and the service bot should stay */ - if (c->ci && c->ci->HasFieldS("PERSIST")) + if (c->ci && c->ci->IsPersist()) return; /* Channel is syncing from a netburst, don't destroy it as more users are probably wanting to join immediately @@ -219,7 +219,7 @@ class BotServCore : public Module, public BotServ::BotServService /* Set default bot flags */ spacesepstream sep(Config->GetModule(this)->Get("defaults", "greet fantasy")); for (Anope::string token; sep.GetToken(token);) - ci->SetS("BS_" + token.upper(), true); + ci->SetS(token, true); } void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) override 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); -