#!/usr/bin/perl
package twitter;

use LWP::Simple;
use Time::HiRes qw ( setitimer ITIMER_VIRTUAL time );

$last = "";

sub public {
	@public = ("help");
}

sub help {
	nanobot::ntc($_[2], "Non-interactive module to pull twitter feeds.");
}

sub getFeed {
	$url = "http://twitter.com/statuses/user_timeline/lulzsec.rss";
	$result = get($url);

	if( $result =~ /<item>.*?<title>(.*?)<\/title>/sg ) {
		if( $last !~ $1 ) {
			$last = $1;
			nanobot::msg("#hackerthreads", $last);
		}
	}
}

$SIG{VTALRM} = sub { &getFeed; };
setitimer(ITIMER_VIRTUAL, 2, 120);

1;