/*
 *   IRC - Internet Relay Chat, topicbadwords.c
 *   (C) 2003 Dominick Meglio
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 1, or (at your option)
 *   any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#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"
#include "proto.h"
#ifdef STRIPBADWORDS
#include "badwords.h"
#endif
#ifdef _WIN32
#include "version.h"
#endif

ModuleHeader MOD_HEADER(topicbadwords)
  = {
	"topicbadwords",
	"1.0",
	"Topic koruma modulu <www.iDeaLSHeLL.CoM> By : MaviOkyanuS", 
	"3.2-b8-1",
	NULL 
    };

char *h_noswear_topic(aClient *sptr, aChannel *chptr, char *text);

DLLFUNC int MOD_INIT(topicbadwords)(ModuleInfo *modinfo)
{
	HookAddPCharEx(modinfo->handle, HOOKTYPE_PRE_LOCAL_TOPIC, h_noswear_topic);
	return MOD_SUCCESS;
}

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

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

char *h_noswear_topic(aClient *sptr, aChannel *chptr, char *text)
{
#ifdef STRIPBADWORDS
	int blocked = 0;
	if (IsULine(sptr) || IsServer(sptr) || IsAnOper(sptr))
		return text;
	text = stripbadwords_channel(text, &blocked);
	if (blocked)
		return NULL;
#endif
	return text;
}