X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_showwhois.cpp;h=398ebf571bda40d549319385a4aed41536d7550a;hb=7b5703b9a22e176ef6a47b405f2b0d5ce122df0a;hp=6eec64bd5e5daf0e92a032ab0584efcf27ccd9b7;hpb=3699b0fb216b16b96ba941f33471fcc52e135f50;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index 6eec64bd5..398ebf571 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -27,41 +27,19 @@ /** 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 { public: - WhoisNoticeCmd(Module* Creator) : Command(Creator,"WHOISNOTICE", 1) + WhoisNoticeCmd(Module* Creator) : Command(Creator,"WHOISNOTICE", 2) { flags_needed = FLAG_SERVERONLY; } @@ -96,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()