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.

[Solved] Love Marriage Command

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

[Solved] Love Marriage Command

Post by kris »

Code: Select all

set mrryrole "/home/kris/Love/eggdrop/marriage.role"
bind msg "-|-" propose msg_propose 
proc msg_propose { nick userhost handle text } {
if {![file exsits $mrryrole]} { 
puthelp "NOTICE $nick :Error: #3001 Please email kris0089@gmail.com for more help." 
return
} else {
set found 0
#set text 0
set fs [open $file r]
while {![eof $fs]} {
gets $fs line
if {$line == $nick} { set found 1 }
#if {$line == $text} { set text 1 }
}
}
The error i get is: [14:41] Tcl error [msg_propose]: wrong # args: extra words after "else" clause in "if" command

so any help is greatly appreciated
Last edited by kris on Mon Oct 02, 2006 8:35 am, edited 1 time in total.
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

the procedure isn't closed, its missing a curly bracket right at the end.
<- tcl newb
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

there is also a typo in the condition expression.

PS: if you used proper formating with the

Code: Select all

, missing braces would be obvious already while posting.
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...
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

Spelling error

Post by kris »

exsists? we fixed that, my admins found it and showed me it.

Code: Select all


set mrryrole "/home/kris/Love/eggdrop/marriage.role"
bind msg "-|-" propose msg_propose
proc msg_propose { nick userhost handle text } {
if {![file exists $mrryrole]} {
puthelp "NOTICE $nick :Error: #3001 Please email kris0089@gmail.com for more help."
return
} else {
set found 0
#set text 0
set fs [open $file r]
while {![eof $fs]} {
gets $fs line
if {$line == $nick} { set found 1 }
#if {$line == $text} { set text 1 }
}
}
close $fs
if {$found} {
puthelp "NOTICE $nick :You are allready married, please join #Chapel to get a divorce."
} else {
if {$text} {
puthelp "NOTICE $Nick :$text is allready married, please both join #Chapel to get a divorce."
}
} else {
puthelp "NOTICE $nick :Congragulations, a Proposal has been sent to $text please wait in #Chapel for a response"
puthelp "NOTICE $text :$nick would like you to marry her, to agree type: /msg Love agree $nick to agree, to them and a notice will be sent to them. or type:$"
puthelp "PRIVMSG #Chapel :Marriage Proposal has been sent from $nick to $text lets see what they say."
}
}
}
Thats the whole code..
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Tcl uses the same convention as C regarding conditional expressions.

example:

Code: Select all

if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else? ?bodyN?
if manual page
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

Ergh?

Post by kris »

How is that ment to help?, also i need help with another part.

Code: Select all

bind msg "-|-" !femaleaccept msg_acceptf
proc msg_acceptf { nick userhost handle text } {
set mrryrole "/home/kris/Love/eggdrop/marriage.role"
global msg_acceptf
    set stripped  $text
    set qot_fd [open $mrryrole a+]
    puts $qot_fd $stripped
    close $qot_fd
puthelp "PRIVMSG #Chapel :$nick has said yes!"
puthelp "MODE #chapel -o $nick"
return
}
bind msg "-|-" !maleaccept msg_acceptm
proc msg_acceptm { nick userhost handle text } {
set mrryrole "/home/kris/Love/eggdrop/marriage.role"
global msg_acceptm
    set stripped $text
    set qot_fd [open $mrryrole a+]
    puts $qot_fd $stripped
    close $qot_fd
puthelp "PRIVMSG #Chapel :$nick has said yes!"
puthelp "MODE #chapel -o $nick"
return
}
the file goes as
nick1nick2

how do i get it as

nick1
nick2

any idea's?
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

We help those that help themselves.
kris wrote:The error i get is: [14:41] Tcl error [msg_propose]: wrong # args: extra words after "else" clause in "if" command
Read and learn.

You were given a link to assist in your education.

Fix one error before ignoring and trying to sort another (which you have not tried to fix yourself).

A hint for your second "problem"; ever thought of a carriage return?
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

ok..

Post by kris »

SO does that website say anything about deleting text from a file?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Just go up one level up to http://www.tcl.tk/man/tcl8.4/TclCmd/contents.htm and read about split and join, I am pretty sure this is what you are looking for, although the way you wrote it, it would be impossible, because if "nick1" and "nick2" are directly concated together without a seperating character like in your example, it would be impossible for the bot to seperate them (unless they are in alphabethical order and are all in another list like online on a channel).
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...
User avatar
kris
Voice
Posts: 14
Joined: Tue Sep 12, 2006 10:46 am
Location: Perth, Australia
Contact:

Post by kris »

the bot sets files as

nick1
nick2

now, and i want it to remove nick1 & nick2, so ill read that site
Post Reply