# Sheep.pl v. .02
# 
# Script revised on October 10, 2003
# 
# Original sheep.pl script written on April 12, 2003
#


use Irssi;
use vars qw($VERSION %IRSSI);

$VERSION = ".02";
%IRSSI = (
    authors => 'pleia2',
    contact => 'lyz@princessleia.com ',
    name => 'imasheep',
    description => 'responds with "baah" when someone says bah baah baaah etc. or sheep',
    license => 'GNU GPL',
    url => 'http://www.princessleia.com'
);

sub event_privmsg {
my ($server, $data, $nick) =@_;
my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
        if ($target =~ /^# */i) {
                if ( $text =~ /.*baa*h.*|.*sheep.*/i) {
                $server->command ( "msg $target baah" );
                }
        }
        else {
                if ( $text =~ /.*baa*h.*|.*sheep.*/i) {
                $server->command ( "msg $nick baah" );
                }
        }
}

sub action_response {
my ($server, $msg, $nick, $address, $target) = @_;
        if ($target =~ /^# */i) {
                return if $msg !~ /^ACTION.*baa*h.*|^ACTION.*sheep.*/i;
                $server->command("action $target baah")
        }
        else {
                return if $msg !~ /^ACTION.*baa*h.*|^ACTION.*sheep.*/i;
                $server->command ( "msg $nick baah" );
        }
}

Irssi::signal_add('event privmsg', 'event_privmsg');
Irssi::signal_add('ctcp msg','action_response');