URL Shortener for mIRC

By manish17xxx on Dec 26, 2017

So basically, what it does is that it shortens your URLs using TinyURL and displays the new shortened URL.

Usage:
!shorten URL : - Shortens the url and posts result in channel. For private results, message the command to the bot.
/shorten URL : - Displays the shortened URL to the user as a notice.

############################################################
##       URL Shortener      ##
##       Version: 1.0              ##
##       By: manish               ##
##       irc.lunarirc.net   #LunarIRC #LunarGames   User - manish  
  Commands:- 
!shorten <URL> : In the channel / Private message the bot
/shorten <URL> : Alias to use yourself
############################################################
alias isurl return $iif($regex($1-,/\b(\^@\S+|www\.\S+|http://\S+|irc\.\S+|irc://\S+|\w+(?:[\.-]\w+)?@\w+(?:[\.-]\w+)?\.[a-z]{2,4})\b/gi),$iif($prop,$regml($v1),$true))
alias -l tiny {
  if ($1) && ($isurl($1)) {
    set %p 0
    sockclose Tinyurl
    set %TinyurlURL /create.php?source=indexpage&url= $+ $1- $+ &submit=Make+TinyURL%21&alias=
    sockopen Tinyurl tinyurl.com 80
  }
  elseif ( !$isurl($1) ) { 
    if (# isin %nick) { msg %nick Invalid url or no url given! }
    else { notice %nick Invalid url or no url given! }
  }
} 
on *:TEXT:!shorten*:#: {
  set %nick $chan
  tiny $2-
}

alias shorten { 
  set %nick $me
  tiny $1-
}

on *:TEXT:!shorten*:?:{
  set %nick $nick
  tiny $2-
}

on *:SOCKOPEN:Tinyurl: {
  sockwrite -n Tinyurl GET %TinyurlURL HTTP/1.1
  sockwrite -n Tinyurl Host: tinyurl.com
  sockwrite Tinyurl $crlf
}
on *:SOCKREAD:Tinyurl: {
  sockread %Tinyurl
  while ($sockbr) {
    if (<div class="indent"><b> isin %Tinyurl) && (%p == 0) { 
      if ($chr(35) isin %nick ) { msg %nick 3 Your URL Has been Shortened To $+ :11 $gettok($right(%Tinyurl,-31),1,60) . }
      else { notice %nick 3 Your URL Has been Shortened To $+ :11 $gettok($right(%Tinyurl,-31),1,60) . }
      unset %p
    }
    sockread %Tinyurl
  }
}

Comments

Sign in to comment.
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.