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.

My PCW scripts

Help for those learning Tcl or writing their own scripts.
Post Reply
t
to2
Voice
Posts: 4
Joined: Fri Feb 01, 2008 6:35 am

My PCW scripts

Post by to2 »

Hi all! the scripts is working great and all as for now. What I would like is some feedback on i.e. excess flood if the script is used to often and so on.


The script is used as follows:
Gamers seeking war and HAVE server use the !addpcw <theis speccs> command
Gamers seeking war WITHOUT server use "!listpcw" which will display the last 10 entrys to "!addpcw", using notice from my egg (this is where I an afraid of excess flood if the script is used very often)




First the "addpcw" script:

Code: Select all

set minkanal "#clan-war"
bind pub - !addpcw addpcwmsg

proc addpcwmsg {n u h c t} {


######
global minkanal 

if {[string tolower $c] != $minkanal} {
    putserv "NOTICE $n : Join #Clan-War to get full use of the seek and add Clan-War features!"
    return 0
}


######




 set filename "/home/to2/website/pw.txt"

 set fid [open $filename "a"]

 puts $fid "$n: Have Server! $t"

 close $fid

 puthelp "NOTICE $n :Your PCW: <Have Server! $t> have been added."
}


and second the "listpcw" script:

Code: Select all

package require http


set minkanal "#clan-war"
bind pub - !listpcw listplayers


proc listplayers {n u h c t} {


######
global minkanal

if {[string tolower $c] != $minkanal} {
    putserv "NOTICE $n : Join #Clan-War to get full use of the seek and add Clan-War features!"
    return 0

}


######


	set x [::http::geturl http://localhost/pw.txt]
	set lines [lrange [split [::http::data $x] \n] end-9 end]
	foreach e $lines {puthelp "NOTICE $n :$e"}
	::http::cleanup $x
}

Thanks in advance for all useful feedback! ^^
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Wait, if you access the file at "/home/to2/website/pw.txt", why do you use the http package?

That seems horribly silly to me.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Use puthelp instead of putserv, then it won't flood. Also, since you're sending notices to the nick $n, the only thing to worry about is exceeding sendq, not necessarily channel flooding.
t
to2
Voice
Posts: 4
Joined: Fri Feb 01, 2008 6:35 am

Post by to2 »

the thing is that I have been given some help around in different irc channels, someone posted me a simple way of displaying text and that was obviously through http :P

feel free to post "corrections" which will help!

and I will be using puthelp instead :)
Post Reply