# This script responds with a comment each time someone in the channel says "clockbot"
#
# This script requires you to have the text file "clockbot" in your /home/user/.irssi/ directory


use Irssi;

use vars qw($VERSION %IRSSI);

$VERSION = "1.0";
%IRSSI = (
    author => 'pleia2',
    contact => 'lyz@princessleia.com ',
    name => 'clockbot',
    description => 'Responds with special message each time someone says clockbot',
    license => 'GNU GPL v2 or later',
    url => 'http://www.princessleia.com'
);

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

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

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