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.

cupbot

Old posts that have not been replied to for several years.
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

cupbot

Post by r0t3n »

i need to store the cup prize info for each channel, i would like to do this using cupprize.db and cupbot.db

I would like cupprize.db to hold the chanel name and the prize info like this:

#channel 10 bncs

or something like that, and in cupbot.db i want it to hold the on/off info like this

#channel on slots type ( type is 1on1 2on2 etc )
#channel2 off

so #channel off means the cup is offf for that channel, and if on its on

Please help me with this.

Commands i would like are:
!start slots prize
!setprize - to change the prize
!stop
!prize to show the prize

Please help with this, have no idea how to write to a .db file

Also need a !add team m8 etc system and !remove, but i think i can make that ;p i hope.

Also, i need different commands for different cups, like ( . for 1on1 | ! for 2on2 | ? for 3on3 | $ for 4on4 ) etc

Please help, thanks in advance!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

I've got the feeling you ask for help too much and RTFM too little

why don't you just bother to read TCL man pages about commands operating on files
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

well, this is a help forum, where people ask for help, maybe thats the reason !?!
r0t3n @ #r0t3n @ Quakenet
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

just please help me with this !!

Thanks in advance!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

this is a help forum for people who bother to search and read (for example Basic File Operations) before crying out loud for help
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

ok, i know how to write to cupprize.db but i dont know how to read from it.
i made a custom C flag for cupadmin

Code: Select all

bind pub oC|oC !setprize cup:prize

proc cup:prize {nick host handle chan text} {
global lastbind
set cupprize [lindex [split $text] end]
if {![matchattr $handle o|o $chan] && ![matchattr $handle C|C $chan]} {
putserv "NOTICE $nick :Error: You dont not have access to this command, +o or +C flag needed on $chan."
} elseif {[$cupprize == ""]} {
putserv "NOTICE $nick :Error: No prize was set, use $lastbind prize"
} elseif {[matchattr $handle o|o $chan] || [matchattr $handle C|C $chan] && [$cupprize != ""]} {
set fs [open "cupprize.db" w]
puts $fs "$chan $cupprize"
close $fs
putserv "NOTICE $nick :Done, Cupprize set to: $cupprize."
putserv "PRIVMSG $chan :Cupprize has been set by $nick, Prize: $cupprize."
}
}
I hope that works, please check. But how can i read that info and display it to a channel from a !prize proc ;p please help, thanks!!
r0t3n @ #r0t3n @ Quakenet
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you can read it like you wrote it. however if you want to save more than 1 price at the same time, I would recommned you use a list which you can read and write to you file.
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...
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

so

Code: Select all

bind pub - \$prize get:prize

proc get:prize {nick host hand chan args} {
set fs [open "cupprize.db" r]
set prize ""
while (![eof $fs]) { set gets [gets $fs]
if {[lindex $fs 0] = "$chan"} { set prize [lrange $fs 1 end] } } if {($prize == "")} { putserv "PRIVMSG $chan :No Prize Is Set..." } else { putserv "PRIVMSG $chan :The Cup Prize Is: $prize." }
}
Would that work, please check, Thanks!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you expect someone to run and debug that for you, without you bothering to test it yourself first? heh

that's not the way to learn Tcl/eggdrop scripting dude

anyway, some hints:
  • \$prize means your bind command is '$prize', which is probably not what you had in mind ($prize as variable)
  • your 'while' command is incorrect, use curly braces to enclose condition, not parenthesis
  • don't use built-in command's name ([gets]) as variable, this is bad practice
  • you try to use the file descriptor variable itself ([lindex $fs 0]) as data, which is nonsense
  • format your scripts using indentation, one statement per line
IMO, you are too lazy to bother trying to learn Tcl starting with simple and basic things first - you want to somehow jump writing complete and functional scripts, with others testing and debugging your stuff while you wait - as I said, this is not the way of becoming a scripter
G
Galadhrim
Op
Posts: 123
Joined: Fri Apr 11, 2003 8:38 am
Location: Netherlands, Enschede

Post by Galadhrim »

nor the way to ask for help. RTFM :shock:

its like asking ur mom for presents she cant even afford.
f
fajja
Voice
Posts: 14
Joined: Sun May 08, 2005 7:48 am

Post by fajja »

hello, hows the cupbot coming along? come across anymore problems? i can test itfor u if u want
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

erm, rather good, got most of it working, just need help on this !prize script, there is a error, and it does find the prize in the cupprize.db, my mate on irc said the script is correct, but he doesnt know the problem.
Can anyone help make a script to read a certain line from cupprize.db which a -string match *$chan* blah blah etc. Erm, i would post the !prize script, but i deleted it because it didnt work. Please help!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you didn't bother to read my remarks on your approach to Tcl scripting, or did you?
r
r0t3n
Owner
Posts: 507
Joined: Tue May 31, 2005 6:56 pm
Location: UK

Post by r0t3n »

i read that basic file operations, and what you said about not using the internal "get" command or whatever that is. The script i made worked, but replyed to the channel as: {#channel prize here}
How can i make it so it replies without the brackets and the channel name.
Thanks in advance!!
r0t3n @ #r0t3n @ Quakenet
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

extract the list element you need, using [lindex]
Locked