| 1 | use Irssi; |
|---|
| 2 | use Irssi::Irc; |
|---|
| 3 | use strict; |
|---|
| 4 | no warnings; |
|---|
| 5 | use vars qw($VERSION %IRSSI); |
|---|
| 6 | $VERSION="0.0.2"; |
|---|
| 7 | %IRSSI = ( |
|---|
| 8 | authors => 'b0nk', |
|---|
| 9 | contact => 'b0nk\@hardchats', |
|---|
| 10 | name => 'cb', |
|---|
| 11 | description => 'czeckbox', |
|---|
| 12 | license => 'GPL v2', |
|---|
| 13 | url => 'http://fagaf.agdea.th', |
|---|
| 14 | ); |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | sub shuffle { |
|---|
| 18 | my $array = shift; |
|---|
| 19 | my $i = @$array; |
|---|
| 20 | while ( --$i ) { |
|---|
| 21 | my $j = int(rand($i+1)); |
|---|
| 22 | @$array[$i,$j] = @$array[$j,$i]; |
|---|
| 23 | } |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | # USAGE: |
|---|
| 27 | # /cb <checked> [unchecked] |
|---|
| 28 | |
|---|
| 29 | sub cmd_cb { |
|---|
| 30 | my ($data, $server, $witem) = @_; |
|---|
| 31 | my ($elm, $str); |
|---|
| 32 | my @mrx=('â','â','â','â','â','â','â','â','â'); |
|---|
| 33 | my $czkchr=$mrx[rand @mrx]; |
|---|
| 34 | my @cxz=(); |
|---|
| 35 | my($checked,$unchecked)=split(/ /,$data); |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | $checked=~s/(.)(?=.*?\1)//g; |
|---|
| 39 | while($checked=~/(.)/g) { |
|---|
| 40 | if ( $1 eq 'y' ) { push(@cxz,"[$czkchr] yes "); } |
|---|
| 41 | if ( $1 eq 'n' ) { push(@cxz,"[$czkchr] no "); } |
|---|
| 42 | if ( $1 eq 's' ) { push(@cxz,"[$czkchr] same "); } |
|---|
| 43 | if ( $1 eq 'r' ) { push(@cxz,"[$czkchr] rude "); } |
|---|
| 44 | if ( $1 eq 'm' ) { push(@cxz,"[$czkchr] maybe "); } |
|---|
| 45 | if ( $1 eq 't' ) { push(@cxz,"[$czkchr] true "); } |
|---|
| 46 | if ( $1 eq 'f' ) { push(@cxz,"[$czkchr] false "); } |
|---|
| 47 | if ( $1 eq 'b' ) { push(@cxz,"[$czkchr] blogged "); } |
|---|
| 48 | $unchecked=~s/$1//gi; |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | $unchecked=~s/(.)(?=.*?\1)//g; |
|---|
| 52 | while($unchecked=~/(.)/g) { |
|---|
| 53 | if ( $1 eq 'y' ) { push(@cxz,"[ ] yes "); } |
|---|
| 54 | if ( $1 eq 'n' ) { push(@cxz,"[ ] no "); } |
|---|
| 55 | if ( $1 eq 's' ) { push(@cxz,"[ ] same "); } |
|---|
| 56 | if ( $1 eq 'r' ) { push(@cxz,"[ ] rude "); } |
|---|
| 57 | if ( $1 eq 'm' ) { push(@cxz,"[ ] maybe "); } |
|---|
| 58 | if ( $1 eq 't' ) { push(@cxz,"[ ] true "); } |
|---|
| 59 | if ( $1 eq 'f' ) { push(@cxz,"[ ] false "); } |
|---|
| 60 | if ( $1 eq 'b' ) { push(@cxz,"[ ] blogged "); } |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | shuffle(\@cxz); |
|---|
| 64 | |
|---|
| 65 | $str=join("",@cxz); |
|---|
| 66 | |
|---|
| 67 | $witem->command("say $str"); |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | Irssi::command_bind('cb', 'cmd_cb'); |
|---|