From cbff8c76278f7cb706e3c4ae0c8bc4cb63c15f96 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 9 Jul 2006 17:31:53 +0000 Subject: And we're all done!!! (well, it compiles, anyway) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4235 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_showwhois.cpp | 87 +++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 31 deletions(-) (limited to 'src/modules/m_showwhois.cpp') diff --git a/src/modules/m_showwhois.cpp b/src/modules/m_showwhois.cpp index 519b13352..c7ba52035 100644 --- a/src/modules/m_showwhois.cpp +++ b/src/modules/m_showwhois.cpp @@ -10,49 +10,74 @@ using namespace std; /* $ModDesc: Allows opers to set +W to see when a user uses WHOIS on them */ -class ModuleShowwhois : public Module +class SeeWhois : public ModeHandler { - Server* Srv; - - public: - ModuleShowwhois(Server* Me) - : Module::Module(Me) - { - Srv = Me; - Srv->AddExtendedMode('W',MT_CLIENT,true,0,0); - } + public: + SeeWhois() : ModeHandler('W', 0, 0, false, MODETYPE_CHANNEL, false) { } - ~ModuleShowwhois() - { - } - - void Implements(char* List) - { - List[I_OnWhois] = List[I_OnExtendedMode] = 1; - } + ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding) + { + /* Only opers can change other users modes */ + if ((source != dest) && (!*source->oper)) + return MODEACTION_DENY; - virtual Version GetVersion() + if (adding) { - return Version(1,0,0,3,VF_STATIC); + if (!channel->IsModeSet('W')) + { + dest->SetMode('W',true); + return MODEACTION_ALLOW; + } } - - virtual int OnExtendedMode(userrec* user, void* target, char modechar, int type, bool mode_on, string_list& params) + else { - if((type == MT_CLIENT) && (modechar == 'W')) + if (channel->IsModeSet('W')) { - return 1; + dest->SetMode('W',false); + return MODEACTION_ALLOW; } - - return 0; } - virtual void OnWhois(userrec* source, userrec* dest) + return MODEACTION_DENY; + } +}; + +class ModuleShowwhois : public Module +{ + Server* Srv; + SeeWhois* sw; + + public: + + ModuleShowwhois(Server* Me) : Module::Module(Me) + { + Srv = Me; + sw = new SeeWhois(); + Srv->AddMode(sw, 'W'); + } + + ~ModuleShowwhois() + { + DELETE(sw); + } + + void Implements(char* List) + { + List[I_OnWhois] = 1; + } + + virtual Version GetVersion() + { + return Version(1,0,0,3,VF_STATIC); + } + + virtual void OnWhois(userrec* source, userrec* dest) + { + if ((dest->IsModeSet('W')) && (source != dest)) { - if ((dest->modes['W'-65]) && (source != dest)) - { - WriteServ(dest->fd,"NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host); - } + WriteServ(dest->fd,"NOTICE %s :*** %s (%s@%s) did a /whois on you.",dest->nick,source->nick,source->ident,source->host); } + } }; -- cgit v1.2.3