rendered paste bodyuse strict;
use vars qw($VERSION %IRSSI);
use Irssi;
$VERSION = "0.0.1";
%IRSSI = (
authors => "Chris \'Cheez\' Stretton",
contact => "cstretton\@gmail.com",
name => "Roll",
licence => "Public Domain",
description => "Rolls a virtual dice",
changed => "Wed Nov 3 16:46:00 GMT 2005",
changes => "script created"
);
sub cmd_roll {
my ($data, $server, $item) = @_;
my $witem = Irssi::active_win()->{active};
my $upper = $data;
my $lower = 1;
my $val = int(rand($upper - $lower + 1)) + $lower;
if ($data eq "") {
Irssi::print('roll: You must specify a size of dice');
} else {
if ($witem && ($witem->{type} eq "CHANNEL" || $witem->{type} eq "QUERY")) {
$witem->command("ACTION ".$witem->{name}." rolls " . $val . " on a " . $upper . " sided dice.");
} else {
Irssi::print('roll: You must do this in a channel or query window.');
}
}
}
Irssi::command_bind('roll', 'cmd_roll');