Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@lnovy
Last active August 29, 2015 14:01
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 lnovy/6d20aa007696c06bbf9c to your computer and use it in GitHub Desktop.
Save lnovy/6d20aa007696c06bbf9c to your computer and use it in GitHub Desktop.
use strict;
use vars qw($VERSION %IRSSI);
use Irssi qw(command_bind signal_add);
use IO::File;
use LWP::Simple;
$VERSION = '0.21';
%IRSSI = (
authors => 'Lukas Novy',
contact => 'lukas.novy@pirati.cz',
name => 'title',
description => 'Posts links title to channel.',
license => 'GPL',
);
sub own_question {
my ($server, $msg, $target) = @_;
question($server, $msg, "", $target);
}
sub public_question {
my ($server, $msg, $nick, $address, $target) = @_;
question($server, $msg, $nick.": ", $target);
}
my @answers = ();
sub question($server, $msg, $nick, $target) {
my ($server, $msg, $nick, $target) = @_;
$_ = $msg;
if (!/(https?:\/\/.*?)(\s|$)/i) { return 0; }
my $url = $1;
my $content = get $url;
my $answer = "";
$content = "<title>Jebacz $url</title>" unless defined $content;
$_ = $content;
if (/<title>(.*?)<\/title>/) {
$answer = $1;
} else {
$answer = "O kurwa !<title>";
}
if ($answer ~~ @answers) { return 0; }
push(@answers, $answer);
$server->command('msg '.$target.' '.$answer);
}
signal_add("message public", "public_question");
signal_add("message own_public", "own_question");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment