Created
June 11, 2009 00:03
-
-
Save arodland/127608 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use Text::ParseWords; | |
sub decide { | |
my $self = shift; | |
my $event = shift; | |
my (@args) = ( $event->args ); | |
my $message = shift(@args); | |
my $send_to; | |
if ( $event->type eq "public" ) { | |
$send_to = ( $event->to )[0]; | |
} elsif ( $event->type eq "msg" ) { | |
$send_to = $event->nick; | |
} else { | |
print STDERR "Got an unexpected type\n"; | |
return; | |
} | |
if ( $message =~ /^\.decide\s+(.*)/i ) { | |
my @tokens = shellwords($lines); | |
if ( @tokens == 1 ) { | |
$self->privmsg( $send_to, "Figure it out yourself!" ); | |
} else { | |
my $choice = $tokens[ rand @tokens ]; | |
$self->privmsg( $send_to, "I choose: $choice" ); | |
} | |
} | |
} | |
register_function( "pubmsg", \&decide ); | |
register_function( "privmsg", \&decide ); | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment