All pastes #794405 Raw Edit

Someone

public cpp v1 · immutable
#794405 ·published 2007-11-23 02:45 UTC
rendered paste body
#include "inspircd.h"#include <stdio.h>#include <string>#include "users.h"#include "channels.h"#include "modules.h"#include "configreader.h"class FagMode : public ModeHandler{ public:	FagMode(InspIRCd* Instance) : ModeHandler(Instance, 'F', 0, 0, false, MODETYPE_USER, false) { }	ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)	{		if (adding)		{			if (!dest->IsModeSet('F'))			{				dest->SetMode('F',true);				return MODEACTION_ALLOW;			}		}		else		{			if (dest->IsModeSet('F'))			{				dest->SetMode('F',false);				return MODEACTION_ALLOW;			}		}				return MODEACTION_DENY;	}};class FagChanMode : public ModeHandler { public:	FagChanMode(InspIRCd* Instance) : ModeHandler(Instance, 'Z', 0, 0, false, MODETYPE_CHANNEL, false) { }	ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding) {		if (adding) {			if (!channel->IsModeSet('Z')) {				channel->SetMode('Z',true);				return MODEACTION_ALLOW;			}		} else {			if (channel->IsModeSet('Z')) {				channel->SetMode('Z',false);				return MODEACTION_ALLOW;			}		}		return MODEACTION_DENY;	}};class ModuleFagMode : public Module{		FagMode* fm;	FagChanMode* fcm; public:	ModuleFagMode(InspIRCd* Me)		: Module(Me)	{				fm = new FagMode(ServerInstance);		if (!ServerInstance->AddMode(fm, 'F'))			throw ModuleException("Could not add new modes!");		fcm = new FagChanMode(ServerInstance);		if (!ServerInstance->AddMode(fcm, 'Z'))			throw ModuleException("Could not add new modes!");	}	void Implements(char* List)	{		List[I_OnWhois] = List[I_OnUserPreJoin] = 1;	}		virtual ~ModuleFagMode()	{		ServerInstance->Modes->DelMode(fm);		DELETE(fm);	}		virtual Version GetVersion()	{		return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);	}	virtual void OnWhois(userrec* src, userrec* dst)	{		if (dst->IsModeSet('F'))		{			ServerInstance->SendWhoisLine(src, dst, 320, std::string(src->nick)+" "+std::string(dst->nick)+" :is a faggot on "+ServerInstance->Config->Network);		}	}	virtual int OnUserPreJoin(userrec* user, chanrec* chan, const char* cname, std::string &privs) {		if (chan) {			if (chan->IsModeSet('Z') && !user->IsModeSet('F')) {				user->WriteServ("520 %s %s :Only Faggots (UMode +F) may join the channel %s (+Z is set)",user->nick, chan->name,chan->name);				return 1;			}		}		return 0;	}};MODULE_INIT(ModuleFagMode)