Today is: 8 January, 2012
Check todays hot topics

Unscramble script for irssi

An irssi script to automatically unscramble words and output them to a channel when an eggdrop is using the following tcl provided by egghelp dot org:

http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=1451

#!/usr/bin/perl
 
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
 
use Irssi qw(command_bind signal_add);
use HTTP::Request::Common;
use LWP::UserAgent;
 
$VERSION = '0.01';
%IRSSI = (
	authors		=> 'Taylor Kimball',
	contact		=> 'taylor@linuxhq.org',
	name		=> 'Unscramble',
	description	=> 'Cheating',
	license		=> 'GPL',
);
 
use constant BOTNICK => 'oldskewl';
use constant CHANNEL => '#oldskewl';
 
sub unscramble
{
	my ($server, $msg, $nick, $address, $target) = @_;
	return 0 if ($nick ne &BOTNICK);
	if ($msg =~ m/^Unscramble.--->..(.*)/)
	{
		my %s = ( 	textfield 	=> $1,
				Unscramble	=> 'Unscramble+It'
			);	
 
		my $u = "http://www.unscramble.net/modules.php?name=Unscramble";
		my $ua = LWP::UserAgent->new;
		$ua->timeout(10);
		my $response = $ua->request(POST $u, \%s);
		return 0 if (! $response->is_success);
		my @lines = split('\n', $response->decoded_content);
		foreach my $line (@lines)
		{
			if ($line =~ m/&word=(\w+)>/)
			{
				my @words = split('&word=', $line);
				foreach my $word (@words)
				{
					$server->command('msg ' . CHANNEL . ' ' . $1)
						if ($word =~ m/^(\w+)>/);	
				}
			}
		}
	}
}
 
signal_add("message public", "unscramble");