| View previous topic :: View next topic |
| Author |
Message |
PrE Voice
Joined: 14 Jan 2012 Posts: 10
|
Posted: Fri Feb 17, 2012 6:53 pm Post subject: url title help |
|
|
So i got this script and modified it a little to my needs but there is a problem i can't fix.
I don't want it to send the text, just the link but it sends the whole line before the link and after the link.
but i want it to ignore text and just send the link to the server
it sends the request the php script with that text
like
host.com/script.php?i=bla link.com
which returns an error to irc.
| Code: |
if {[string length $word] >= $urltitle(length) && \
[regexp {^(f|ht)tp(s|)://} $word] && \
![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
set urltitle(last) [unixtime]
set urtitle [urltitle $word]
if {[string match *http://forum.gordonsys.net/showthread.php?* $word]} {
puthelp "PRIVMSG $chan :\002GordonSys\002: \"$urtitle\""
}
} |
|
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Feb 17, 2012 7:50 pm Post subject: Re: url title help |
|
|
| Code: | foreach word [split $text] {
if {[string length $word] >= $urltitle(length) && \
[regexp {^(f|ht)tp(s|)://} $word] && \
![regexp {://([^/:]*:([^/]*@|\d+(/|$))|.*/\.)} $word]} {
set urltitle(last) [unixtime]
set urtitle [urltitle $word]
if {[string length $urtitle]} {
switch -glob -- $word {
*http://forum.gordonsys.net/showthread.php?* {
puthelp "PRIVMSG $chan :\002GordonSys\002: \"$urtitle\""
}
}
}
break
}
} |
You removed too much of the original code. You removed the foreach which iterates over every word of input. I also added a switch statement and body too. These are more efficient than a ton of nested if's. If you wish to add to the switch statement add the bodies exactly as I have done. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|