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.

ChartScript wrong proc ?

Support & discussion of released scripts, and announcements of new releases.
Post Reply
L
Ladykiller
Voice
Posts: 7
Joined: Sun Feb 18, 2007 4:24 pm

ChartScript wrong proc ?

Post by Ladykiller »

I tried to load this lil Script but got an error and need some Help please to find it. Thanks in advance

Here is the Script

Code: Select all

bind PUB -|- ".charts" pub:mtv:charts

setudef flag charts

proc pub:mtv:charts { nickname hostname handle channel arguments } {

	if { [info exists ::chartsdone($channel)] || ![channel get $channel charts] } {
		return 0
	}

	package require http

	set x [http::config -useragent "Mozilla"]
	set x [http::geturl "http://www.mtv.de/hitlistgermany/index.php" -timeout 2000]

	set y [http::data $x]

	http::cleanup $x

	unset x
	set   chartcurrent  0
	set   chartlist     ""

	foreach element [split $y \n] {

		if { ![info exists preline] } {

			if { [regexp {width=\"160\"} $element chartline] } {

				set  preline       1
	
				regsub -all -- {\<(.*?)>} $element "" element

				append chartlist "$element "

				continue

			}

		}

		if { [info exists preline] } {

			if { [regexp {width=\"163\"} $element chartline] } {

				unset preline

				incr chartcurrent

				regsub -all -- {\<(.*?)>} $element "" element

				append chartlist "- $element|"

				if { $chartcurrent == 5 } {

					break

				}

				continue

			}

		}

	}

	set x 1

	foreach chart [split $chartlist "|"] {

		if { $chart != "" } {
			lappend charts "\002$x.\002 $chart"
			incr x
			continue
		}

	}


	sendmsg $channel "GERMAN TOP5" "[join $charts " | "]"

	set ::chartsdone($channel) 1
	utimer 10 [list unset ::chartsdone($channel)]

}
and thats the Error i get
Tcl error [pub:mtv:charts]: can't read "chart": no such variable
Regards LK


edit: solved the Prob. Found my glasses ;)
another question. At the moment the output is like that

« GERMAN TOP5 » «1. Herbert Groenemeyer - Lied 1- Stueck Vom Himmel | 2. Nelly Furtado - All Good Things (Come To An End) | 3. DJ Oetzi & Nik P - Ein Stern (der Deinen Namen..) | 4. Ville Valo & Natalia Avelon - Summer Wine | 5. Hoehner - Wenn Nicht Jetzt Wann Dann? »
But i would like to have it this way

]« GERMAN TOP5 » «1. Herbert Groenemeyer - Lied 1- Stueck Vom Himmel
2. Nelly Furtado - All Good Things (Come To An End)
3. DJ Oetzi & Nik P - Ein Stern (der Deinen Namen..)
4. Ville Valo & Natalia Avelon - Summer Wine
5. Hoehner - Wenn Nicht Jetzt Wann Dann? »
Cant get it solved with \n
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Change:

Code: Select all

 foreach chart [split $chartlist "|"] {

      if { $chart != "" } {
         lappend charts "\002$x.\002 $chart"
         incr x
         continue
      }

   }
   sendmsg $channel "GERMAN TOP5" "[join $charts " | "]"
to:

Code: Select all

 foreach chart [split $chartlist "|"] {
      if { $chart != "" } {
         incr x
         sendmsg $channel "GERMAN TOP5 $x\. $charts"
         continue
      }
   }
Should work.. I don't know where the sendmsg thing comes from, I assume its a proc in a different script.. Otherwise, just use

puthelp "PRIVMSG $chan :GERMAN TOP5 $x\. $charts"
L
Ladykiller
Voice
Posts: 7
Joined: Sun Feb 18, 2007 4:24 pm

Post by Ladykiller »

Hi thanks for the help. I got it now.

Bit different.

foreach chart [split $chartlist "|"] {
if { $chart != "" } {
incr x
sendmsg $channel "GERMAN TOP5" "$x\. $chart"
continue
}
}
otherwise u get a lil sendmsg error

Maybe u can help again. With this code i have on all 5 GERMAN TOP5
Is it possible to change it that way that GERMAN TOP5 is just a topic an underneath the TOP5 listing?

Regards LK

edit: why does the Count starts now from 2 - 6 instead 1 - 5

edit. Grr so stupid ;))
set x 0

foreach chart [split $chartlist "|"] {
if { $chart != "" } {
incr x 1
sendmsg $channel "GERMAN TOP5" "$x\. $chart"
continue
}
}
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Code: Select all

set x 0
if { $chart != "" } {
     sendmsg $channel "GERMAN TOP5:"
     foreach chart [split $chartlist "|"] {
           incr x 1
           sendmsg $channel "$x\. $chart"
           continue
      }
}
That'll show the header "GERMAN TOP5:" by itself, then the actual chart stuff will be shown 1 line at a time after.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Another way to do the same thing, more or less:

Code: Select all

set x 0
if { $chart != "" } {
    foreach chart [split $chartlist "|"] {
          incr x 1
          if {$x == 1} {
                sendmsg $channel "GERMAN TOP5: $x\. $chart"}
          } else {
                sendmsg $channel "x\. $chart"
                continue
          }
    }
}
L
Ladykiller
Voice
Posts: 7
Joined: Sun Feb 18, 2007 4:24 pm

Post by Ladykiller »

rosc2112 wrote:Another way to do the same thing, more or less:

Code: Select all

set x 0
if { $chart != "" } {
    foreach chart [split $chartlist "|"] {
          incr x 1
          if {$x == 1} {
                sendmsg $channel "GERMAN TOP5: $x\. $chart"}
          } else {
                sendmsg $channel "x\. $chart"
                continue
          }
    }
}
gives an Error
("foreach" body line 2)
invoked from within
"foreach script $neededscripts {
source scripts/priv/$script
}"
invoked from within
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Ahh, there's a few errors in my code, I musta been tired =)
I tested this, it worked. Modify to suit.

Code: Select all

bind pub - test proctest
proc proctest {nick uhost hand chan text} {
        set x 0
        set chartlist "foo | bar | biz | baz"
        if { $chartlist != "" } {
                foreach chart [split $chartlist "|"] {
                        if {$chart != ""} {
                                incr x
                                if {$x == 1} {
                                        puthelp "PRIVMSG $chan :GERMAN TOP5: $x\. $chart"
                                } else {
                                        puthelp "PRIVMSG $chan :$x\. $chart"
                                        continue
                                }
                        }
                }
        }
}
L
Ladykiller
Voice
Posts: 7
Joined: Sun Feb 18, 2007 4:24 pm

Post by Ladykiller »

Very nice. Thx to all for the nice help

Kind regards LK

edit: Grrmmmlll

Now i am sleepy
bind PUB -|- ".charts" pub:mtv:charts

setudef flag charts

proc pub:mtv:charts { nickname hostname handle channel arguments } {

if { [info exists ::chartsdone($channel)] || ![channel get $channel charts] } {
return 0
}

package require http

set x [http::config -useragent "Mozilla"]
set x [http::geturl "http://www.mtv.de/hitlistgermany/index.php" -timeout 2000]

set y [http::data $x]

http::cleanup $x

unset x
set chartcurrent 0
set chartlist ""

foreach element [split $y \n] {

if { ![info exists preline] } {

if { [regexp {width=\"160\"} $element chartline] } {

set preline 1

regsub -all -- {\<(.*?)>} $element "" element

append chartlist "$element "

continue

}

}

if { [info exists preline] } {

if { [regexp {width=\"163\"} $element chartline] } {

unset preline

incr chartcurrent

regsub -all -- {\<(.*?)>} $element "" element

append chartlist "- $element|"

if { $chartcurrent == 5 } {

break

}

continue

}

}

}

bind pub - test proctest
proc proctest {nick uhost hand chan text} {
set x 0
set chartlist "foo | bar | biz | baz"
if { $chartlist != "" } {
foreach chart [split $chartlist "|"] {
if {$chart != ""} {
incr x
if {$x == 1} {
puthelp "PRIVMSG $chan :GERMAN TOP5: $x\. $chart"
} else {
puthelp "PRIVMSG $chan :$x\. $chart"
continue
}
}
}
}
}




set ::chartsdone($channel) 1
utimer 10 [list unset ::chartsdone($channel)]

}
is anything wrong in here ???

its not posting while using .charts and i cant find anything
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

That's because I posted an example proc, it's up to you to use the parts you need. You don't need the entire proc or the bind for it.
Post Reply