Created
December 23, 2014 02:04
-
-
Save bigbosst/f7faee0576efa2dc15be to your computer and use it in GitHub Desktop.
tinyurl irssi - thanks thehaz
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
# 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