X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_swhois.cpp;h=d635654a524fd1229b02031dc35f95f05dc3d677;hb=d556a4f8740b65e635ff7d2b976faaedbdac51d4;hp=3dcdb10f2bb92e46536cc36585f1d4689d971dc8;hpb=38ca8be9a3881a3cb3cf6864e67b779ffbab6874;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 3dcdb10f2..d635654a5 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -11,10 +11,10 @@ * --------------------------------------------------- */ +#include "inspircd.h" #include "users.h" #include "channels.h" #include "modules.h" -#include "inspircd.h" /* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */ @@ -33,45 +33,54 @@ class cmd_swhois : public command_t CmdResult Handle(const char** parameters, int pcnt, userrec* user) { userrec* dest = ServerInstance->FindNick(parameters[0]); - if(dest) + + if (!dest) { - std::string line; - for(int i = 1; i < pcnt; i++) - { - if (i != 1) - line.append(" "); - - line.append(parameters[i]); - } - - std::string* text; - dest->GetExt("swhois", text); - - if(text) - { - // We already had it set... - - if (!ServerInstance->ULine(user->server)) - // Ulines set SWHOISes silently - ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str()); + user->WriteServ("401 %s %s :No such nick/channel", user->nick, parameters[0]); + return CMD_FAILURE; + } + + if (!*parameters[1]) + { + user->WriteServ("NOTICE %s :*** SWHOIS: Whois line must be specified", user->nick); + return CMD_FAILURE; + } + + std::string line; + for (int i = 1; i < pcnt; i++) + { + if (i != 1) + line.append(" "); - dest->Shrink("swhois"); - DELETE(text); - } - else if(!ServerInstance->ULine(user->server)) - { + line.append(parameters[i]); + } + + std::string* text; + dest->GetExt("swhois", text); + + if (text) + { + // We already had it set... + + if (!ServerInstance->ULine(user->server)) // Ulines set SWHOISes silently - ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str()); - } + ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois from '%s' to '%s'", user->nick, dest->nick, text->c_str(), line.c_str()); - text = new std::string(line); - dest->Extend("swhois", text); - - return CMD_SUCCESS; + dest->Shrink("swhois"); + DELETE(text); + } + else if (!ServerInstance->ULine(user->server)) + { + // Ulines set SWHOISes silently + ServerInstance->WriteOpers("*** %s used SWHOIS to set %s's extra whois to '%s'", user->nick, dest->nick, line.c_str()); } + + text = new std::string(line); + dest->Extend("swhois", text); - return CMD_FAILURE; + return CMD_SUCCESS; } + }; class ModuleSWhois : public Module @@ -81,7 +90,7 @@ class ModuleSWhois : public Module ConfigReader* Conf; public: - ModuleSWhois(InspIRCd* Me) : Module::Module(Me) + ModuleSWhois(InspIRCd* Me) : Module(Me) { Conf = new ConfigReader(ServerInstance); @@ -123,7 +132,7 @@ class ModuleSWhois : public Module // this method is called. We should use the ProtoSendMetaData function after we've // corrected decided how the data should look, to send the metadata on its way if // it is ours. - virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname) + virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname, bool displayable) { // check if the linking module wants to know about OUR metadata if (extname == "swhois") @@ -255,28 +264,4 @@ class ModuleSWhois : public Module } }; - -class ModuleSWhoisFactory : public ModuleFactory -{ - public: - ModuleSWhoisFactory() - { - } - - ~ModuleSWhoisFactory() - { - } - - virtual Module * CreateModule(InspIRCd* Me) - { - return new ModuleSWhois(Me); - } - -}; - - -extern "C" void * init_module( void ) -{ - return new ModuleSWhoisFactory; -} - +MODULE_INIT(ModuleSWhois)