diff options
| author | 2022-12-27 17:57:54 +0000 | |
|---|---|---|
| committer | 2022-12-27 18:19:10 +0000 | |
| commit | 75de6e0d5c28d0a4f798a02be024e45f148bc52c (patch) | |
| tree | 1e4b18a50051b3950716f79c0818a0cf5e7a5bcb /src/modules/m_account.cpp | |
| parent | Merge branch 'insp3' into master. (diff) | |
Add the ListExtItem extension type.
Diffstat (limited to 'src/modules/m_account.cpp')
| -rw-r--r-- | src/modules/m_account.cpp | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/src/modules/m_account.cpp b/src/modules/m_account.cpp index 33ca64929..3e1795ed5 100644 --- a/src/modules/m_account.cpp +++ b/src/modules/m_account.cpp @@ -83,54 +83,13 @@ public: } }; - -class AccountNicksExtItem final - : public SimpleExtItem<Account::NickList> -{ -public: - AccountNicksExtItem(Module* mod) - : SimpleExtItem<Account::NickList>(mod, "accountnicks", ExtensionType::USER, true) - { - } - - void FromInternal(Extensible* container, const std::string& value) noexcept override - { - if (container->extype != this->extype) - return; - - auto list = new Account::NickList(); - irc::spacesepstream nickstream(value); - for (std::string nick; nickstream.GetToken(nick); ) - list->insert(nick); - - if (list->empty()) - { - // The remote sent an empty list of nicknames for some reason. - delete list; - Unset(container); - } - else - { - // The remote sent a non-zero list of nicks; set it. - Set(container, list); - } - } - - std::string ToInternal(const Extensible* container, void* item) const noexcept override - { - auto list = static_cast<Account::NickList*>(item); - return stdalgo::string::join(*list); - } -}; - - class AccountAPIImpl final : public Account::APIBase { private: AccountExtItemImpl accountext; StringExtItem accountidext; - AccountNicksExtItem accountnicksext; + ListExtItem<Account::NickList> accountnicksext; UserModeReference identifiedmode; public: @@ -138,7 +97,7 @@ public: : Account::APIBase(mod) , accountext(mod) , accountidext(mod, "accountid", ExtensionType::USER, true) - , accountnicksext(mod) + , accountnicksext(mod, "accountnicks", ExtensionType::USER, true) , identifiedmode(mod, "u_registered") { } |
