X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_showwhois.cpp;h=398ebf571bda40d549319385a4aed41536d7550a;hb=a5d110282a864fd2e91b51ce360a977cd0643657;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..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; } @@ -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) { - ConfigReader conf; - bool OpersOnly = conf.ReadFlag("showwhois", "opersonly", "yes", 0); - ShowWhoisFromOpers = conf.ReadFlag("showwhois", "showfromopers", "yes", 0); + } + + void init() + { + 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()