X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_showwhois.cpp;h=459e4866458f8690e2a500755f527c38510a3367;hb=551d687ec6d7ce44be35fae0dd7345fe73c4f63a;hp=691887429fd316b167f45ea5c0673908789b4922;hpb=46a39046196f55b52336e19662bb7bac85b731ac;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index 691887429..459e48664 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -27,35 +27,13 @@ /** Handle user mode +W */ -class SeeWhois : public ModeHandler +class SeeWhois : public SimpleUserModeHandler { public: - SeeWhois(Module* Creator, bool IsOpersOnly) : ModeHandler(Creator, "showwhois", 'W', PARAM_NONE, MODETYPE_USER) + SeeWhois(Module* Creator, bool IsOpersOnly) : SimpleUserModeHandler(Creator, "showwhois", 'W') { oper = IsOpersOnly; } - - ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding) - { - if (adding) - { - if (!dest->IsModeSet('W')) - { - dest->SetMode('W',true); - return MODEACTION_ALLOW; - } - } - else - { - if (dest->IsModeSet('W')) - { - dest->SetMode('W',false); - return MODEACTION_ALLOW; - } - } - - return MODEACTION_DENY; - } }; class WhoisNoticeCmd : public Command @@ -76,6 +54,9 @@ class WhoisNoticeCmd : public Command CmdResult Handle(const std::vector ¶meters, User *user) { User* dest = ServerInstance->FindNick(parameters[0]); + if (!dest) + return CMD_FAILURE; + User* source = ServerInstance->FindNick(parameters[1]); if (IS_LOCAL(dest) && source) @@ -93,18 +74,23 @@ class ModuleShowwhois : public Module public: - ModuleShowwhois() : cmd(this) + ModuleShowwhois() + : sw(NULL), cmd(this) + { + } + + void init() { - ConfigReader conf; - bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0); - ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0); + ConfigTag* tag = ServerInstance->Config->ConfValue("showwhois"); + + bool OpersOnly = tag->getBool("opersonly", true); + ShowWhoisFromOpers = tag->getBool("showfromopers", true); sw = new SeeWhois(this, OpersOnly); - if (!ServerInstance->Modes->AddMode(sw)) - throw ModuleException("Could not add new modes!"); - ServerInstance->AddCommand(&cmd); + ServerInstance->Modules->AddService(*sw); + ServerInstance->Modules->AddService(cmd); Implementation eventlist[] = { I_OnWhois }; - ServerInstance->Modules->Attach(eventlist, this, 1); + ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation)); } ~ModuleShowwhois() @@ -122,7 +108,7 @@ class ModuleShowwhois : public Module if (!dest->IsModeSet('W') || source == dest) return; - if (!ShowWhoisFromOpers && IS_OPER(source)) + if (!ShowWhoisFromOpers && source->IsOper()) return; if (IS_LOCAL(dest)) @@ -139,7 +125,7 @@ class ModuleShowwhois : public Module ServerInstance->PI->SendEncapsulatedData(params); } } - }; MODULE_INIT(ModuleShowwhois) +