/*
 * kayitli olmayan nicklerin servisler ve serverlar harici komut gondermesini ve kanallara girmesini engeller
 */

#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

#ifndef DYNAMIC_LINKING
ModuleHeader m_kayitsiz_Header
#else
#define m_kayitsiz_Header Mod_Header
ModuleHeader Mod_Header
#endif
  = {
	"m_kayitsiz",	/* Name of module */
	"v0.0.1", /* Version */
	"Kayitsiz nickler icin komut engelleme", /* Short description of module */
	"3.2.3",
	NULL 
    };

static Hook *PrivMsg = NULL, *PreJoinChan = NULL;

DLLFUNC char *priv_msg(aClient *, aClient *, aClient *, char *, int);
DLLFUNC int pre_join_chan(aClient *sptr, aChannel *acptr, char *parv[]);

DLLFUNC int MOD_INIT(m_kayitsiz)(ModuleInfo *modinfo)
{
	PrivMsg = HookAddPCharEx(modinfo->handle, HOOKTYPE_USERMSG, priv_msg);
	PreJoinChan = HookAddEx(modinfo->handle, HOOKTYPE_PRE_LOCAL_JOIN, pre_join_chan);

	if (!PrivMsg || !PreJoinChan)
		return MOD_FAILED; 

	return MOD_SUCCESS;
}

DLLFUNC int MOD_LOAD(m_kayitsiz)(int module_load)
{
	return MOD_SUCCESS;
}

DLLFUNC int MOD_UNLOAD(m_kayitsiz)(int module_unload)
{
	HookDel(HookDel);
	HookDel(PreJoinChan);
	return MOD_SUCCESS;
}

DLLFUNC char *priv_msg(aClient *cptr, aClient *sptr, aClient *acptr, char *text, int notice)
{
	if( !IsARegNick(sptr) && !IsULine(acptr) && !IsOper(sptr) )
	{
		sendto_one(sptr,":%s PRIVMSG %s :Konusabilmek icin lutfen nickinizi kaydedin...", me.name, sptr->name);
		return NULL;
	} else
		return text;
}

DLLFUNC int pre_join_chan(aClient *sptr, aChannel *acptr, char *parv[])
{
	if( !IsARegNick(sptr) && !IsOper(sptr) )
		return HOOK_DENY;

}
