Created
July 25, 2013 15:57
-
-
Save aaronpk/6081167 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
sub microformats_server_start { | |
my $kernel = $_[KERNEL]; | |
my $socket = IO::Socket::INET->new( | |
Proto => 'udp', | |
LocalPort => $conf->{UDP_LISTEN_MF}, | |
); | |
die "Couldn't create server socket: $!" unless $socket; | |
$kernel->select_read( $socket, "get_datagram" ); | |
} | |
sub microformats_server_read { | |
my ( $kernel, $socket ) = @_[ KERNEL, ARG0 ]; | |
my $ircmessage = ""; | |
recv( $socket, my $message = "", DATAGRAM_MAXLEN, 0 ); | |
$ircmessage = $message; | |
debugmsg("microformats_server_read: ".$message); | |
if( $ircmessage =~ m/^ACTION / ) { | |
$irc->yield( ctcp => $conf->{IRC_CHANNEL_MF}, $ircmessage ) ; | |
handle_message($conf->{IRC_NICK}, $conf->{IRC_USERNAME}, $conf->{IRC_CHANNEL_MF}, $ircmessage); | |
} elsif( $ircmessage =~ m/^PRIV ([^ ]+) (.+)/ ) { | |
$irc->yield( privmsg => $1, $2 ); | |
handle_message($conf->{IRC_NICK}, $conf->{IRC_USERNAME}, $conf->{IRC_CHANNEL_MF}, $2); | |
} elsif( $ircmessage =~ m/^INVITE ([^ ]+) (#.*)/ ) { | |
$irc->yield( invite => $1, $2 ); | |
} elsif( $ircmessage =~ m/^TOPIC (#[^ ]+) (.+)/ ) { | |
debugmsg("topic change: ".$2); | |
$irc->yield( topic => $1, $2 ); | |
} else { | |
$irc->yield( privmsg => $conf->{IRC_CHANNEL_MF}, $ircmessage ) ; | |
handle_message($conf->{IRC_NICK}, $conf->{IRC_USERNAME}, $conf->{IRC_CHANNEL_MF}, $ircmessage); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment