Kod:   Kodu kopyalamak için üzerine çift tıklayın!
 /*
 * Filename:     m_helponly.c
 * Description : Channel mode +H ( HelpOp Only )
 * Author:       Ldunda <
Bu forumdaki linkleri ve resimleri görebilmek için en az 25 mesajınız olması gerekir.
>
 */
#include "config.h"
#include "struct.h"
#include "common.h"
#include "sys.h"
#include "numeric.h"
#include "msg.h"
#include "channel.h"
#include <time.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _WIN32
#include <io.h>
#endif
#include <fcntl.h>
#include "h.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif
#define ERR_HELPONLY		410
ModuleHeader MOD_HEADER(m_helponly)
  = {
	"m_helponly",
	"Channel mode +H ( Helpop Only )",
	"Channel mode +H ( Helpop Only ) ( By Ldunda )",
	"3.2-b8-1",
	NULL 
    };
    
static Cmode		*AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode);
static int			help_is_ok(aClient *, aChannel *, char *, int, int);
static int			help_only_join(aClient *, aChannel *, char *[]);
Cmode				*ModeHelpOnly;
Cmode_t				MODE_HELPONLY = 0L;
Hook				*HookPreJoin;
DLLFUNC int MOD_INIT(m_helponly)(ModuleInfo *modinfo)
{
	CmodeInfo req;
	memset(&req, 0, sizeof req);
	req.paracount	= 0;
	req.is_ok		= help_is_ok;
	req.flag		= 'H';
	ModeHelpOnly		= AddCmode(modinfo->handle, &req, &MODE_HELPONLY);
	HookPreJoin = HookAddEx(modinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, help_only_join);
	return MOD_SUCCESS;
}
DLLFUNC int MOD_LOAD(m_helponly)(int module_load)
{
	return MOD_SUCCESS;
}
DLLFUNC int MOD_UNLOAD(m_helponly)(int module_unload)
{
	return MOD_FAILED;
}
static Cmode *AddCmode(Module *module, CmodeInfo *req, Cmode_t *mode)
{
	Cmode *cmode;
	*mode = 0;
	cmode = CmodeAdd(module, *req, mode);
}
static int help_is_ok(aClient *sptr, aChannel *chptr, char *para, int type, int what)
{
	if ((type == EXCHK_ACCESS) || (type == EXCHK_ACCESS_ERR))
	{
		if (!is_chan_op(sptr, chptr))
		{
			if (type == EXCHK_ACCESS_ERR)
				sendto_one(sptr, err_str(ERR_CHANOPRIVSNEEDED),
					me.name, sptr->name, chptr->chname);
			return 0;
		}
		if (!(sptr->umodes & UMODE_HELPOP))
		{
			if (type == EXCHK_ACCESS_ERR)
				sendto_one(sptr, ":%s %d %s :Permission Denied- You do not have the correct Help Operator privileges",
				 me.name, ERR_HELPONLY, sptr->name);
			return 0;
		}
		return 1;
	}
	return 0;
}
static int help_only_join(aClient *sptr, aChannel *chptr, char *parv[])
{
	if ((chptr->mode.extmode & MODE_HELPONLY) && !IsHelpOp(sptr))
	{
		sendto_one(sptr, ":%s %d %s :Cannot join channel %s (Help Operator Only)",
			me.name, ERR_HELPONLY, sptr->name, chptr->chname);
		return 1;
	}
	return 0;
}