# Got an annoying chatter who likes to use "ur" rather than "you're" or "your"? This script responds with a fact about the ancient city of Ur each time someone says "ur"
#
# This script requires you to have the text file "ur" in your /home/user/.irssi/ directory

use Irssi;

use vars qw($VERSION %IRSSI);

$VERSION = "1.0";
%IRSSI = (
    author => 'pleia2',
    contact => 'lyz@princessleia.com ',
    name => 'ur',
    description => 'Discourages the use of "ur" by stating a fact about ancient UR each time it is used',
    license => 'GNU GPL v2 or later',
    url => 'http://www.princessleia.com'
);

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

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

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