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.

Tcl script help

Old posts that have not been replied to for several years.
Locked
V
Vizionz
Voice
Posts: 3
Joined: Wed Feb 09, 2005 12:28 am

Tcl script help

Post by Vizionz »

Alright i downloaded a script here that Scans for playlists
well okay i added it and its on the web but i dont understand how it actually works...

http://www.egghelp.org/cgi-bin/tcl_arch ... ad&id=1076
there the actual download

Code: Select all

#playlist scan by #@homer
#version 0.5
#email fkhg1@web.de (reason scriptname.tcl)
#icq 92566354
#simple make a playlist of all your mp3's or what you whant
#than put it into a direcory (simple ~/playlists/playlist01.htm or what you whant)
#use !addpl Playlist1 ~/playlists/playlist01.html (be sure that you are bot owner)
#if you whant to donate me paypal: fkhg1@web.de
#if you have any problems with the script just visit me
#my homepage www.homer-im-bett.de.vu
#
#i have made this script for the radio #dynamix in irc.quakenet.org www.rautedynamix.de
#if you have any good ideas what i can code just visit me :D i have a lot of time ^^
#copyright 2004 homer^im^bett Florian K.

bind pub n !addpl appp
bind pub - !setcurrent scurr
bind pub - !playlist plsearch

#do not change or ripp anything under this line:
#-----------------------------------------------
proc searchlist {listname nick strings} {
	if {![file exists $listname]} {
		putserv "NOTICE $nick :Playlist Not Found"
		varin ~/stream.txt scan no
		return noplaylist
	}
	if {[file exists $listname]} {
		set fs [open $listname r]
		set found 0
		regsub -all " " $strings "*" bla
		gets $fs point
		while {![eof $fs]} {
			if {[string match -nocase "*$bla*" $point]} {
				incr found
				set output($found) $point
			}
			gets $fs point
		}
		close $fs
		if {$found == 0} {
			putserv "NOTICE $nick :nothing found!!!"
			varin ~/stream.txt scan no
			return found0
		}
		if {$found <= 5} {
			set afound 1
			while {$afound <= $found} {
				regsub -all "<BR>" $output($afound) "" text
				regsub -all "<br>" $text "" text
				puthelp "NOTICE $nick :$afound / $found found: $text"
				incr afound
			}
			varin ~/stream.txt scan no
			return afterwhile
		}
		if {$found >= 5} {
			putserv "NOTICE $nick :too many matches ($found) show the first 5 matches"
			set afound 1
			while {$afound <= 5} {
				regsub -all "<BR>" $output($afound) "" text
				regsub -all "<br>" $text "" text
				puthelp "NOTICE $nick :$afound / $found found: $text"
				incr afound
			}
		}
	}
	varin ~/stream.txt scan no
}
proc appp {nick host handle chan text} {
	if {$text == ""} {
		putserv "NOTICE $nick :Syntax: !addpl NAME OF HTML PLAYLIST ~/playlists/XXXXX.html \"!addpl play01 ~/playlists/play01.html\""
		return help
	}
	addpl $nick [lindex $text 0] [lindex $text 1] $chan 
}
proc addpl { nick plname pl chan } {
	if {![file exists $pl]} {
		putserv "NOTICE $nick :PlayList Not Found"
		return noplaylist
	}
	if {[file exists $pl]} {
		varin ~/playlists.txt $plname $pl
		putserv "NOTICE $nick :playlist saved as: $plname"
		putserv "PRIVMSG $chan :playlist: $pl : $nick name: $plname"
		return everythingdone
	}
}
proc scurr {nick host handle chan text} {
	if {[lindex $text 0] == ""} {
		putserv "NOTICE $nick :!setcurrent playlistname"
		return 0
	}
	if {![file exists [varout ~/playlists.txt [lindex $text 0]]]} {
		putserv "PRIVMSG $chan :playlist not in list"
		return 1
	}
	if {[varout ~/playlists.txt [lindex $text 0]] == "0"} {
		putserv "PRIVMSG $chan :playlist not in list"
		return 2
	}
	if {[varout ~/playlists.txt [lindex $text 0]] != "0"} {
		varin ~/stream.txt current [varout ~/playlists.txt [lindex $text 0]]
		varin ~/stream.txt curpl [lindex $text 0]
		putserv "PRIVMSG $chan :playlist set to: [varout ~/playlists.txt [lindex $text 0]]"
		return 10000
	}
}
proc plsearch {nick host handle chan text} {
	if {[varout ~/stream.txt curpl] == 0} {
		putserv "NOTICE $nick :Playlist not loadet"
		return nopl
	}
	if {[varout ~/stream.txt current] == 0} {
		putserv "NOTICE $nick :Playlist not loadet"
		return nopl
	}
	if {[varout ~/stream.txt scan] == "scan"} {
		putserv "NOTICE $nick :Please wait"
		return already
	}
	if {$text == ""} {
		putserv "NOTICE $nick :syntax: !playlist string to search"
		return 0
	}
	if {[llength [split $text ""]] <= 2} {
		putserv "NOTICE $nick :string to short must be longer than 3 letters"
		return 2short
	}
	varin ~/stream.txt scan scan
	putserv "NOTICE $nick :Scanning playlist: [varout ~/stream.txt curpl]"
	searchlist [varout ~/stream.txt current] $nick [lrange $text 0 end]
	return 0
}

##### one piece of my var.tcl normal it is very big if you whant it contact me in irc.quakenet.org #@homer #####
#copyright 2004 homer^im^bett Florian K.
#do not change or ripp anything under this line:
#-----------------------------------------------

proc varin {storeplace var text} {
	if {![file exists $storeplace]} {
		set fs [open $storeplace w]
		puts $fs ""
		close $fs
	}
	set change 0
	set fs [open $storeplace r]
	set tmpfs [open $storeplace.tmp w]
	while {![eof $fs]} {
		gets $fs line
		if {[lindex $line 0] != $var && [lindex $line 0] != ""} {
			puts $tmpfs "$line"
		}
		if {[lindex $line 0] == $var} {
			puts $tmpfs "$var [lrange $text 0 end]"
			set change 1
		}
	}
	if {!$change} {
		puts $tmpfs "$var [lrange $text 0 end]"
	}
	close $fs
	close $tmpfs
	set fs [open $storeplace.tmp r]
	set grrr "[read $fs]"
	close $fs
	set fs [open $storeplace w]
	puts $fs "$grrr"
	close $fs
	return 0
}
proc varout {storeplace var} {
	if {![file exists $storeplace]} {
		return file!exists
	}
	set fs [open $storeplace r]
	set varX 0
	set ende 0
	while {![eof $fs] || !$ende} {
		gets $fs line
		if {[lindex $line 0] == $var} {
			close $fs
			return [lrange $line 1 end]
			set varX [lrange $line 1 end]
			set ende 1
		}
		if {$line == ""} {
			close $fs
			return 0
		}
	}
	close $fs
	return $varX
}
now theres the actual coding within the tcl

now my real question is how does it work?


bind pub n !addpl appp
bind pub - !setcurrent scurr
bind pub - !playlist plsearch
^---- What do these mean is this something i need to do somewhere ?

and if not where does the Playlist Directory need to reside i added it in like three directories and one of them worked but not sure which one its actually in hehe.

but my real problem is what use is this. when i try to search like !playlist name it keeps saying not loadet so obviousely something is wrong can anyone help with how this actually works and the right steps to get it running ...
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

First of all the Binds are needed by the bot you dont need to do anything to them. they are just there to BIND a trigger like !playlist. So when someone types !playlist it checks against the binds and knows which procedure to run.

Secondly if you read the authors description at the top of the script you would of seen that it doesn't matter where you put the playlist as you tell the script where it is when you use !addpl.
#than put it into a direcory (simple ~/playlists/playlist01.htm or what you whant)
#use !addpl Playlist1 ~/playlists/playlist01.html (be sure that you are bot owner)
Hope this helps,
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
User avatar
YooHoo
Owner
Posts: 939
Joined: Thu Feb 13, 2003 10:07 pm
Location: Redwood Coast

Re: Tcl script help

Post by YooHoo »

Vizionz wrote:bind pub n !addpl appp
bind pub - !setcurrent scurr
bind pub - !playlist plsearch
^---- What do these mean is this something i need to do somewhere ?
Read all about BINDS.
Vizionz wrote:and if not where does the Playlist Directory need to reside i added it in like three directories and one of them worked but not sure which one its actually in hehe.
Do like ^Doom^ said, use the !addpl command to tell the bot where to store your playlist (obviously, you must be a global +n owner)...be sure you delete the other 2 playlists from the shell, to cut down on confusion as to which playlist is valid and which is not....
V
Vizionz
Voice
Posts: 3
Joined: Wed Feb 09, 2005 12:28 am

Post by Vizionz »

okay thanks guys. figured that out still dont understand how to call the script though.

if i do like !playlist 1 it dont find anything or show anything :(
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

did you do

Code: Select all

!setcurrent playlistname
after adding a playlist?
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
Locked