All pastes #778739 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-17 21:31 UTC
rendered paste body
#!/usr/bin/perl

use strict;
use LWP::Simple;
use Text::Wrap;
use vars qw($VERSION %IRSSI);

sub grouphug {
    my ($server, $data, $nick, $address) = @_;
    my ($target, $text) = split(/ :/, $data, 2);
    if($text eq "~grouphug") {
        my $content = get 'http://www.grouphug.us/random';
        my $start = index($content, '<td class="conf-text">');
        my $length = index($content, '</td>', $start) - $start;
        $content = substr($content, $start, $length);
        $content =~ s/(<.+?>|\t|\n)?//g;
        my @content = split("\n", wrap("", "", $content));
        foreach(@content) {
            $server->command("msg $target $nick: $_");
        }
    }
}

use Irssi;
$VERSION = '1.00';
%IRSSI = (
    authors     => 'limetang',
    contact     => 'lime@zybez.net',
    name        => 'Grouphug Script',
    description => 'This script fetches a random confession from Grouphug.us.',
    license     => 'Public domain',
);
$Text::Wrap::columns = 431;
Irssi::signal_add_last("event privmsg", "grouphug");