diff options
| author | Adam <Adam@anope.org> | 2016-11-25 16:35:10 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2016-11-25 16:35:56 -0500 |
| commit | a635344582a13d935631fbe930d79d3788359c8a (patch) | |
| tree | cd7b372d02f94c7f6c18542e06d29deff0f19842 /modules/nickserv/main | |
| parent | f30d99f81f6fb8abd7ca555068173bad6c99e07a (diff) | |
Rename most ext fields names to be consistent with everything else, add accessors for many
Diffstat (limited to 'modules/nickserv/main')
| -rw-r--r-- | modules/nickserv/main/account.cpp | 170 | ||||
| -rw-r--r-- | modules/nickserv/main/account.h | 63 | ||||
| -rw-r--r-- | modules/nickserv/main/accounttype.cpp | 17 | ||||
| -rw-r--r-- | modules/nickserv/main/accounttype.h | 4 | ||||
| -rw-r--r-- | modules/nickserv/main/nick.cpp | 14 | ||||
| -rw-r--r-- | modules/nickserv/main/nick.h | 4 | ||||
| -rw-r--r-- | modules/nickserv/main/nickserv.cpp | 32 | ||||
| -rw-r--r-- | modules/nickserv/main/nicktype.cpp | 3 | ||||
| -rw-r--r-- | modules/nickserv/main/nicktype.h | 4 |
9 files changed, 289 insertions, 22 deletions
diff --git a/modules/nickserv/main/account.cpp b/modules/nickserv/main/account.cpp index 1cd868194..fa6de8455 100644 --- a/modules/nickserv/main/account.cpp +++ b/modules/nickserv/main/account.cpp @@ -92,6 +92,176 @@ MemoServ::MemoInfo *AccountImpl::GetMemos() return GetRef<MemoServ::MemoInfo *>(); } +Anope::string AccountImpl::GetGreet() +{ + return Get(&AccountType::greet); +} + +void AccountImpl::SetGreet(const Anope::string &greet) +{ + Set(&AccountType::greet, greet); +} + +bool AccountImpl::IsUnconfirmed() +{ + return Get(&AccountType::unconfirmed); +} + +void AccountImpl::SetUnconfirmed(bool unconfirmed) +{ + Set(&AccountType::greet, unconfirmed); +} + +bool AccountImpl::IsPrivate() +{ + return Get(&AccountType::_private); +} + +void AccountImpl::SetPrivate(bool _private) +{ + Set(&AccountType::_private, _private); +} + +bool AccountImpl::IsAutoOp() +{ + return Get(&AccountType::autoop); +} + +void AccountImpl::SetAutoOp(bool autoop) +{ + Set(&AccountType::autoop, autoop); +} + +bool AccountImpl::IsKeepModes() +{ + return Get(&AccountType::keepmodes); +} + +void AccountImpl::SetKeepModes(bool keepmodes) +{ + Set(&AccountType::keepmodes, keepmodes); +} + +bool AccountImpl::IsKillProtect() +{ + return Get(&AccountType::killprotect); +} + +void AccountImpl::SetKillProtect(bool killprotect) +{ + Set(&AccountType::killprotect, killprotect); +} + +bool AccountImpl::IsKillQuick() +{ + return Get(&AccountType::killquick); +} + +void AccountImpl::SetKillQuick(bool killquick) +{ + Set(&AccountType::killquick, killquick); +} + +bool AccountImpl::IsKillImmed() +{ + return Get(&AccountType::killimmed); +} + +void AccountImpl::SetKillImmed(bool killimmed) +{ + Set(&AccountType::killimmed, killimmed); +} + +bool AccountImpl::IsMsg() +{ + return Get(&AccountType::msg); +} + +void AccountImpl::SetMsg(bool msg) +{ + Set(&AccountType::msg, msg); +} + +bool AccountImpl::IsSecure() +{ + return Get(&AccountType::secure); +} + +void AccountImpl::SetSecure(bool secure) +{ + Set(&AccountType::secure, secure); +} + +bool AccountImpl::IsMemoSignon() +{ + return Get(&AccountType::memosignon); +} + +void AccountImpl::SetMemoSignon(bool memosignon) +{ + Set(&AccountType::memosignon, memosignon); +} + +bool AccountImpl::IsMemoReceive() +{ + return Get(&AccountType::memoreceive); +} + +void AccountImpl::SetMemoReceive(bool memoreceive) +{ + Set(&AccountType::memoreceive, memoreceive); +} + +bool AccountImpl::IsMemoMail() +{ + return Get(&AccountType::memomail); +} + +void AccountImpl::SetMemoMail(bool memomail) +{ + Set(&AccountType::memomail, memomail); +} + +bool AccountImpl::IsHideEmail() +{ + return Get(&AccountType::hideemail); +} + +void AccountImpl::SetHideEmail(bool hideemail) +{ + Set(&AccountType::hideemail, hideemail); +} + +bool AccountImpl::IsHideMask() +{ + return Get(&AccountType::hidemask); +} + +void AccountImpl::SetHideMask(bool hidemask) +{ + Set(&AccountType::hidemask, hidemask); +} + +bool AccountImpl::IsHideStatus() +{ + return Get(&AccountType::hidestatus); +} + +void AccountImpl::SetHideStatus(bool hidestatus) +{ + Set(&AccountType::hidestatus, hidestatus); +} + +bool AccountImpl::IsHideQuit() +{ + return Get(&AccountType::hidequit); +} + +void AccountImpl::SetHideQuit(bool hidequit) +{ + Set(&AccountType::hidequit, hidequit); +} + void AccountImpl::SetDisplay(NickServ::Nick *na) { if (na->GetAccount() != this || na->GetNick() == this->GetDisplay()) diff --git a/modules/nickserv/main/account.h b/modules/nickserv/main/account.h index 611233261..928213666 100644 --- a/modules/nickserv/main/account.h +++ b/modules/nickserv/main/account.h @@ -25,6 +25,18 @@ class AccountImpl : public NickServ::Account Anope::string display, password, email, language; Oper *oper = nullptr; + Anope::string greet; + bool unconfirmed = false; + bool _private = false; + bool autoop = false; + bool keepmodes = false; + bool killprotect = false; + bool killquick = false; + bool killimmed = false; + bool msg = false; + bool secure = false; + bool memosignon = false, memoreceive = false, memomail = false; + bool hideemail = false, hidemask = false, hidestatus = false, hidequit = false; public: using NickServ::Account::Account; @@ -46,6 +58,57 @@ class AccountImpl : public NickServ::Account Oper *GetOper() override; void SetOper(Oper *) override; + Anope::string GetGreet() override; + void SetGreet(const Anope::string &) override; + + bool IsUnconfirmed() override; + void SetUnconfirmed(bool) override; + + bool IsPrivate() override; + void SetPrivate(bool) override; + + bool IsAutoOp() override; + void SetAutoOp(bool) override; + + bool IsKeepModes() override; + void SetKeepModes(bool) override; + + bool IsKillProtect() override; + void SetKillProtect(bool) override; + + bool IsKillQuick() override; + void SetKillQuick(bool) override; + + bool IsKillImmed() override; + void SetKillImmed(bool) override; + + bool IsMsg() override; + void SetMsg(bool) override; + + bool IsSecure() override; + void SetSecure(bool) override; + + bool IsMemoSignon() override; + void SetMemoSignon(bool) override; + + bool IsMemoReceive() override; + void SetMemoReceive(bool) override; + + bool IsMemoMail() override; + void SetMemoMail(bool) override; + + bool IsHideEmail() override; + void SetHideEmail(bool) override; + + bool IsHideMask() override; + void SetHideMask(bool) override; + + bool IsHideStatus() override; + void SetHideStatus(bool) override; + + bool IsHideQuit() override; + void SetHideQuit(bool) override; + MemoServ::MemoInfo *GetMemos() override; void SetDisplay(NickServ::Nick *na) override; diff --git a/modules/nickserv/main/accounttype.cpp b/modules/nickserv/main/accounttype.cpp index ec37c18d4..ccc02726a 100644 --- a/modules/nickserv/main/accounttype.cpp +++ b/modules/nickserv/main/accounttype.cpp @@ -26,6 +26,23 @@ AccountType::AccountType(Module *me) : Serialize::Type<AccountImpl>(me) , email(this, "email", &AccountImpl::email) , language(this, "language", &AccountImpl::language) , oper(this, "oper", &AccountImpl::oper) + , greet(this, "greet", &AccountImpl::greet) + , unconfirmed(this, "unconfirmed", &AccountImpl::unconfirmed) + , _private(this, "private", &AccountImpl::_private) + , autoop(this, "autoop", &AccountImpl::autoop) + , keepmodes(this, "keepmodes", &AccountImpl::keepmodes) + , killprotect(this, "killprotect", &AccountImpl::killprotect) + , killquick(this, "killquick", &AccountImpl::killquick) + , killimmed(this, "killimmed", &AccountImpl::killimmed) + , msg(this, "msg", &AccountImpl::msg) + , secure(this, "secure", &AccountImpl::secure) + , memosignon(this, "memo_signon", &AccountImpl::memosignon) + , memoreceive(this, "memo_receive", &AccountImpl::memoreceive) + , memomail(this, "memo_mail", &AccountImpl::memomail) + , hideemail(this, "hide_email", &AccountImpl::hideemail) + , hidemask(this, "hide_mask", &AccountImpl::hidemask) + , hidestatus(this, "hide_status", &AccountImpl::hidestatus) + , hidequit(this, "hide_quit", &AccountImpl::hidequit) { } diff --git a/modules/nickserv/main/accounttype.h b/modules/nickserv/main/accounttype.h index 8e831ed2c..f8d6a31a5 100644 --- a/modules/nickserv/main/accounttype.h +++ b/modules/nickserv/main/accounttype.h @@ -35,6 +35,10 @@ class AccountType : public Serialize::Type<AccountImpl> /* Locale name of the language of the user. Empty means default language */ Serialize::Field<AccountImpl, Anope::string> language; Serialize::ObjectField<AccountImpl, Oper *> oper; + Serialize::Field<AccountImpl, Anope::string> greet; + Serialize::Field<AccountImpl, bool> unconfirmed, _private, autoop, keepmodes, + killprotect, killquick, killimmed, msg, secure, memosignon, memoreceive, + memomail, hideemail, hidemask, hidestatus, hidequit; AccountType(Module *); diff --git a/modules/nickserv/main/nick.cpp b/modules/nickserv/main/nick.cpp index 0f94e63af..1efa37a2b 100644 --- a/modules/nickserv/main/nick.cpp +++ b/modules/nickserv/main/nick.cpp @@ -128,11 +128,21 @@ void NickImpl::SetLastSeen(const time_t &ls) NickServ::Account *NickImpl::GetAccount() { - return Get(&NickType::nc); + return Get(&NickType::account); } void NickImpl::SetAccount(NickServ::Account *acc) { - Set(&NickType::nc, acc); + Set(&NickType::account, acc); +} + +bool NickImpl::IsNoExpire() +{ + return Get(&NickType::noexpire); +} + +void NickImpl::SetNoExpire(bool noexpire) +{ + Set(&NickType::noexpire, noexpire); } diff --git a/modules/nickserv/main/nick.h b/modules/nickserv/main/nick.h index 69f47efe8..9df205fb9 100644 --- a/modules/nickserv/main/nick.h +++ b/modules/nickserv/main/nick.h @@ -24,6 +24,7 @@ class NickImpl : public NickServ::Nick NickServ::Account *account = nullptr; Anope::string nick, last_quit, last_realname, last_usermask, last_realhost; time_t time_registered = 0, last_seen = 0; + bool noexpire = false; public: NickImpl(Serialize::TypeBase *type) : NickServ::Nick(type) { } @@ -54,4 +55,7 @@ class NickImpl : public NickServ::Nick NickServ::Account *GetAccount() override; void SetAccount(NickServ::Account *acc) override; + + bool IsNoExpire() override; + void SetNoExpire(bool) override; }; diff --git a/modules/nickserv/main/nickserv.cpp b/modules/nickserv/main/nickserv.cpp index c41f3b3f3..60b136db1 100644 --- a/modules/nickserv/main/nickserv.cpp +++ b/modules/nickserv/main/nickserv.cpp @@ -244,7 +244,7 @@ class NickServCore : public Module, public NickServ::NickServService if (MOD_RESULT == EVENT_ALLOW) return; - if (!na->GetAccount()->HasFieldS("NS_SECURE") && u->IsRecognized()) + if (!na->GetAccount()->IsSecure() && u->IsRecognized()) { na->SetLastSeen(Anope::CurTime); na->SetLastUsermask(u->GetIdent() + "@" + u->GetDisplayedHost()); @@ -257,21 +257,21 @@ class NickServCore : public Module, public NickServ::NickServService bool on_access = u->IsRecognized(false); - if (on_access || !na->GetAccount()->HasFieldS("KILL_IMMED")) + if (on_access || !na->GetAccount()->IsKillImmed()) { - if (na->GetAccount()->HasFieldS("NS_SECURE")) + if (na->GetAccount()->IsSecure()) u->SendMessage(*NickServ, _("This nickname is registered and protected. If this is your nickname, type \002{0}{1} IDENTIFY \037password\037\002. Otherwise, please choose a different nickname."), Config->StrictPrivmsg, NickServ->nick); // XXX else u->SendMessage(*NickServ, _("This nickname is owned by someone else. If this is your nickname, type \002{0}{1} IDENTIFY \037password\037\002. Otherwise, please choose a different nickname."), Config->StrictPrivmsg, NickServ->nick); // XXX } - if (na->GetAccount()->HasFieldS("KILLPROTECT") && !on_access) + if (na->GetAccount()->IsKillProtect() && !on_access) { - if (na->GetAccount()->HasFieldS("KILL_IMMED")) + if (na->GetAccount()->IsKillImmed()) { u->SendMessage(*NickServ, _("This nickname has been registered; you may not use it.")); this->Collide(u, na); } - else if (na->GetAccount()->HasFieldS("KILL_QUICK")) + else if (na->GetAccount()->IsKillQuick()) { time_t killquick = Config->GetModule("nickserv/main")->Get<time_t>("killquick", "20s"); u->SendMessage(*NickServ, _("If you do not change within %s, I will change your nick."), Anope::Duration(killquick, u->Account()).c_str()); @@ -290,7 +290,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnUserLogin(User *u) override { NickServ::Nick *na = NickServ::FindNick(u->nick); - if (na && na->GetAccount() == u->Account() && !Config->GetModule("nickserv/main")->Get<bool>("nonicknameownership") && !na->GetAccount()->HasFieldS("UNCONFIRMED")) + if (na && na->GetAccount() == u->Account() && !Config->GetModule("nickserv/main")->Get<bool>("nonicknameownership") && !na->GetAccount()->IsUnconfirmed()) u->SetMode(NickServ, "REGISTERED"); const Anope::string &modesonid = Config->GetModule(this)->Get<Anope::string>("modesonid"); @@ -406,13 +406,9 @@ class NickServCore : public Module, public NickServ::NickServService NickServ = bi; - spacesepstream(conf->GetModule(this)->Get<Anope::string>("defaults", "ns_secure memo_signon memo_receive")).GetTokens(defaults); + spacesepstream(conf->GetModule(this)->Get<Anope::string>("defaults", "secure memo_signon memo_receive")).GetTokens(defaults); if (defaults.empty()) - { - defaults.push_back("NS_SECURE"); - defaults.push_back("MEMO_SIGNON"); - defaults.push_back("MEMO_RECEIVE"); - } + defaults = { "secure", "memo_signon", "memo_receive" }; else if (defaults[0].equals_ci("none")) defaults.clear(); } @@ -489,7 +485,7 @@ class NickServCore : public Module, public NickServ::NickServService void OnNickGroup(User *u, NickServ::Nick *target) override { - if (!target->GetAccount()->HasFieldS("UNCONFIRMED")) + if (!target->GetAccount()->IsUnconfirmed()) u->SetMode(NickServ, "REGISTERED"); } @@ -557,7 +553,7 @@ class NickServCore : public Module, public NickServ::NickServService { /* Reset +r and re-send account (even though it really should be set at this point) */ IRCD->SendLogin(u, na); - if (!Config->GetModule("nickserv/main")->Get<bool>("nonicknameownership") && na->GetAccount() == u->Account() && !na->GetAccount()->HasFieldS("UNCONFIRMED")) + if (!Config->GetModule("nickserv/main")->Get<bool>("nonicknameownership") && na->GetAccount() == u->Account() && !na->GetAccount()->IsUnconfirmed()) u->SetMode(NickServ, "REGISTERED"); Log(u, "", NickServ) << u->GetMask() << " automatically identified for group " << u->Account()->GetDisplay(); } @@ -620,7 +616,7 @@ class NickServCore : public Module, public NickServ::NickServService { /* Set default flags */ for (unsigned i = 0; i < defaults.size(); ++i) - na->GetAccount()->SetS<bool>(defaults[i].upper(), true); + na->GetAccount()->SetS<bool>(defaults[i], true); } void OnUserQuit(User *u, const Anope::string &msg) override @@ -668,10 +664,10 @@ class NickServCore : public Module, public NickServ::NickServService void OnNickInfo(CommandSource &source, NickServ::Nick *na, InfoFormatter &info, bool show_hidden) override { - if (!na->GetAccount()->HasFieldS("UNCONFIRMED")) + if (!na->GetAccount()->IsUnconfirmed()) { time_t nickserv_expire = Config->GetModule(this)->Get<time_t>("expire", "21d"); - if (!na->HasFieldS("NS_NO_EXPIRE") && nickserv_expire && !Anope::NoExpire && (source.HasPriv("nickserv/auspex") || na->GetLastSeen() != Anope::CurTime)) + if (!na->IsNoExpire() && nickserv_expire && !Anope::NoExpire && (source.HasPriv("nickserv/auspex") || na->GetLastSeen() != Anope::CurTime)) info[_("Expires")] = Anope::strftime(na->GetLastSeen() + nickserv_expire, source.GetAccount()); } else diff --git a/modules/nickserv/main/nicktype.cpp b/modules/nickserv/main/nicktype.cpp index 9efe55d86..b3bcdc0f7 100644 --- a/modules/nickserv/main/nicktype.cpp +++ b/modules/nickserv/main/nicktype.cpp @@ -28,7 +28,8 @@ NickType::NickType(Module *me) : Serialize::Type<NickImpl>(me) , last_realhost(this, "last_realhost", &NickImpl::last_realhost) , time_registered(this, "time_registered", &NickImpl::time_registered) , last_seen(this, "last_seen", &NickImpl::last_seen) - , nc(this, "nc", &NickImpl::account) + , account(this, "account", &NickImpl::account) + , noexpire(this, "noexpire", &NickImpl::noexpire) { } diff --git a/modules/nickserv/main/nicktype.h b/modules/nickserv/main/nicktype.h index 0779b08da..c702de5a1 100644 --- a/modules/nickserv/main/nicktype.h +++ b/modules/nickserv/main/nicktype.h @@ -38,7 +38,9 @@ class NickType : public Serialize::Type<NickImpl> Serialize::Field<NickImpl, time_t> last_seen; /* Account this nick is tied to. Multiple nicks can be tied to a single account. */ - Serialize::ObjectField<NickImpl, NickServ::Account *> nc; + Serialize::ObjectField<NickImpl, NickServ::Account *> account; + + Serialize::Field<NickImpl, bool> noexpire; NickType(Module *); |
