-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmoberrycard.pl
More file actions
executable file
·70 lines (58 loc) · 2.01 KB
/
Copy pathmoberrycard.pl
File metadata and controls
executable file
·70 lines (58 loc) · 2.01 KB
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
use strict;
use Irssi qw/signal_add/;
use Irssi::Irc;
use warnings;
use vars qw($VERSION %IRSSI);
$VERSION = "1";
%IRSSI = (
authors => 'Mosai with improvements by Stevie-O',
contact => 'mosai57@gmail.com',
name => 'Cards',
description => 'Selects a random card or a specific one if predicted.',
changed => '2014-01-7 21:47 (UTC-8:00)',
);
my @suit = qw/Hearts Spades Diamonds Clubs/;
my @rank = qw/Ace 2 3 4 5 6 7 8 9 10 Jack Queen King/;
my %suit; $suit{lc $_} = $_ for @suit;
my %rank; $rank{lc $_} = $_ for @rank;
my %predict;
my %ignore =(
"Mesril" => 1,
"Eldora" => 1,
"sugarass" => 1,
"Droplet" => 1,
"Camazotz" => 1,
);
signal_add('message public', sub {
my ($server, $message, $nick, $address, $target) = @_;
{ no warnings 'uninitialized'; return if ($ignore{$nick} == 1); }
if($nick =~ /amiigo\|\d+/i){ return; }
my $me = $server->{nick};
if ($message =~ /^$me[:,] i predict (?:the )?(\w+) of (\w+)/i) {
my ($rank, $suit) = (lc $1, lc $2);
my $proper_rank = $rank{$rank};
my $proper_suit = $suit{$suit};
if (defined $proper_rank && defined $proper_suit) {
$predict{$nick} = [ $proper_rank, $proper_suit ];
} else {
$server->command("MSG $target You predict the " . ($proper_rank // 'what') . " of " . ($proper_suit // 'what') . " now?");
}
}
});
sub card {
my ($server, $message, $nick, $address, $target) = @_;
{ no warnings 'uninitialized'; return if ($ignore{$nick} == 1); }
if($nick =~ /amiigo\|\d+/i){ return; }
if($message =~ m/^!card$/i){
my ($rank, $suit);
my $predict = delete $predict{$nick};
if ($predict) {
($rank, $suit) = @$predict;
} else {
$rank = $rank[rand(@rank)];
$suit = $suit[rand(@suit)];
}
$server->command("MSG $target $nick, your card is the $rank of $suit");
}
}
Irssi::signal_add('message public', 'card');