Xcution commented on a Page, Open links without http:// or www. with double-click  -  Aug 04, 2013

A little more further in what you can do with this and using regex to filter links.

;Hooks right, selected, and double click events in channels for nicks, links and channels ;)
on *:HOTLINK:*:*: {
  var %n $hotlink(match) ,%e $hotlink(event) 
  if (%n ison #) { 
    if (%e == rclick) { xdid -u nicklist 3 | xdid -c nicklist 3 $xfind(%n) | nicklist.popup } 
    elseif (%e == sclick) { xdid -u nicklist 3 | xdid -c nicklist 3 $xfind(%n) } 
    elseif (%e == dclick) { query %n } 
  } 
  elseif (%e == dclick) {
    if ($regex(%n,/(^|\s|>)((https?|ftp):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/gim)) { URL  $regml(2) }
    elseif ($regex(%n,/(^|\s|>)(www\.[\S]+(\b|$))/gim)) { URL $+(http://,$regml(2)) }
    elseif ($regex(%n,/(\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*)/gim)) { url mailto: $+ $regml(1) }
    elseif ($regex(%n,/(%#\w+)/g)) { JOIN $regml(1) }
} }
Yama  -  Aug 06, 2013

Nice, but I only wanted hotlink for links without http:// or www.
Nicks and channels are working fine.

Savage_CL  -  Aug 09, 2013

@Xcution nice, but try to add to hers/his instead of posting your own.

@Yama When you have long lists of matches like that, regex is a blessing. Something simple like:

if ($regex($1-,/\b(.+?\.(?:com|net|org|de|to|info|biz).+?)\b/SUi))

This will match any string with .com, .net, .org, etc and place that string in $regml(1), everything in either direction until it hits whitespace (space, end of line, etc).

I would also suggest not adding the "www." to the beginning, as my website doesn't even allow for it, and some others don't too. I've only ever come across one, though, that needed it.

Yama  -  Aug 17, 2013

Thank you, will update later :D

sagargulati  -  Sep 01, 2013

@Yama : https:// you forgot that :)

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.