diff --git a/lib/Bot/BasicBot/Pluggable/Module/Tea.pm b/lib/Bot/BasicBot/Pluggable/Module/Tea.pm index f74b18b..c00ef72 100644 --- a/lib/Bot/BasicBot/Pluggable/Module/Tea.pm +++ b/lib/Bot/BasicBot/Pluggable/Module/Tea.pm @@ -4,6 +4,7 @@ package Bot::BasicBot::Pluggable::Module::Tea; use Moose; use DateTime; use List::Util qw(shuffle); +use List::MoreUtils qw(uniq); extends 'Bot::BasicBot::Pluggable::Module'; @@ -42,8 +43,8 @@ sub help { If you want to see the current tea round status, issue `!tea status`. - If you want to live on the edge issue the `!tea random` command to have - someone at random selected to make the tea + Feeling lucky Punk? `tea double_or_nothing` gives you the chance to escape + your tea round. However, it's 50/50 and you could be making the next TWO cups! HELPMSG } @@ -82,11 +83,13 @@ HELPMSG sub tidy_lists { my ( $self, $chan ) = @_; my @all_nicks = $self->bot->pocoirc->channel_list( $chan ); + # don't tell Gianni I used ~~ @nick_list = grep { $_ ~~ @all_nicks && $_ ne $self->bot->nick } @nick_list; my $extra = ''; if (DateTime->now > $last_used->clone->add(hours => 8)) { + @all_nicks = uniq(@all_nicks); # forgive those who gambled and lost. @nick_list = shuffle(@nick_list); $extra = ' (the rota was rewritten due to inactivity)'; } @@ -146,7 +149,17 @@ HELPMSG elsif ( $commands[1] eq 'version' ) { return "This is teabot version $VERSION"; } - else { + elsif ( $commands[1] eq 'double_or_nothing' ){ + my $rand = rand; + if ($rand >= 0.5) { + my $next = pop @nick_list; + push (@nick_list, $next); + return "Wow!!! You got lucky! $who escapes his round. $next is making this round!!"; + } else { + unshift (@nick_list, $who); + return "Ouch! Tough luck son! You double or nothin'd your way into making two rounds!"; + } + } else { return "$who-- # Imbecile! [unknown command]"; }