use Irssi qw(command_bind signal_add);
use IO::File;
-$VERSION = '0.22';
+$VERSION = '0.23';
%IRSSI = (
authors => 'Patrik Akerfeldt',
contact => 'patrik.akerfeldt@gmail.com',
license => 'GPL',
);
+my $filename= Irssi::get_irssi_dir().'/8-ball';
+
sub own_question {
my ($server, $msg, $target) = @_;
question($server, $msg, "", $target);
my ($fh, $count);
$fh = new IO::File;
$count = 0;
- if ($fh->open("< .8-ball")){
+ if ($fh->open($filename, 'r')){
$count = <$fh>;
$fh->close;
}
$count++;
$fh = new IO::File;
- if ($fh->open("> .8-ball")){
+ if ($fh->open($filename, 'w')){
print $fh $count;
$fh->close;
}else{
my ($fh, $count);
$fh = new IO::File;
$count = 0;
- if ($fh->open("< .8-ball")){
+ if ($fh->open($filename, 'r')){
$count = <$fh>;
$server->command('msg '.$target.' 8-ball says: I\'ve got '.$count.' questions so far.');
$fh->close;
signal_add("message public", "public_question");
signal_add("message own_public", "own_question");
+
+# vim:set ts=8 sw=8: