source: trollforge/irc/irssi/cb.pl @ 773

Revision 606, 1.7 KB checked in by literalka, 16 months ago (diff)

done..?

Line 
1use Irssi;
2use Irssi::Irc;
3use strict;
4no warnings;
5use 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
17sub 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
29sub 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
70Irssi::command_bind('cb', 'cmd_cb');
Note: See TracBrowser for help on using the repository browser.