aboutsummaryrefslogtreecommitdiff
path: root/Plugin/Random.pm
blob: 03a050baa9a05f1a39231f64efa15b3191c425b7 (plain)
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
package Plugin::Random;

use strict;
use warnings;

use List::Util;

sub configure {
	my $self = shift;
	my $cmdref = shift;

	$cmdref->($self, "shuffle", sub { $self->shuffle(@_); } );
	$cmdref->($self, "choose", sub { $self->choose(@_); } );
	$cmdref->($self, "8ball", sub { $self->eight_ball(@_); } );

	return $self;
}

sub _choose {
	return (List::Util::shuffle(@_))[0];
}

sub shuffle {
	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;

	return join " ", List::Util::shuffle(@arguments);
}

sub choose {
	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;
	return _choose(@arguments);
}

sub eight_ball {
	my ($self, $irc, $logger, $who, $where, $ided, $rest, $no_reenter, @arguments) = @_;
	my @responses = (
		"It is certain.",
		"Without a doubt.",
		"You may rely on it",
		"Yes. Definitely.",
		"It is decidedly so.",
		"As I see it, yes.",
		"Most likely.",
		"Yes.",
		"Outlook good.",
		"Signs point to yes.",
		"Reply hazy, try again.",
		"Better not tell you now.",
		"Ask again later.",
		"Cannot predict now.",
		"Concentrate and ask again.",
		"Don't count on it.",
		"Outlook not so good.",
		"My sources say no.",
		"Very doubtful.",
		"My reply is no.",
	);
	return _choose(@responses);
}
1;