Skip to content

Instantly share code, notes, and snippets.

@bigbosst
Created December 23, 2014 02:04
Show Gist options
  • Save bigbosst/f7faee0576efa2dc15be to your computer and use it in GitHub Desktop.
Save bigbosst/f7faee0576efa2dc15be to your computer and use it in GitHub Desktop.
tinyurl irssi - thanks thehaz
# tinyurl.pl
use strict;
use warnings;
use LWP::Simple;
use Irssi;
our $VERSION = '1.0';
our %IRSSI = (
author => 'Hazael Sanchez',
contact => 'hazaelsan@gmail.com',
name => 'tinyurl',
description => 'creates tinyurl',
license => 'GPL',
);
Irssi::command_bind( tinyurl => sub {
my ($msg, $server, $win) = @_;
my $url;
if ($url = get "http://www.tinyurl.com/api-create.php?url=$msg") {
if ($win && ($win->{type} eq 'CHANNEL' || $win->{type} eq 'QUERY')) {
$win->command("MSG $win->{name} $url");
}
else {
print CLIENTCRAP "tinyurl: $url";
};
}
else {
print CLIENTCRAP 'Error connecting to tinyurl';
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment