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.

url title help

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
P
PrE
Voice
Posts: 10
Joined: Sat Jan 14, 2012 8:19 pm

url title help

Post by PrE »

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.

Code: Select all

bla link.com

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: Select all

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\""
				}
				
				
				
			}
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: url title help

Post by speechles »

Code: Select all

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.
Post Reply