/usr/share/irssi/scripts/8-ball.pl is in irssi-scripts 20131030.
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 | #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 vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);
use IO::File;
$VERSION = '0.20';
%IRSSI = (
authors => 'Patrik Jansson',
contact => 'gein@knivby.nu',
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($server, $msg, $nick, $target) {
my ($server, $msg, $nick, $target) = @_;
$_ = $msg;
if (!/^8-ball/i) { return 0; }
if (/^8-ball:.+\?$/i) {
my $ia = int(rand(16));
my $answer = "";
SWITCH: {
if ($ia==0) { $answer = "Yes"; last SWITCH; }
if ($ia==1) { $answer = "No"; last SWITCH; }
if ($ia==2) { $answer = "Outlook so so"; last SWITCH; }
if ($ia==3) { $answer = "Absolutely"; last SWITCH; }
if ($ia==4) { $answer = "My sources say no"; last SWITCH; }
if ($ia==5) { $answer = "Yes definitely"; last SWITCH; }
if ($ia==6) { $answer = "Very doubtful"; last SWITCH; }
if ($ia==7) { $answer = "Most likely"; last SWITCH; }
if ($ia==8) { $answer = "Forget about it"; last SWITCH; }
if ($ia==9) { $answer = "Are you kidding?"; last SWITCH; }
if ($ia==10) { $answer = "Go for it"; last SWITCH; }
if ($ia==11) { $answer = "Not now"; last SWITCH; }
if ($ia==12) { $answer = "Looking good"; last SWITCH; }
if ($ia==13) { $answer = "Who knows"; last SWITCH; }
if ($ia==14) { $answer = "A definite yes"; last SWITCH; }
if ($ia==15) { $answer = "You will have to wait"; last SWITCH; }
if ($ia==16) { $answer = "Yes, in due time"; last SWITCH; }
if ($ia==17) { $answer = "I have my doubts"; last SWITCH; }
}
$server->command('msg '.$target.' '.$nick.'8-ball says: '.$answer);
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");
|