X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_swhois.cpp;h=c868060984175f8afa8f0c15a65e1c44ed051f18;hb=6bc3d71946b339a5a10ca621b029fe8a5b180d68;hp=741031561e7bfaaceaea6279e609d804e8d12063;hpb=12737ab4ad61a0d8a908c8a21594c7012e21eb3c;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 741031561..c86806098 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -2,12 +2,9 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * - * - * Written by Craig Edwards, Craig McLure, and others. + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits + * * This program is free but copyrighted software; see * the file COPYING for details. * @@ -17,24 +14,23 @@ #include "users.h" #include "channels.h" #include "modules.h" -#include "helperfuncs.h" #include "inspircd.h" /* $ModDesc: Provides the SWHOIS command which allows setting of arbitary WHOIS lines */ - - +/** Handle /SWHOIS + */ class cmd_swhois : public command_t { public: - cmd_swhois (InspIRCd* Instance) : command_t(Instance,"SWHOIS",'o',2) + cmd_swhois (InspIRCd* Instance) : command_t(Instance,"SWHOIS",'o',2) { this->source = "m_swhois.so"; syntax = " "; } - void Handle(const char** parameters, int pcnt, userrec* user) + CmdResult Handle(const char** parameters, int pcnt, userrec* user) { userrec* dest = ServerInstance->FindNick(parameters[0]); if(dest) @@ -55,14 +51,14 @@ class cmd_swhois : public command_t { // We already had it set... - if (!ServerInstance->IsUlined(user->server)) + 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()); dest->Shrink("swhois"); DELETE(text); } - else if(!ServerInstance->IsUlined(user->server)) + 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()); @@ -70,7 +66,11 @@ class cmd_swhois : public command_t text = new std::string(line); dest->Extend("swhois", text); + + return CMD_SUCCESS; } + + return CMD_FAILURE; } }; @@ -97,7 +97,7 @@ class ModuleSWhois : public Module void Implements(char* List) { - List[I_OnWhois] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnOper] = 1; + List[I_OnWhois] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnPostCommand] = 1; } // :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games. @@ -107,7 +107,7 @@ class ModuleSWhois : public Module dest->GetExt("swhois", swhois); if (swhois) { - source->WriteServ("320 %s %s :%s",source->nick,dest->nick,swhois->c_str()); + ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :%s",source->nick,dest->nick,swhois->c_str()); } } @@ -184,32 +184,50 @@ class ModuleSWhois : public Module } } - virtual void OnOper(userrec* user, const std::string &opertype) + virtual void OnPostCommand(const std::string &command, const char **params, int pcnt, userrec *user, CmdResult result, const std::string &original_line) { - for(int i =0; i < Conf->Enumerate("type"); i++) + if ((command != "OPER") || (result != CMD_SUCCESS)) + return; + + std::string swhois; + + for (int i = 0; i < Conf->Enumerate("oper"); i++) { - std::string type = Conf->ReadValue("type", "name", i); + std::string name = Conf->ReadValue("oper", "name", i); - if(strcmp(type.c_str(), user->oper) == 0) + if (name == params[0]) + { + swhois = Conf->ReadValue("oper", "swhois", i); + break; + } + } + + if (!swhois.length()) + { + for (int i = 0; i < Conf->Enumerate("type"); i++) { - std::string swhois = Conf->ReadValue("type", "swhois", i); + std::string type = Conf->ReadValue("type", "name", i); - if(swhois.length()) + if (type == user->oper) { - std::string* old; - if(user->GetExt("swhois", old)) - { - user->Shrink("swhois"); - DELETE(old); - } - - std::string* text = new std::string(swhois); - user->Extend("swhois", text); - + swhois = Conf->ReadValue("type", "swhois", i); break; } } - } + } + + std::string *old; + if (user->GetExt("swhois", old)) + { + user->Shrink("swhois"); + DELETE(old); + } + + if (!swhois.length()) + return; + + std::string *text = new std::string(swhois); + user->Extend("swhois", text); } virtual ~ModuleSWhois() @@ -219,7 +237,7 @@ class ModuleSWhois : public Module virtual Version GetVersion() { - return Version(1,0,0,0,VF_VENDOR); + return Version(1,1,0,0,VF_VENDOR,API_VERSION); } };