Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created July 25, 2013 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aaronpk/6081167 to your computer and use it in GitHub Desktop.
Save aaronpk/6081167 to your computer and use it in GitHub Desktop.
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