diff options
-rw-r--r-- | include/modules.h | 9 | ||||
-rw-r--r-- | src/modules.cpp | 1 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 37 | ||||
-rw-r--r-- | src/users.cpp | 1 |
4 files changed, 42 insertions, 6 deletions
diff --git a/include/modules.h b/include/modules.h index 4d4d0871f..b16dcc49a 100644 --- a/include/modules.h +++ b/include/modules.h @@ -116,7 +116,7 @@ struct ModResult { * and numerical comparisons in preprocessor macros if they wish to support * multiple versions of InspIRCd in one file. */ -#define INSPIRCD_VERSION_API 10 +#define INSPIRCD_VERSION_API 11 /** * This #define allows us to call a method in all @@ -332,7 +332,7 @@ enum Implementation I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnRemoteKill, I_OnLoadModule, I_OnUnloadModule, I_OnBackgroundTimer, I_OnPreCommand, I_OnCheckReady, I_OnCheckInvite, I_OnRawMode, I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnCheckChannelBan, I_OnExtBanCheck, - I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange, + I_OnStats, I_OnChangeLocalUserHost, I_OnPreTopicChange, I_OnPostDeoper, I_OnPostTopicChange, I_OnEvent, I_OnGlobalOper, I_OnPostConnect, I_OnAddBan, I_OnDelBan, I_OnChangeLocalUserGECOS, I_OnUserRegister, I_OnChannelPreDelete, I_OnChannelDelete, I_OnPostOper, I_OnSyncNetwork, I_OnSetAway, I_OnPostCommand, I_OnPostJoin, @@ -555,6 +555,11 @@ class CoreExport Module : public classbase, public usecountbase */ virtual void OnPostOper(User* user, const std::string &opername, const std::string &opertype); + /** Called after a user deopers locally. + * @param user The user who has deopered. + */ + virtual void OnPostDeoper(User* user); + /** Called whenever a user types /INFO. * The User will contain the information of the user who typed the command. Modules may use this * method to output their own credits in /INFO (which is the ircd's version of an about box). 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 */ |