Last active
August 29, 2015 14:01
-
-
Save lnovy/6d20aa007696c06bbf9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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