This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

incith:xrl (r94) (Jan. 20th, 2009) (+TinyURL and x0.no)

Support & discussion of released scripts, and announcements of new releases.
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

2.5 released with TinyURL support and vast other code changes I think. Please report any problems. :) Script has been well overdue for these fixes.
h
hippytyre
Voice
Posts: 1
Joined: Tue Feb 26, 2008 6:45 pm
Location: Scotland
Contact:

Post by hippytyre »

Thanks for releasing all of these scripts incith. I've been using your google one for a while now and after finding these forums earlier this week i've started using a few more of your tcls. Nice work :D
t
testebr
Halfop
Posts: 86
Joined: Thu Dec 01, 2005 12:22 pm

Post by testebr »

very usefull, I use this script at a long time.

The support to tinyurl was that lacked.

Thank you!
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

I think there may be a problem with how I changed the binds.. for some reason unknown to me, public messages have stopped working due to modifying how I bind the binds slightly.

If after you do a .die your bot's xrl is not working in channels please download 2.5a.
t
testebr
Halfop
Posts: 86
Joined: Thu Dec 01, 2005 12:22 pm

Post by testebr »

Tcl error [incith::xrl::message_handler]: Unsupported URL: http://metamark.net/api/rest/simple?lon ... 21SkCX7h18

if char '?' is present in url, show this error.

Can you fix it?

Thank you!
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

testebr wrote:if char '?' is present in url, show this error.
Sorry about that, I had removed them because I didn't think it was necessary anymore. (them = ? and &). I have released version 2.5b to address this problem on my website.
t
testebr
Halfop
Posts: 86
Joined: Thu Dec 01, 2005 12:22 pm

Post by testebr »

Very nice, to shorten work fine, but to lengthen still with error..
[01:11:10] <me> !shorten http://www.orkut.com/AlbumZoom.aspx?uid ... id=3&aid=1
[01:11:11] <MyBot> url's: http://tinyurl.com/2ttpzw
[01:11:16] <me> o/
[01:11:22] <me> !lengthen http://tinyurl.com/2ttpzw
[01:11:23] <MyBot> me's url's: http://www.orkut.com/AlbumZoom.aspx%3Fu ... =3%26aid=1
And the lengthen is invalid with theses chars '%' and '3%'.

Easy to fix I believe.

Cya
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

proc UrlDecode {text} {
  set url ""
  regsub -all {\%([0-9a-fA-F][0-9a-fA-F])} $text {[format %c 0x\1]} text
  set text [subst $text]
  foreach byte [split [encoding convertto utf-8 $text] ""] {
    scan $byte %c i
    if { $i < 33 || $i > 127 } {
      append url [format %%%02X $i]
    } else {
      append url $byte
    }
  }
  return $url
}
A simple urldecoder (such as above) is all it needs. ;)
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

Sigh.. slennox is gonna slaughter me one day with all the cancellations I do.

I have released 2.5c to hopefully address the above issues. % codes should always be converted now thanks to the above proc in a lengthen. Thanks, speechles.
(03:35:18) (@incith) !untiny 2ttpzw
(03:35:20) <@visitant> incith's lengthened url: http://www.orkut.com/AlbumZoom.aspx?uid ... id=3&aid=1
Edit: I just can't help myself. 2.5d released, all URL's appear to lengthen quite nicely now.
Last edited by incith on Sat Mar 01, 2008 7:56 am, edited 1 time in total.
m
madwoota
Halfop
Posts: 53
Joined: Tue Aug 09, 2005 12:27 am

Post by madwoota »

Haha, I've been meaning to write a scripted char to/from %code like that for years.

Nicely done speechles, I just might have to steal that :)

(With credit of course!)

-madwoota
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

proc UrlEncode {text type} {
  set url ""
  foreach byte [split [encoding convertto utf-8 $text] ""] {
    scan $byte %c i
    if {$i < 65 || $i > 122} {
      append url [format %%%02X $i]
    } else {
      append url $byte
    }
  }
  if {$type == 1} {
    return [string map {%25 . %3A : %2D - %2E . %30 0 %31 1 %32 2 %33 3 %34 4 %35 5 %36 6 %37 7 %38 8 %39 9 % .} $url]
  } else {
    return [string map {%3A : %2D - %2E . %30 0 %31 1 %32 2 %33 3 %34 4 %35 5 %36 6 %37 7 %38 8 %39 9 \[ %5B \\ %5C \] %5D \^ %5E \_ %5F \` %60} $url]
  }
}
Just for laughs and perhaps others use (stealing is fine in this case), here is the corresponding urlencode.
The mundane [string maps { }] are neccessary to keep numerics and other required symbols from being %percentualized/encoded. The $type is only useful for doing this on more than one encoding style. Sites such as wikipedia (type 1 in code above) that require almost everything encoded with periods . , while every other site including google uses percents % .
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

This would be really useful in a lot of places.

I decided against its use in xrl for now because I do not want to store urls as http%##%##%##www blah blah (yes I am too lazy to look up the codes for ://, still waking up), and is also why I removed % from being converted to %25 in 2.5d, I tested an ebay link stuffed with %'s and it still returned fine, the urlDecode making it even prettier now on a !lengthen.

There may still be some obscure URL/characters that will break xrl in the future, I didn't test curly braces for example, but I want to believe it's 99% good now.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

incith wrote:This would be really useful in a lot of places.

I decided against its use in xrl for now because I do not want to store urls as http%##%##%##www blah blah (yes I am too lazy to look up the codes for ://, still waking up), and is also why I removed % from being converted to %25 in 2.5d, I tested an ebay link stuffed with %'s and it still returned fine, the urlDecode making it even prettier now on a !lengthen.

There may still be some obscure URL/characters that will break xrl in the future, I didn't test curly braces for example, but I want to believe it's 99% good now.
Since your merely shortening url's your prolly closer to 99.999%. Your regexp is defining what gets sent off for url query (cleansing before querying). Which is neccessary because your anticipating links within context (hard to do). I only provided the urlencode function because the urldecode was mentioned in this thread. Imagined they could share mention in this thread and hopefully act as a reference in the future for someone suffering similar issues.. Theft is encouraged, this is a sharing community. :wink:

Note: this helps get around the accented character problem when dealing with multiple languages as input.
g
grrmisfit
Voice
Posts: 6
Joined: Sat Mar 29, 2008 4:24 pm

Post by grrmisfit »

if demond doesnt mind id love to see this incorporated into his rss feed script. google news links are HUGE since they have referal links in them so it can be quite spamming to have them in there. i may try to modify the two to be one but since im not a tcl coder it wont be to easy
t
testebr
Halfop
Posts: 86
Joined: Thu Dec 01, 2005 12:22 pm

Post by testebr »

founded one small bug with xrl

[10:34:18] <me> !xrl www.youtube.com/watch?v=_LNkqRQ1u0c
[10:34:19] <Bot> http://xrl.us/onehr

Without http:// the result will be:

xrl.uswww.youtube.com/watch?v=_LNkqRQ1u0c

-------------------------------------------------------------------

[10:35:30] <me> !xrl http://youtube.com/watch?v=_LNkqRQ1u0c
[10:35:31] <Bot> http://xrl.us/onemv

With http:// the result will be:

http://youtube.com/watch?v=_LNkqRQ1u0c

It's possible to fix this problem?

Thank you!
Post Reply