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.

Search after a string an output this PLUS the next 2 lines

Old posts that have not been replied to for several years.
Locked
J
Jagg
Halfop
Posts: 53
Joined: Sat Jan 24, 2004 11:32 am

Search after a string an output this PLUS the next 2 lines

Post by Jagg »

Hi,

i want search a source code after a string like "color=#FF0000>• ". When this string is found the bot should post THIS line (the whole) AND THE NEXT TWO LINES to a channel.

(This string is in the source code about 3-6 times)

I've tried that:

Code: Select all

bind pub - !test pub:econD

proc pub:econD {nick host handle chan text} {
set tok [http::geturl http://www.url.com]
set data [http::data $tok]

set var "color=#FF0000>• "
set x 0
foreach creature [split $data \n] {
		if [string match *${creature}* $var] {set x 1}
		if {$x > 0 && $x <= 3} {incr x
		
		puthelp "PRIVMSG $chan : $creature"
		}
}
}
But this code outputs the whole source code not only the 3 lines when "color=#FF0000>• " were found :cry:

Thanks
User avatar
strikelight
Owner
Posts: 708
Joined: Mon Oct 07, 2002 10:39 am
Contact:

Post by strikelight »

your string match is incorrect... you want:

Code: Select all

if [string match "*$var*" $creature] {set x 1}
Locked