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.

\n dosnt' work :s

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

\n dosnt' work :s

Post by NTHosts »

Ok i have managed to get this far, most of this script works but on the last function for some reason \n isnt' working, it says the first line and thats it... here's the code..

Code: Select all

set url "http://www.lynxfm.info/stream.html"
set djtrigger "!dj"
set tracktrigger "!track"
set listenerstrigger "!listeners"
set alltrigger "!all"

set channel "#LynxFM"

### Current DJ ###

if {![info exists egghttp(version)]} {
  putlog "egghttp.tcl was NOT successfully loaded."
  putlog "shoutcast.tcl has not been loaded as a result."
} else {
  proc current_dj {sock} {

    global channel

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

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


    puthelp "PRIVMSG $channel :\0032\004The current DJ is: \0034$dj"

  }

  bind pub -|* $djtrigger top:djtrigger
  proc top:djtrigger {nick host hand chan text} {
    global url
    set sock [egghttp:geturl $url current_dj]
    return 1
  }


### Current Track ###


proc current_track {sock} {

    global channel

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

    regexp {<td height="39" valign="top" id="song"><font color="white" face="verdana" size="2">(.*?)</font></td>} $body1 - track


    puthelp "PRIVMSG $channel :\0032\004The current Track is: \0034 $track"

  }

  bind pub -|* $tracktrigger top:tracktrigger
  proc top:tracktrigger {nick host hand chan text} {
    global url
    set sock [egghttp:geturl $url current_track]
    return 1
  }

### Current Listeners ###

proc current_listeners {sock} {

    global channel

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

    regexp {<td height="21" valign="top" id="listeners"><font color="white" face="verdana" size="2">(.*?)</font></td>} $body2 - listeners


    puthelp "PRIVMSG $channel :\0032\004Current Listeners: \0034 $listeners"

  }

  bind pub -|* $listenerstrigger top:listenerstrigger
  proc top:listenerstrigger {nick host hand chan text} {
    global url
    set sock [egghttp:geturl $url current_listeners]
    return 1
  }

### All Stats ###

proc show_all {sock} {

    global channel

    set headers [egghttp:headers $sock]
    set all1 [egghttp:data $sock]
    set all2 [egghttp:data $sock]
    set all3 [egghttp:data $sock]

    regexp { <td height="39" valign="top" id="description"><font color="white" face="verdana" size="2">(.*)</font></tr>} $all1 - dj
    regexp {<td height="39" valign="top" id="song"><font color="white" face="verdana" size="2">(.*?)</font></td>} $all2 - track
    regexp {<td height="21" valign="top" id="listeners"><font color="white" face="verdana" size="2">(.*?)</font></td>} $all3 - listeners


    puthelp "PRIVMSG $channel :\0032\004Current Status:\n \0034 The current DJ is:$dj \n The current track is: $track \n With listeners: $listeners"

  }

  bind pub -|* $alltrigger top:alltrigger
  proc top:alltrigger {nick host hand chan text} {
    global url
    set sock [egghttp:geturl $url show_all]
    return 1
  }


 putlog "shoutcast.tcl has been successfully loaded."
}
Any thoughts ? :(
www.NT-Hosts.Net - More than just a host
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

split that last puthelp:

Code: Select all

puthelp "PRIVMSG $channel :\0032\004Current Status:"
puthelp "PRIVMSG $channel :\0034 The current DJ is:$dj"
puthelp "PRIVMSG $channel :The current track is: $track"
puthelp "PRIVMSG $channel :With listeners: $listeners"
N
NTHosts
Op
Posts: 100
Joined: Mon Oct 10, 2005 9:57 pm
Location: UK
Contact:

hehe

Post by NTHosts »

Thanks, works perfect.. I shoulda guessed that myself eh :P

Oh well another day gone and a little bit more learnt :D thanks again :D
www.NT-Hosts.Net - More than just a host
Post Reply