summaryrefslogtreecommitdiff
path: root/src/modules/m_showwhois.cpp
diff options
context:
space:
mode:
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);
}
+ }
};