diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 37 | ||||
-rw-r--r-- | src/users.cpp | 1 |
3 files changed, 35 insertions, 4 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index 79a33e617..7df7579bf 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -99,6 +99,7 @@ ModResult Module::OnUserPreJoin(User*, Channel*, const char*, std::string&, cons void Module::OnMode(User*, void*, int, const std::vector<std::string>&, const std::vector<TranslateType>&) { } void Module::OnOper(User*, const std::string&) { } void Module::OnPostOper(User*, const std::string&, const std::string &) { } +void Module::OnPostDeoper(User*) { } void Module::OnInfo(User*) { } void Module::OnWhois(User*, User*) { } ModResult Module::OnUserPreInvite(User*, User*, Channel*, time_t) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 742781747..b29d268d1 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -32,8 +32,12 @@ class CommandSwhois : public Command { public: + LocalIntExt operblock; StringExtItem swhois; - CommandSwhois(Module* Creator) : Command(Creator,"SWHOIS", 2,2), swhois("swhois", Creator) + CommandSwhois(Module* Creator) + : Command(Creator,"SWHOIS", 2,2) + , operblock("swhois_operblock", Creator) + , swhois("swhois", Creator) { flags_needed = 'o'; syntax = "<nick> :<swhois>"; TRANSLATE3(TR_NICK, TR_TEXT, TR_END); @@ -63,6 +67,7 @@ class CommandSwhois : public Command ServerInstance->SNO->WriteGlobalSno('a', "%s used SWHOIS to set %s's extra whois to '%s'", user->nick.c_str(), dest->nick.c_str(), parameters[1].c_str()); } + operblock.set(user, 0); if (parameters[1].empty()) swhois.unset(dest); else @@ -92,9 +97,9 @@ class ModuleSWhois : public Module void init() { - ServerInstance->Modules->AddService(cmd); - ServerInstance->Modules->AddService(cmd.swhois); - Implementation eventlist[] = { I_OnWhoisLine, I_OnPostOper }; + ServiceProvider* providerlist[] = { &cmd, &cmd.operblock, &cmd.swhois }; + ServerInstance->Modules->AddServices(providerlist, sizeof(providerlist)/sizeof(ServiceProvider*)); + Implementation eventlist[] = { I_OnWhoisLine, I_OnPostOper, I_OnPostDeoper, I_OnDecodeMetaData }; ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } @@ -126,10 +131,34 @@ class ModuleSWhois : public Module if (!swhois.length()) return; + cmd.operblock.set(user, 1); cmd.swhois.set(user, swhois); ServerInstance->PI->SendMetaData(user, "swhois", swhois); } + void OnPostDeoper(User* user) + { + std::string* swhois = cmd.swhois.get(user); + if (!swhois) + return; + + if (!cmd.operblock.get(user)) + return; + + cmd.operblock.set(user, 0); + cmd.swhois.unset(user); + ServerInstance->PI->SendMetaData(user, "swhois", ""); + } + + void OnDecodeMetaData(Extensible* target, const std::string& extname, const std::string&) + { + // XXX: We use a dynamic_cast in m_services_account so I used one + // here but do we actually need it or is static_cast okay? + User* dest = dynamic_cast<User*>(target); + if (dest && (extname == "swhois")) + cmd.operblock.set(dest, 0); + } + ~ModuleSWhois() { } diff --git a/src/users.cpp b/src/users.cpp index 9e06485e5..ac87f1187 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -692,6 +692,7 @@ void User::UnOper() ServerInstance->Users->all_opers.remove(this); this->modes[UM_OPERATOR] = 0; + FOREACH_MOD(I_OnPostDeoper, OnPostDeoper(this)); } /* adds or updates an entry in the whowas list */ |