| View previous topic :: View next topic |
| Author |
Message |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Wed Feb 27, 2008 2:31 am Post subject: |
|
|
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. _________________ ; Answer a few unanswered posts! |
|
| Back to top |
|
 |
hippytyre Voice
Joined: 26 Feb 2008 Posts: 1 Location: Scotland
|
Posted: Wed Feb 27, 2008 5:26 am Post subject: |
|
|
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  |
|
| Back to top |
|
 |
testebr Halfop
Joined: 01 Dec 2005 Posts: 86
|
Posted: Wed Feb 27, 2008 3:50 pm Post subject: |
|
|
very usefull, I use this script at a long time.
The support to tinyurl was that lacked.
Thank you! |
|
| Back to top |
|
 |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Wed Feb 27, 2008 5:20 pm Post subject: |
|
|
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. _________________ ; Answer a few unanswered posts! |
|
| Back to top |
|
 |
testebr Halfop
Joined: 01 Dec 2005 Posts: 86
|
|
| Back to top |
|
 |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Fri Feb 29, 2008 9:04 pm Post subject: |
|
|
| 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. _________________ ; Answer a few unanswered posts! |
|
| Back to top |
|
 |
testebr Halfop
Joined: 01 Dec 2005 Posts: 86
|
Posted: Sat Mar 01, 2008 12:17 am Post subject: |
|
|
Very nice, to shorten work fine, but to lengthen still with error..
And the lengthen is invalid with theses chars '%' and '3%'.
Easy to fix I believe.
Cya |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Mar 01, 2008 3:23 am Post subject: |
|
|
| Code: | 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.  |
|
| Back to top |
|
 |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Sat Mar 01, 2008 6:26 am Post subject: |
|
|
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.
Edit: I just can't help myself. 2.5d released, all URL's appear to lengthen quite nicely now. _________________ ; Answer a few unanswered posts!
Last edited by incith on Sat Mar 01, 2008 7:56 am; edited 1 time in total |
|
| Back to top |
|
 |
madwoota Halfop
Joined: 09 Aug 2005 Posts: 53
|
Posted: Sat Mar 01, 2008 7:05 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Mar 01, 2008 3:50 pm Post subject: |
|
|
| Code: | 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 % . |
|
| Back to top |
|
 |
incith Master

Joined: 23 Apr 2005 Posts: 275 Location: Canada
|
Posted: Sat Mar 01, 2008 4:34 pm Post subject: |
|
|
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. _________________ ; Answer a few unanswered posts! |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sat Mar 01, 2008 5:01 pm Post subject: |
|
|
| 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.
Note: this helps get around the accented character problem when dealing with multiple languages as input. |
|
| Back to top |
|
 |
grrmisfit Voice
Joined: 29 Mar 2008 Posts: 6
|
Posted: Sun Mar 30, 2008 8:02 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
testebr Halfop
Joined: 01 Dec 2005 Posts: 86
|
|
| Back to top |
|
 |
|