egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

help with add

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Mon Aug 14, 2006 10:00 am    Post subject: help with add Reply with quote

Code:

########################################
#tested to work on windrop             #
#v1.0 soon to be more updated          #
#email me for comments ,hate , or help #
#monie @ XG.Monie089@gmail.com         #
########################################
set wififile "wifi/wifi.txt"
set mphfile "wifi/mph.txt"
set mkdsfile "wifi/mkds.txt"
set acwwfile "wifi/acww.txt"
set thasfile "wifi/thas.txt"
set starfoxfile "wifi/starfox.txt"
if {![file exists $wififile]} {
   catch {close [open $wififile w]}
}
if {![file exists $mphfile]} {
   catch {close [open $mphfile w]}
}
if {![file exists $mkdsfile]} {
   catch {close [open $mkdsfile w]}
}
if {![file exists $acwwfile]} {
   catch {close [open $acwwfile w]}
}
if {![file exists $thasfile]} {
   catch {close [open $thasfile w]}
}
if {![file exists $starfoxfile]} {
   catch {close [open $starfoxfile w]}
}
bind pub -|- &wifi pub:wifi
proc pub:wifi {nickname uhost hostname  arguments handle  } {
putquick "PRIVMSG $nickname :Welcome to The WiFi Gaming Center"
putquick "PRIVMSG $nickname :Games Currently supported are"
putquick "PRIVMSG $nickname :MKDS MPH THAS ACWW STARFOX More coming soon"
putquick "PRIVMSG $nickname :Commands are as Following"
putquick "PRIVMSG $nickname :&list - lists the current games open"
putquick "PRIVMSG $nickname :&join <name> - Joins the game thats open"
putquick "PRIVMSG $nickname :&create <name> -creates a game"
putquick "PRIVMSG $nickname :&leave <name> - Parts you from that game"
putquick "PRIVMSG $nickname :&add - adds your code for any game"
putquick "PRIVMSG $nickname :&find - finds you or a friends code"
}
bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}
bind pub -|- &find pub:find
proc pub:find {nick uhost hand chan arg} {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mphfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mphcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mkdsfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mkdscode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::thasfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names thascode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::acwwfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names acwwcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::starfoxfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names starfoxcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
}
bind pub -|- &create pub:create
proc pub:create { nick uhost hand chan arg } {
set table [lindex [split $arg] 0]
if {$table != ""} {
set fd [open $::wififile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] == ""} {
set list [lreplace $list end end]
}
lappend list "\[$table\]"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &create game."
}
}


everything works but the add and how do i make the join leave and list part please help
_________________
New server irc.NintendoXG.com come and visit


Last edited by monie089 on Mon Aug 14, 2006 10:20 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
metroid
Owner


Joined: 16 Jun 2004
Posts: 771

PostPosted: Mon Aug 14, 2006 10:15 am    Post subject: Reply with quote

sigh.

also, why does it say "100% made by monnie" when half or more of this ''script'' has been made by others here.
Back to top
View user's profile Send private message
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Mon Aug 14, 2006 10:19 am    Post subject: Reply with quote

i did this
_________________
New server irc.NintendoXG.com come and visit
Back to top
View user's profile Send private message Send e-mail
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Aug 14, 2006 11:04 am    Post subject: Reply with quote

get rid of the [close [open]] nonsense and read here how you should deal with files
_________________
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code
Back to top
View user's profile Send private message Visit poster's website
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Mon Aug 14, 2006 11:26 am    Post subject: Reply with quote

ok thanks
EDIT:it still says TCL [pub:add]: missing close bracket
Code:

bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}

thats what im having trouble with please help
_________________
New server irc.NintendoXG.com come and visit
Back to top
View user's profile Send private message Send e-mail
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Aug 14, 2006 12:33 pm    Post subject: Reply with quote

It would be helpful if you tabinate.. This is unreadable as it is.
Back to top
View user's profile Send private message
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Mon Aug 14, 2006 12:40 pm    Post subject: Reply with quote

rosc2112 wrote:
It would be helpful if you tabinate.. This is unreadable as it is.

what do you mean by tabinate
_________________
New server irc.NintendoXG.com come and visit
Back to top
View user's profile Send private message Send e-mail
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Mon Aug 14, 2006 3:29 pm    Post subject: Reply with quote

http://forum.egghelp.org/viewtopic.php?t=10215
Back to top
View user's profile Send private message
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Mon Aug 14, 2006 3:34 pm    Post subject: Reply with quote

i dont even see errors in my script
_________________
New server irc.NintendoXG.com come and visit
Back to top
View user's profile Send private message Send e-mail
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Mon Aug 14, 2006 3:50 pm    Post subject: Reply with quote

<note>One should know how to debug it's own stuff.</note>

<off topic>
I've searched the dictionary and haven't found that word.
</off topic>

Anyway, he probably meant to use some sort of application to arrange your code. Something like this (and I quote):
Code:

bind pub -|- &add pub:add
proc pub:add {nick uhost hostname text arg handle channel} {
  global mphfile mkdsfile thasfile acwwfile starfoxfile
  set game [lindex [split $arg] 0]
  set code [lindex [split $arg] 1]
  if {$game !="mph"&& $code !=""} {
[...]
  }
}

_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
monie089
Halfop


Joined: 29 Jul 2006
Posts: 76

PostPosted: Tue Aug 15, 2006 4:22 pm    Post subject: Reply with quote

Code:

########################################
#100% made by monie                    #
#tested to work on windrop             #
#v1.0 soon to be more updated          #
#email me for comments ,hate , or help #
#monie @ XG.Monie089@gmail.com         #
########################################
set wififile "wifi/wifi.txt"
set mphfile "wifi/mph.txt"
set mkdsfile "wifi/mkds.txt"
set acwwfile "wifi/acww.txt"
set thasfile "wifi/thas.txt"
set starfoxfile "wifi/starfox.txt"
bind pub -|- &wifi pub:wifi
proc pub:wifi {nickname uhost hostname  arguments handle  } {
putquick "PRIVMSG $nickname :Welcome to The WiFi Gaming Center"
putquick "PRIVMSG $nickname :Games Currently supported are"
putquick "PRIVMSG $nickname :MKDS MPH THAS ACWW STARFOX More coming soon"
putquick "PRIVMSG $nickname :Commands are as Following"
putquick "PRIVMSG $nickname :&list - lists the current games open"
putquick "PRIVMSG $nickname :&join <name> - Joins the game thats open"
putquick "PRIVMSG $nickname :&create <name> -creates a game"
putquick "PRIVMSG $nickname :&leave <name> - Parts you from that game"
putquick "PRIVMSG $nickname :&add - adds your code for any game"
putquick "PRIVMSG $nickname :&find - finds you or a friends code"
}
bind pub -|- &add pub:add
proc pub:add { nick uhost text channel arg } {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mph"&& $code !=""} {
set fd [open $::mphfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="mkds"&& $code !=""} {
set fd [open $::mkdsfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="acww"&& $code !=""} {
set fd [open $::acwwfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="thas"&& $code !=""} {
set fd [open $::thasfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
set game [lindex [split $arg] 0]
set code [lindex [split $arg] 1]
if {$game !="starfox"&& $code !=""} {
set fd [open $::starfoxfile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end == ""]} {
set list [lreplace $list end end]
}
lappend list "\[$nick\] $game $code"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
} else {
putserv "PRIVMSG $nick :Usage: &add game code"
}
}
bind pub -|- &find pub:find
proc pub:find {nick uhost hand chan arg} {
global mphfile mkdsfile thasfile acwwfile starfoxfile
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mphfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mphcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::mkdsfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names mkdscode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::thasfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names thascode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::acwwfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names acwwcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
set name [lindex [split $arg] 0]
if {$name != ""} {
set fd [open $::starfoxfile r]
while {! [eof $fd]} {
lappend list [gets $fd]
}
close $fd
if {[set le [lsearch -glob $list "*$name*"]] != -1} {
set line [lindex $list $le]
set code [string map {"" ""} [lindex $line 2]]
putserv "NOTICE $nick :$names starfoxcode is $code"
} else {
putserv "NOTICE $nick :Name not found."
}
} else {
putserv "NOTICE $nick :Usage: &find nick"
}
}
bind pub -|- &create pub:create
proc pub:create { nick uhost hand chan arg } {
set table [lindex [split $arg] 0]
if {$table != ""} {
set fd [open $::wififile r+]
while {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] == ""} {
set list [lreplace $list end end]
}
lappend list "\[$table\]"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
putquick "PRIVMSG $chan :$table was created"
} else {
putserv "PRIVMSG $nick :Usage: &create game."
}
}
bind pub - &join pub:join
proc pub:join { nick chan hand arg text} {
set join [lindex [split $arg] 0]
if {$join != ""} {
set fd [open $::wififile r+]
While {![eof $fd]} {
lappend list [gets $fd]
}
if {[lindex $list end] = ""} {
set list [lreplace $list end end]
}
lappend list "\[$join\] $nick"
seek $fd 0
puts -nonewline $fd [join $list \n]
close $fd
putquick "PRIVMSG $nick :You have joined $join"
} else {
putserv "PRIVMSG $nick :Usage: &join name"
}
}

i found the missing brackets but now it says something bout "==" and interger
_________________
New server irc.NintendoXG.com come and visit
Back to top
View user's profile Send private message Send e-mail
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Aug 15, 2006 4:32 pm    Post subject: Reply with quote

A hint... there is something wrong with this
Code:

if {[lindex $list end == ""]} {


Actually, there's several things wrong with it...
Check the manual-page for lindex, and you'll see that argument 2 and following arguments should be list indexes ("start", "end", integers are some, == and "" are not)
Also, if you check the various operators supported in tcl (another manual-page), you'll find that == only works on numbers, not strings
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
Alchera
Revered One


Joined: 11 Aug 2003
Posts: 3344
Location: Ballarat Victoria, Australia

PostPosted: Tue Aug 15, 2006 6:36 pm    Post subject: Reply with quote

monie089 wrote:
rosc2112 wrote:
It would be helpful if you tabinate.. This is unreadable as it is.

what do you mean by tabinate

Edit your code and indent as per the example given. It makes code reading far easier.
_________________
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
Back to top
View user's profile Send private message Visit poster's website
incith
Master


Joined: 23 Apr 2005
Posts: 275
Location: Canada

PostPosted: Sun Aug 20, 2006 11:12 pm    Post subject: Reply with quote

The correct word is tabulate. Tabulate your code.
_________________
; Answer a few unanswered posts!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber