/usr/share/irssi/scripts/8-ball.pl is in irssi-scripts 20160301.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | #8-ball / decision ball
#
#What is this?
#
#The 8-ball (Eight-ball) is a decision ball which i bought
#in a gadget shop when i was in London. I then came up with
#the idea to make an irc-version of this one :)
#There are 16 possible answers that the ball may give you.
#
#
#usage
#
#Anyone in the same channel as the one who runs this script may
#write "8-ball: question ?" without quotes and where question is
#a question to ask the 8-ball.
#An answer is given randomly. The possible answers are the exact
#same answers that the real 8-ball gives.
#
#Write "8-ball" without quotes to have the the ball tell you
#how money questions it've got totally.
#
#Write "8-ball version" without quotes to have him tell what
#his version is.
#
#
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);
use IO::File;
$VERSION = '0.22';
%IRSSI = (
authors => 'Patrik Akerfeldt',
contact => 'patrik.akerfeldt@gmail.com',
name => '8-ball',
description => 'Dont like to take decisions? Have the 8-ball do it for you instead.',
license => 'GPL',
);
sub own_question {
my ($server, $msg, $target) = @_;
question($server, $msg, "", $target);
}
sub public_question {
my ($server, $msg, $nick, $address, $target) = @_;
question($server, $msg, $nick.": ", $target);
}
sub question {
my ($server, $msg, $nick, $target) = @_;
$_ = $msg;
if (!/^8-ball/i) { return 0; }
if (/^8-ball:.+\?$/i) {
# From: "The 8-Ball Answers", http://8ball.ofb.net/answers.html
my @answers = (
'Signs point to yes.',
'Yes.',
'Reply hazy, try again.',
'Without a doubt.',
'My sources say no.',
'As I see it, yes.',
'You may rely on it.',
'Concentrate and ask again.',
'Outlook not so good.',
'It is decidedly so.',
'Better not tell you now.',
'Very doubtful.',
'Yes - definitely.',
'It is certain.',
'Cannot predict now.',
'Most likely.',
'Ask again later.',
'My reply is no.',
'Outlook good.',
'Don\'t count on it.'
);
$server->command('msg '.$target.' '.$nick.'8-ball says: '.$answers[rand @answers]);
my ($fh, $count);
$fh = new IO::File;
$count = 0;
if ($fh->open("< .8-ball")){
$count = <$fh>;
$fh->close;
}
$count++;
$fh = new IO::File;
if ($fh->open("> .8-ball")){
print $fh $count;
$fh->close;
}else{
print "Couldn't open file for output. The value $count couldn't be written.";
return 1;
}
return 0;
} elsif (/^8-ball$/i) {
my ($fh, $count);
$fh = new IO::File;
$count = 0;
if ($fh->open("< .8-ball")){
$count = <$fh>;
$server->command('msg '.$target.' 8-ball says: I\'ve got '.$count.' questions so far.');
$fh->close;
}else{
print "Couldn't open file for input";
return 1;
}
return 0;
} elsif (/^8-ball version$/i){
$server->command('msg '.$target.' My version is: '.$VERSION);
return 0;
} else {
if(!/^8-ball says/i){
$server->command('msg '.$target.' '.$nick.'A question please.');
return 0;
}
}
}
signal_add("message public", "public_question");
signal_add("message own_public", "own_question");
|