| 1 | package Bot::Cobalt::Plugin::Games::Magic8; | ||
| 2 | $Bot::Cobalt::Plugin::Games::Magic8::VERSION = '0.021003'; | ||
| 3 | use v5.10; | ||
| 4 | use strict; use warnings; | ||
| 5 | |||
| 6 | sub new { bless [], shift } | ||
| 7 | |||
| 8 | sub execute { | ||
| 9 | my ($self, $msg) = @_; | ||
| 10 | |||
| 11 | state $responses = [ <DATA> ]; | ||
| 12 | my $selected = $responses->[rand @$responses]; | ||
| 13 | chomp $selected; | ||
| 14 | |||
| 15 | my $nick = ref $msg ? $msg->src_nick : ''; | ||
| 16 | ($nick // '') . ': ' . $selected | ||
| 17 | } | ||
| 18 | |||
| 19 | 1; | ||
| 20 | |||
| 21 | =pod | ||
| 22 | |||
| 23 | =head1 NAME | ||
| 24 | |||
| 25 | Bot::Cobalt::Plugin::Games::Magic8 - Ask the Magic 8-ball | ||
| 26 | |||
| 27 | =head1 SYNOPSIS | ||
| 28 | |||
| 29 | !magic8 Will today be a good day? | ||
| 30 | |||
| 31 | =head1 DESCRIPTION | ||
| 32 | |||
| 33 | Ask the magic 8-ball; it knows the answer to all the big questions in | ||
| 34 | life. | ||
| 35 | |||
| 36 | =head1 AUTHOR | ||
| 37 | |||
| 38 | Jon Portnoy <avenj@cobaltirc.org> | ||
| 39 | |||
| 40 | =cut | ||
| 41 | |||
| 42 | __DATA__ |