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
00016
00017
00020 class HideOper : public ModeHandler
00021 {
00022 public:
00023 HideOper(InspIRCd* Instance) : ModeHandler(Instance, 'H', 0, 0, false, MODETYPE_USER, true) { }
00024
00025 ModeAction OnModeChange(User* source, User* dest, Channel* channel, std::string ¶meter, bool adding, bool)
00026 {
00027 if (adding)
00028 {
00029 if (!dest->IsModeSet('H'))
00030 {
00031 dest->SetMode('H',true);
00032 return MODEACTION_ALLOW;
00033 }
00034 }
00035 else
00036 {
00037 if (dest->IsModeSet('H'))
00038 {
00039 dest->SetMode('H',false);
00040 return MODEACTION_ALLOW;
00041 }
00042 }
00043
00044 return MODEACTION_DENY;
00045 }
00046 };
00047
00048 class ModuleHideOper : public Module
00049 {
00050
00051 HideOper* hm;
00052 public:
00053 ModuleHideOper(InspIRCd* Me)
00054 : Module(Me)
00055 {
00056
00057 hm = new HideOper(ServerInstance);
00058 if (!ServerInstance->Modes->AddMode(hm))
00059 throw ModuleException("Could not add new modes!");
00060 Implementation eventlist[] = { I_OnWhoisLine };
00061 ServerInstance->Modules->Attach(eventlist, this, 1);
00062 }
00063
00064
00065 virtual ~ModuleHideOper()
00066 {
00067 ServerInstance->Modes->DelMode(hm);
00068 delete hm;
00069 }
00070
00071 virtual Version GetVersion()
00072 {
00073 return Version("$Id: m_hideoper.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00074 }
00075
00076 int OnWhoisLine(User* user, User* dest, int &numeric, std::string &text)
00077 {
00078
00079
00080
00081 return ((!IS_OPER(user)) && (numeric == 313) && dest->IsModeSet('H'));
00082 }
00083 };
00084
00085
00086 MODULE_INIT(ModuleHideOper)