#!/usr/bin/perl -w use strict; Xchat::register("Swearing Warning", 1.0, "Warns a user when they swear on #boinc-credit", \&deregister); my $privmsgHandler; my @swear = ("shit", "fuck", "hell", "cock", "asshole", "gay", "lesbian", "whore"); ®ister(); my $room = "\#boinc-credit"; # Leave blank to check for any room sub register { $privmsgHandler = Xchat::hook_server("PRIVMSG", \&parse_msg); } sub deregister { Xchat::unhook($privmsgHandler); } sub parse_msg { #Xchat::command("msg Romulus echo $_[1][0]") if($_[0][2] ne "MTughan"); if($room eq "" || $_[0][2] eq $room) { my ($message, $user, $warned, $chatRoom) = ($_[1][3], $_[0][0], 0, $_[0][2]); $user = $1 if($user =~ /^:(.*)![ni]=.*@.*$/); foreach(@swear) { if($message =~ /.*$_.*/i) { next if(index(lc($message), "hell") != -1 && index(lc($message), "hell") == index(lc($message), "hello")); &warnUser($user, $chatRoom); $warned = 1; last; } } if(!$warned) { $message =~ tr/!@\#$%^&*()-_=+<>,.\/?\"\';:\\|[]{}/ /; $message =~ tr/[A-Z]/[a-z]/; my @messageArr = split(/ /, $message); foreach(@messageArr) { if($_ eq "ass") { &warnUser($user); last; } } } } return Xchat::EAT_NONE; } sub warnUser { Xchat::command("me asks $_[0] to watch their language. A message from the channel op.", $_[1]); }