# Madness? Sparta!
#
# This script requires you to have the text file "sparta" in your /home/user/.irssi/ directory

use Irssi;

use vars qw($VERSION %IRSSI);

$VERSION = "1.0";
%IRSSI = (
    author => 'pleia2',
    contact => 'lyz@princessleia.com ',
    name => 'sparta',
    description => 'This is sparta!',
    license => 'GNU GPL v2 or later',
    url => 'http://www.princessleia.com'
);

open ( SPARTA, "<.irssi/sparta" ) or die "can't open ur:$!\n";
chomp( @sparta = <SPARTA> );
close SPARTA;

sub event_privmsg {
my ($server, $data, $nick, $mask) =@_;
my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
    return if ( $text !~ / madness |^madness$|^madness | madness$/i );
       $spartaquote = $sparta[rand @sparta];
          $server->command ( "msg $target $spartaquote" );
}

Irssi::signal_add('event privmsg', 'event_privmsg');
