| View previous topic :: View next topic |
| Author |
Message |
Ladykiller Voice
Joined: 18 Feb 2007 Posts: 7
|
Posted: Sun Feb 18, 2007 4:29 pm Post subject: ChartScript wrong proc ? |
|
|
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: |
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
| Quote: | | 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
| Quote: | | « 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
| Quote: | ]« 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 |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Sun Feb 18, 2007 8:22 pm Post subject: |
|
|
Change:
| Code: |
foreach chart [split $chartlist "|"] {
if { $chart != "" } {
lappend charts "\002$x.\002 $chart"
incr x
continue
}
}
sendmsg $channel "GERMAN TOP5" "[join $charts " | "]"
|
to:
| Code: |
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" |
|
| Back to top |
|
 |
Ladykiller Voice
Joined: 18 Feb 2007 Posts: 7
|
Posted: Tue Feb 20, 2007 10:16 am Post subject: |
|
|
Hi thanks for the help. I got it now.
Bit different.
| Quote: | 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 )
| Quote: | set x 0
foreach chart [split $chartlist "|"] {
if { $chart != "" } {
incr x 1
sendmsg $channel "GERMAN TOP5" "$x\. $chart"
continue
}
} |
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Feb 20, 2007 8:47 pm Post subject: |
|
|
| Code: |
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. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Feb 20, 2007 8:54 pm Post subject: |
|
|
Another way to do the same thing, more or less:
| Code: |
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
}
}
}
|
|
|
| Back to top |
|
 |
Ladykiller Voice
Joined: 18 Feb 2007 Posts: 7
|
Posted: Wed Feb 21, 2007 9:26 am Post subject: |
|
|
| rosc2112 wrote: | Another way to do the same thing, more or less:
| Code: |
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
| Quote: | ("foreach" body line 2)
invoked from within
"foreach script $neededscripts {
source scripts/priv/$script
}"
invoked from within
|
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Feb 21, 2007 12:44 pm Post subject: |
|
|
Ahh, there's a few errors in my code, I musta been tired =)
I tested this, it worked. Modify to suit.
| Code: |
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
}
}
}
}
}
|
|
|
| Back to top |
|
 |
Ladykiller Voice
Joined: 18 Feb 2007 Posts: 7
|
Posted: Wed Feb 21, 2007 6:41 pm Post subject: |
|
|
Very nice. Thx to all for the nice help
Kind regards LK
edit: Grrmmmlll
Now i am sleepy
| Quote: |
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 |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Feb 21, 2007 7:32 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
|