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.

Can anyone tell me where I went wrong ? :(

Help for those learning Tcl or writing their own scripts.
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

Can anyone tell me where I went wrong ? :(

Post by NTHosts »

Ok i wrote this..

Code: Select all

bind pub * !test2 test2

proc test2 {nick uhost handle chan arg} {

   putquick "privmsg #Help :15"
   putquick "privmsg #Help :14"
   putquick "privmsg #Help :13"
   putquick "privmsg #Help :12"
   putquick "privmsg #Help :11"
   putquick "privmsg #Help :10"
   putquick "privmsg #Help :9"
   putquick "privmsg #Help :8"
   putquick "privmsg #Help :7"
   putquick "privmsg #Help :6"
   putquick "privmsg #Help :5"
   putquick "privmsg #Help :4"
   putquick "privmsg #Help :3"
   putquick "privmsg #Help :2"
   putquick "privmsg #Help :1"
   putquick "privmsg #Help :!kicksrc"
   putquick "privmsg #Help :Please Connect Now !"
   }

utimer 30 { 

proc topic_update {sock} {

    set headers [egghttp:headers $sock]
    set topic [egghttp:data $sock]

    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $topic - dj

    putquick "topic #LynxFM :\0030,12 ~ This Is LynxFM -|- The current DJ is: $dj ~ "
    #putquick "privmsg operserv :svsnick $djnick $djnick|On-Air"

  }
}
it does the count down bit fine, but the last bit dont work, i get this from .set errorInfo

ntIRC [14:08] #Nick# set errorInfo
ntIRC Currently: wrong # args: should be "topic_update sock"
ntIRC Currently: while executing
ntIRC Currently: "topic_update "

any ideas please ?

I am trying hehe :P
www.NT-Hosts.Net - More than just a host
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

you shouldn't declare the proc inside the utimer, you should just call it then

Code: Select all

proc topic_update {sock} { 

    set headers [egghttp:headers $sock] 
    set topic [egghttp:data $sock] 

    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $topic - dj 

    putquick "topic #LynxFM :\0030,12 ~ This Is LynxFM -|- The current DJ is: $dj ~ " 
    #putquick "privmsg operserv :svsnick $djnick $djnick|On-Air" 

  } 

utimer 30 topic_update <your arg here>
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

..

Post by NTHosts »

will that make it call the second proc 30 seconds after it completes the first tho ? :shock:
www.NT-Hosts.Net - More than just a host
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

no.. if you want it to get called 30 seconds after it finishes, paste the utimer 30 line after the last line in proc test2
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

Dude that dont work.. i get this from .set errorInfo..

ntIRC Currently: wrong # args: should be "utimer seconds command"
ntIRC Currently: while executing
ntIRC Currently: "utimer 30"
ntIRC Currently: (procedure "test2" line 20)
ntIRC Currently: invoked from within
ntIRC Currently: "test2 $_pub1 $_pub2 $_pub3 $_pub4 $_pub5"

Im lost lol
www.NT-Hosts.Net - More than just a host
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

he said the utimer 30 line, not just utimer 30.
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

right...

Post by NTHosts »

When I add it like

Code: Select all

utimer 10 topic_update {sock}
I get..

Tcl error [test2]: wrong # args: should be "utimer seconds command"

So i remove the arg {sock} then i get this..

Tcl error in script for 'timer8':
wrong # args: should be "topic_update sock"

Im very confused as to what i need to do now :roll: :oops:
www.NT-Hosts.Net - More than just a host
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

utimer 10 [list topic_update $sock]
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

Ok that 'seems' to have fixed that, but now I get the error..

Tcl error in script for 'timer9':
can't read "dj": no such variable

But dj is clearly there lol, here's the whole script now..

Code: Select all

bind pub * !test2 test2

proc test2 {nick uhost handle chan arg} {

   putquick "privmsg #Help :5"
   putquick "privmsg #Help :4"
   putquick "privmsg #Help :3"
   putquick "privmsg #Help :2"
   putquick "privmsg #Help :1"
   putquick "privmsg #Help :!kicksrc"
   putquick "privmsg #Help :Please Connect Now !"
utimer 10 [list topic_update sock]
}

proc topic_update {sock} {

    set headers [egghttp:headers $sock]
    set topic [egghttp:data $sock]
    #set topic1 [egghttp:data $sock]

    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $topic dj
    #regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)-} $topic1 - djnick


    putquick "topic #LynxFM :\0030,12 ~ This Is LynxFM -|- The current DJ is: $dj ~ "
    #putquick "privmsg operserv :svsnick $djnick $djnick|On-Air"

  }
Any ideas ?
Sorry if i'm being thick :P
www.NT-Hosts.Net - More than just a host
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

anyone ? :-/
www.NT-Hosts.Net - More than just a host
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you are missing the extra argument in the first regexp, add something like - or "" or {} before 'dj'.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

That was there, just missed it when putting it in the forum sorry :oops:
I tried using the others you said but didnt' work
www.NT-Hosts.Net - More than just a host
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

the regexp simply does not match, check the syntax against the source. There are even tools out there to test regular expression, if you are not familar enough with them to match them with your brain :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

...

Post by NTHosts »

Someone slap me lol, i hadnt set url or anything
derrrrrr

Anyway, the script now looks like this..

Code: Select all

bind pub * !test2 test2

proc test2 {nick uhost handle chan arg} {

   putquick "privmsg #Help :5"
   putquick "privmsg #Help :4"
   putquick "privmsg #Help :3"
   putquick "privmsg #Help :2"
   putquick "privmsg #Help :1"
   putquick "privmsg #Help :!kicksrc"
   putquick "privmsg #Help :Please Connect Now !"
utimer 10 [list topic_update sock]
}
set url "http://www.lynxfm.info/stream.html"

proc topic_update {sock} {
  global url
    set headers [egghttp:headers $sock]
    set topic [egghttp:data $sock]
    set topic1 [egghttp:data $sock]
    set sock [egghttp:geturl $url topic_update]
    return 1

    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $topic "" dj
    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*) - .*</font></tr>} $topic1 - djnick


    putquick "topic #LynxFM :\0030,12 ~ This Is LynxFM -|- The current DJ is: $dj ~ "
    putquick "privmsg operserv :svsnick $djnick $djnick|On-Air"

  }
and now gives the error..

ntIRC Currently: can't read "egghttp(9,body)": no such element in array
ntIRC Currently: while executing
ntIRC Currently: "if {![string match "*<*" $input] && ($egghttp($sock,body) == "")} {
ntIRC Currently: append egghttp($sock,headers) "$input\n"
ntIRC Currently: if {[string match "*HTTP/*" $inpu..."
ntIRC Currently: (procedure "egghttp:control" line 18)
ntIRC Currently: invoked from within
ntIRC Currently: "egghttp:control $_n $_a"

Anyone have any idea what that means ??

:shock:
www.NT-Hosts.Net - More than just a host
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

This script makes absolutely no sense at all.
It looks like you have no idea what you're doing if i read this.

I would advise you to use the http module anyway, i've found it to be much easier and better then egghttp.

Hint: You might want to try to call the topic_update with an actual socket, right now your script just loops by getting the website over and over (if i read it right)
Post Reply