-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path8ball.pl
executable file
·66 lines (58 loc) · 1.93 KB
/
8ball.pl
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
use strict;
use Encode;
use vars qw($VERSION %IRSSI);
use Irssi;
our $VERSION = '0.1';
our %IRSSI = (
authors => 'Seth Galitzer',
contact => '[email protected]',
name => '8ball',
description => 'your basic magic 8-ball script',
license => 'Public Domain',
);
sub shake_it {
my @answers = ( "As I see it, yes",
"It is certain",
"It is decidedly so",
"Most likely",
"Outlook good",
"Signs point to yes",
"Without a doubt",
"Yes",
"Yes, definitely",
"You may rely on it",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful" );
return "Magic 8 Ball Says: " . $answers[ rand @answers ];
}
sub handler {
my ($server, $msg, $nick, $addr, $target, $priv) = @_;
# use utf8;
$msg = decode_utf8($msg);
if ($msg =~ m/^!8ball/) {
$msg = encode_utf8(shake_it());
if ($priv) {
$server->command ("msg $nick $msg");
} else {
$server->command ("msg $target $msg");
}
}
}
Irssi::signal_add_last('message public', sub {
my ($server, $msg, $nick, $addr, $target) = @_;
Irssi::signal_continue($server, $msg, $nick, $addr, $target);
handler($server, $msg, $nick, $addr, $target);
});
Irssi::signal_add_last('message private', sub {
my ($server, $msg, $nick, $addr, $target) = @_;
Irssi::signal_continue($server, $msg, $nick, $addr, $target);
handler($server, $msg, $nick, $addr, $target, 1);
});