m_hideoper.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015 #include "users.h"
00016 #include "channels.h"
00017 #include "modules.h"
00018
00019
00020
00023 class HideOper : public ModeHandler
00024 {
00025 public:
00026 HideOper(InspIRCd* Instance) : ModeHandler(Instance, 'H', 0, 0, false, MODETYPE_USER, true) { }
00027
00028 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
00029 {
00030 if (source != dest)
00031 return MODEACTION_DENY;
00032
00033 if (adding)
00034 {
00035 if (!dest->IsModeSet('H'))
00036 {
00037 dest->SetMode('H',true);
00038 return MODEACTION_ALLOW;
00039 }
00040 }
00041 else
00042 {
00043 if (dest->IsModeSet('H'))
00044 {
00045 dest->SetMode('H',false);
00046 return MODEACTION_ALLOW;
00047 }
00048 }
00049
00050 return MODEACTION_DENY;
00051 }
00052 };
00053
00054 class ModuleHideOper : public Module
00055 {
00056
00057 HideOper* hm;
00058 public:
00059 ModuleHideOper(InspIRCd* Me)
00060 : Module(Me)
00061 {
00062
00063 hm = new HideOper(ServerInstance);
00064 if (!ServerInstance->AddMode(hm, 'H'))
00065 throw ModuleException("Could not add new modes!");
00066 }
00067
00068 void Implements(char* List)
00069 {
00070 List[I_OnWhoisLine] = 1;
00071 }
00072
00073 virtual ~ModuleHideOper()
00074 {
00075 ServerInstance->Modes->DelMode(hm);
00076 DELETE(hm);
00077 }
00078
00079 virtual Version GetVersion()
00080 {
00081 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
00082 }
00083
00084 int OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text)
00085 {
00086
00087
00088
00089 return ((!IS_OPER(user)) && (numeric == 313) && dest->IsModeSet('H'));
00090 }
00091 };
00092
00093
00094 MODULE_INIT(ModuleHideOper)