From 09f1ca71c2652a029577d23b615c1ebfb8d27f71 Mon Sep 17 00:00:00 2001 From: David Phillips Date: Fri, 14 Sep 2018 23:24:21 +1200 Subject: Rename Shuffle to Random, add choose command --- Plugin/Random.pm | 32 ++++++++++++++++++++++++++++++++ Plugin/Shuffle.pm | 26 -------------------------- 2 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 Plugin/Random.pm delete mode 100644 Plugin/Shuffle.pm (limited to 'Plugin') diff --git a/Plugin/Random.pm b/Plugin/Random.pm new file mode 100644 index 0000000..bd1c4d2 --- /dev/null +++ b/Plugin/Random.pm @@ -0,0 +1,32 @@ +package Plugin::Random; + +use strict; +use warnings; + +use List::Util; + +my %config; + +sub configure { + my $self = shift; + my $cmdref = shift; + my $cref = shift; + %config = %$cref; + + $cmdref->("shuffle", sub { $self->shuffle(@_); } ); + $cmdref->("choose", sub { $self->choose(@_); } ); + + return $self; +} + +sub shuffle { + my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; + + return join " ", List::Util::shuffle(@arguments); +} + +sub choose { + my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; + return (List::Util::shuffle(@arguments))[0]; +} +1; diff --git a/Plugin/Shuffle.pm b/Plugin/Shuffle.pm deleted file mode 100644 index dc39898..0000000 --- a/Plugin/Shuffle.pm +++ /dev/null @@ -1,26 +0,0 @@ -package Plugin::Shuffle; - -use strict; -use warnings; - -use List::Util; - -my %config; - -sub configure { - my $self = shift; - my $cmdref = shift; - my $cref = shift; - %config = %$cref; - - $cmdref->("shuffle", sub { $self->shuffle(@_); } ); - - return $self; -} - -sub shuffle { - my ($self, $irc, $logger, $who, $where, $rest, @arguments) = @_; - - return join " ", List::Util::shuffle(@arguments); -} -1; -- cgit v1.1