use strict;
use vars qw($VERSION %IRSSI);
use Irssi 20010920.0000 ();
$VERSION = "2.01";
%IRSSI = (
    authors     => 'From irssi source, modified by Brian Ponnampalam (dg)',
    name        => 'mquotes',
    description => '/MQUOTES - Display a random quote',
    license     => 'Same as Irssi',
    url         => 'https://magical.ddns.net/software/irssi/',
);

sub cmd_quotes {
   
 my ($data, $server, $channel) = @_;

 if (!$channel || $channel->{type} ne 'CHANNEL') {
    Irssi::print('No active channel in window');
    return;
  }

 my $home = $ENV{"HOME"};
 my $myfile = $home."/.irssi/quotes.txt";
 open my $fh,'<',$myfile or die $!;
 my $size = -s $fh;
 seek $fh, rand($size) , 0;
 <$fh>; #throw away current line;
   
 my $randomline = <$fh>;

 close $fh;
 $channel->print($randomline);
}
Irssi::command_bind('mquotes', 'cmd_quotes');
