Advertisement
swarley

is.gd shortener

Nov 9th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.83 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. use LWP::Simple;
  4. use Xchat ':all';
  5. use subs qw/true false/;
  6.  
  7. Xchat::hook_command('shorten', 'decide');
  8.  
  9.  
  10.  
  11. my $show = false;
  12.  
  13. sub decide {
  14.   if ((split(/ /, $_[1][1]))[0] eq "set") {
  15.     if ($show == true) {
  16.       $show = false;
  17.       Xchat::print("Show.....: OFF");
  18.     } else {
  19.       $show = true;
  20.       Xchat::print("Show.....: ON");
  21.     }
  22.   } else {
  23.     get_url($_);
  24.   }
  25. }
  26.  
  27.  
  28. sub get_url {
  29.     my $url = $_[1][1];
  30.     my $miniurl = get("http://is.gd/create.php?format=simple&url=" . $url);
  31.     my $page = "NIL"; $page = get($url);
  32.     $page =~ /\<title\>(.+?)\<\/title>/;
  33.     if ($1 && $show == true) {
  34.         Xchat::command("SAY $miniurl #{" . decode_entities($1) . "}");
  35.    } else {
  36.         Xchat::command("SAY $miniurl");
  37.    }
  38. }
  39.  
  40. sub true {
  41.   return 1;
  42. }
  43.  
  44. sub false {
  45.   return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement