/*
 Netdelisi..
 */

#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

static Hook *Notice;

DLLFUNC char *cb_chanmsg(aClient *, aClient *, aClient *, char *, int);

ModuleHeader MOD_HEADER(cb_chanmsg)
  = {
	"cb_chanmsg v0.1",
	"kayitsiz nickler icin kanalda konusma engelleme",
	"NeTDeLiSi (Diablo modulu uzerine editlenmistir)",
	"3.2-b8-1",
	NULL 
    };

#define SURE 60

DLLFUNC int MOD_INIT(cb_chanmsg)(ModuleInfo *modinfo)
{
	Notice = HookAddPCharEx(modinfo->handle, HOOKTYPE_CHANMSG, cb_chanmsg);

	return MOD_SUCCESS;
}

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

DLLFUNC int MOD_UNLOAD(cb_chanmsg)(int module_unload)
{
	return MOD_SUCCESS;
}

DLLFUNC char *cb_chanmsg(aClient *cptr, aClient *sptr, aClient *acptr, char *text, int notice)
{
	 if(!IsARegNick(sptr) && !IsULine(acptr) && !IsServer(sptr) && !IsOper(sptr) && !(sptr->umodes & UMODE_SECURE) && 0 < SURE - (TStime() - sptr->firsttime))
	{
		sendto_one(sptr,":%s NOTICE %s :Kanala mesaj gondermek icin %d saniye beklemeniz gerekiyor", me.name, sptr->name, SURE - (TStime() - sptr->firsttime));
		return NULL;
	} else
		return text;
}
