m_nokicks.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
00018 class NoKicks : public SimpleChannelModeHandler
00019 {
00020 public:
00021 NoKicks(InspIRCd* Instance) : SimpleChannelModeHandler(Instance, 'Q') { }
00022 };
00023
00024 class ModuleNoKicks : public Module
00025 {
00026 NoKicks* nk;
00027
00028 public:
00029 ModuleNoKicks(InspIRCd* Me)
00030 : Module(Me)
00031 {
00032 nk = new NoKicks(ServerInstance);
00033 if (!ServerInstance->Modes->AddMode(nk))
00034 throw ModuleException("Could not add new modes!");
00035 Implementation eventlist[] = { I_OnAccessCheck, I_On005Numeric };
00036 ServerInstance->Modules->Attach(eventlist, this, 2);
00037 }
00038
00039 virtual void On005Numeric(std::string &output)
00040 {
00041 ServerInstance->AddExtBanChar('Q');
00042 }
00043
00044 virtual int OnAccessCheck(User* source,User* dest,Channel* channel,int access_type)
00045 {
00046 if (access_type == AC_KICK)
00047 {
00048 if (channel->IsModeSet('Q') || channel->IsExtBanned(source, 'Q'))
00049 {
00050 if ((ServerInstance->ULine(source->nick.c_str())) || (ServerInstance->ULine(source->server)) || (!*source->server))
00051 {
00052
00053 return ACR_ALLOW;
00054 }
00055 else
00056 {
00057
00058 source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Can't kick user %s from channel (+Q set)",source->nick.c_str(), channel->name.c_str(), dest->nick.c_str());
00059 return ACR_DENY;
00060 }
00061 }
00062 }
00063 return ACR_DEFAULT;
00064 }
00065
00066 virtual ~ModuleNoKicks()
00067 {
00068 ServerInstance->Modes->DelMode(nk);
00069 delete nk;
00070 }
00071
00072 virtual Version GetVersion()
00073 {
00074 return Version("$Id: m_nokicks.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_COMMON | VF_VENDOR, API_VERSION);
00075 }
00076 };
00077
00078
00079 MODULE_INIT(ModuleNoKicks)