swearbot : Chatbot/Badword plugin, by Mat-d-Rat HELP!!!

Discover FAST, a records keeping server control script with a public records system called Dedimania, which will show records from the server on tm-exchange.com

Moderators: Slig, TM-Patrol

Post Reply
User avatar
nicomoore0
speedy pilot
speedy pilot
Posts: 326
Joined: 27 May 2008 16:58
Owned TM-games: All
Location: Scotland

swearbot : Chatbot/Badword plugin, by Mat-d-Rat HELP!!!

Post by nicomoore0 » 12 Jan 2009 15:46

Code: Select all

<?php
////////////////////////////////////////////////////////////////
//
// File:      Swear bot for fast 3.2x
// Date:      21.04.2008
// Author:    Matthew Augier AKA Mat-d-Rat
// 
////////////////////////////////////////////////////////////////

registerPlugin('swearbot',81,1.0);

function swearbotPlayerChat($event,$plogin,$msg){
	global $_players;

	// remote or other entry
	if (!isset($_players[$plogin]["Active"])) {
		return 0;
		}

	// set this for max number of swears before kick
	$swearbot_max=1;

	// after 2am swearing should be ok
 	if (Date("H")>=2) {
		return 0;
	}
	// before 3am swearing ok
  	if (Date("H")<=3) {
		return 0;	
	}

	// list of words to count
	$bad_Words = array(	'merde','****','****',
					'dick', 'cock', 'merda',
					'sucks', 'scheise', 'scheiße', 'scheis',
					'baskasöle', 'baskasole', 'cocugu', 'kodugumun','cazo',
					'penis', 'fotze', 'ffs', 'piss', 'nigger', 
					'orospu', 'bitch', 'pédé', '****', 'wtf', 'wank', 
					'fck', 'fuk', 'bastard', '*******', 'blowjob', 'prick',
					'prik', 'fu ', 'omfg', 'bolox', 'bollock', 'fkin', 'gay'
				);
	
	// modify the msg to check
	$texte=$msg;
	$texte=str_replace("|_|","u",$texte);
	$texte=str_replace(".","",$texte);
	$texte=str_replace("*","",$texte);

	// check for each word int eh string
	foreach($bad_Words As $mot) {
		if (stristr($msg, $mot)) {
			// detected a BAD word!
			// see if array exists, if not create
			if (!isset($_players[$plogin]["SwearCount"])) {
				$_players[$plogin]["SwearCount"] = 0;
				}
			// set our counter
			$_players[$plogin]["SwearCount"]++;
			if ($_players[$plogin]["SwearCount"]==$swearbot_max) {
				// too many kick!
				addCall(null,"ChatSendServerMessage", "Kicking ".$_players[$plogin]["NickName"].'$fff'." ($plogin) for swearing ".$_players[$plogin]["SwearCount"]."/$swearbot_max");
				addCall(null,"Kick",$plogin);
				unset($_players[$plogin]["SwearCount"]);
				return 0;
				}
			  else {
				// jsut warn!
				addCall(null,"ChatSendServerMessage", "Please do not swear ".$_players[$plogin]["NickName"].'$fff'." ($plogin) count ".$_players[$plogin]["SwearCount"]."/$swearbot_max");
				}
			}		
	
		}
}

?>

This is the code I used for the swearbot, but it doesn't seem to work does anyone have a solution?
I m also trying to get it to work 24/7 instead of a sset time period.

Thanks n advance!
C®AżΨ αηηιнιllαтσя ッ
We Are Crazy server <<-- Click to join
Server Location
United Kingdom -> England -> London

Racemaniac
TM-Patrol
TM-Patrol
Posts: 2480
Joined: 13 Aug 2005 10:57
Owned TM-games: all
Manialink(s): racemaniac
Location: Belgium
Contact:

Re: swearbot : Chatbot/Badword plugin, by Mat-d-Rat HELP!!!

Post by Racemaniac » 12 Jan 2009 22:08

just remove
// after 2am swearing should be ok
if (Date("H")>=2) {
return 0;
}
// before 3am swearing ok
if (Date("H")<=3) {
return 0;
}

to disable the timing

besides that, i don't write such plugins, so i could be missing something, but as far as i understand that piece of code, all it does is kick people if they swear too much, not prevent the swearing from appearing in the chat (if that's what your purpose is?)
as much as the trackmanias may rule, carmageddon 1 & 2 are still the best games ever :D

User avatar
nicomoore0
speedy pilot
speedy pilot
Posts: 326
Joined: 27 May 2008 16:58
Owned TM-games: All
Location: Scotland

Re: swearbot : Chatbot/Badword plugin, by Mat-d-Rat HELP!!!

Post by nicomoore0 » 13 Jan 2009 06:08

Racemaniac wrote:just remove
// after 2am swearing should be ok
if (Date("H")>=2) {
return 0;
}
// before 3am swearing ok
if (Date("H")<=3) {
return 0;
}

to disable the timing

besides that, i don't write such plugins, so i could be missing something, but as far as i understand that piece of code, all it does is kick people if they swear too much, not prevent the swearing from appearing in the chat (if that's what your purpose is?)
I mean't the Bot itself would not work. I got someone from another server to test it and it didn't work for them either. I got the link to download the php script from here, made one edit to it (the time limit) and that was it.

I even went back to the uneditted version and that didn't work either. Again meaning..... It was as if it didn't exist!

Thanks in advance for any support!
C®AżΨ αηηιнιllαтσя ッ
We Are Crazy server <<-- Click to join
Server Location
United Kingdom -> England -> London

User avatar
Generator
speedy pilot
speedy pilot
Posts: 339
Joined: 18 Apr 2008 00:35
Owned TM-games: TMNF - TMUF
Manialink(s): Generator
Location: Lancashire, England
Contact:

Re: swearbot : Chatbot/Badword plugin, by Mat-d-Rat HELP!!!

Post by Generator » 20 Jan 2009 01:05

It WILL appear that your plug-in adoption wont work because you have only give it chance to work between 2am and 3am, anything outside this timezone wont do anything.

Here's my adoptation with no time limits (due to the code being commented)

Code: Select all

<?php
////////////////////////////////////////////////////////////////
//
// File:      Swear bot for fast 3.2x
// Date:      21.04.2008
// Author:    Matthew Augier AKA Mat-d-Rat
// 
////////////////////////////////////////////////////////////////

registerPlugin('swearbot',81,1.0);

function swearbotPlayerChat($event,$plogin,$msg){
	global $_players;

	// remote or other entry
	if (!isset($_players[$plogin]["Active"])) {
		return 0;
		}

	// set this for max number of swears before kick
	$swearbot_max=3;

	// after 9pm swearing should be ok
 	//if (Date("H")>=21) {
	//	return 0;
	//}
	// before 5am swearing ok
  	//if (Date("H")<=5) {
	//	return 0;	
	//}

	// list of words to count
	$bad_Words = array(	'merde','****','****',
					'dick', 'cock', 'merda',
					'sucks', 'scheise', 'scheiße', 'scheis',
					'baskasöle', 'baskasole', 'cocugu', 'kodugumun','cazo',
					'penis', 'fotze', 'ffs', 'piss', 'nigger', 
					'orospu', 'bitch', 'pédé', '****', 'wtf', 'wank', 
					'fck', 'fuk', 'bastard', '*******', 'blowjob', 'prick',
					'prik', 'fu ', 'omfg', 'bolox', 'bollock', 'fkin'
				);
	
	// modify the msg to check
	$texte=$msg;
	$texte=str_replace("|_|","u",$texte);
	$texte=str_replace(".","",$texte);
	$texte=str_replace("*","",$texte);

	// check for each word int eh string
	foreach($bad_Words As $mot) {
		if (stristr($msg, $mot)) {
			// detected a BAD word!
			// see if array exists, if not create
			if (!isset($_players[$plogin]["SwearCount"])) {
				$_players[$plogin]["SwearCount"] = 0;
				}
			// set our counter
			$_players[$plogin]["SwearCount"]++;
			if ($_players[$plogin]["SwearCount"]==$swearbot_max) {
				// too many kick!
				addCall(null,"ChatSendServerMessage", "Kicking ".$_players[$plogin]["NickName"].'$fff'." ($plogin) for swearing ".$_players[$plogin]["SwearCount"]."/$swearbot_max");
				addCall(null,"Kick",$plogin);
				unset($_players[$plogin]["SwearCount"]);
				return 0;
				}
			  else {
				// jsut warn!
				addCall(null,"ChatSendServerMessage", "Please do not swear ".$_players[$plogin]["NickName"].'$fff'." ($plogin) count ".$_players[$plogin]["SwearCount"]."/$swearbot_max");
				}
			}		
	
		}
}

?>
This code is took straight from my plugin folder and works for me 24hrs a day. :thumbsup:
Customize your virtual world to the max! >> http://www.virtualcustoms.net
3D Models, 2D skins & horns on my Manialink >> Generatorcolor>

Post Reply