summaryrefslogtreecommitdiff
path: root/src/modules/m_showwhois.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 17:31:53 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-09 17:31:53 +0000
commitcbff8c76278f7cb706e3c4ae0c8bc4cb63c15f96 (patch)
treea3919e7e2eafbd831bf242a6a8efda2a8b8be0e2 /src/modules/m_showwhois.cpp
parentcd767403e9cce6cc0749160fddb9e7c82042d23c (diff)
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
Diffstat (limited to 'src/modules/m_showwhois.cpp')
-rw-r--r--src/modules/m_showwhois.cpp87
1 files changed, 56 insertions, 31 deletions
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 &parameter, 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);
}
+ }
};