$heap->{ 'twitterUsers' } = {};
}
}
+
+ if( $what =~ /^\s*$/ ) {
+ $kernel->post( $src, $replypath, "Usage: TWITTER <message>", $dest );
+ return;
+ }
if( exists( $heap->{ 'twitterUsers' }->{ uc( $who ) } ) ) {
if( $heap->{ 'twitterUsers' }->{ uc( $who ) }->{ "state" } == 0 ) {
$page =~ m/<h1>(Package: .*?)<\/h1>/s;
$kernel->post( $src, $replypath, $1, $dest );
}
+
+BACKRONYM: |-
+ sub {
+ my( $kernel, $heap, $who, $what, $src, $dest, $replypath ) = @_;
+ my $FH;
+ my $dict;
+ unless( exists $heap->{ "backronym_dict" } ) {
+ $dict = $heap->{ "backronym_dict" } = {};
+ if( -e "backronym.wordlist" ) {
+ print( "BACKRONYM: Using backronym.wordlist\n" );
+ open $FH, "<", "backronym.wordlist";
+ } elsif( -e "/usr/share/dict/words" ) {
+ print( "BACKRONYM: Using /usr/share/dict/words\n" );
+ open $FH, "<", "/usr/share/dict/words";
+ } else {
+ $kernel-post( $src, $replypath, "I can't find a wordlist. :(", $dest );
+ return;
+ }
+ while(<$FH>) {
+ chomp;
+ my $word = $_;
+ $word =~ tr/A-Z/a-z/;
+ my $ch = (substr $word, 0, 1);
+ $dict->{ $ch } = [] unless exists $dict->{ $ch };
+ push @{ $dict->{ $ch } }, $word;
+ }
+ close $FH;
+ } else {
+ $dict = $heap->{ "backronym_dict" };
+ }
+ my $response = "";
+ $what =~ tr/A-Z/a-z/;
+ for my $c (split( //, $what)) {
+ $response .= $dict->{ $c }->[ int( rand( scalar @{$dict->{$c}} ) ) ]." ";
+ }
+ $kernel->post( $src, $replypath, $response, $dest );
+ }