You must be a bot master or the bot owner for this to work.
In the pvt of the bot, you type - free me and the bot will store the value "free me" in the local variable test
bind msg m "-" mypvtcommand
proc mypvtcommand {nick host hand arg} {
if {$arg == ""} {
putserv "PRIVMSG $nick :You must enter a command"
} else {
set test $arg
}
}
the_crow wrote:i put a trigger in a channel, like !teste, and then the bot, enter contact with me by pvt like this:
<Bot> Put a name:
then i put a name
<me> teste
Then the bot keeps the text "teste" in the variable test
You mean GLOBAL variable, right? To catch the reply use a msgm bind. If you need to make sure the message you get is from the user typing the trigger you could store the nick and/or uhost of the person typing the trigger some where and check for the existance of a matching value in the proc triggered by the msgm bind.
bind pub - !trigger trigged
bind msgm - * input
proc trigged {n u h c a} {
global triggedBy
set triggedBy $u
putserv "PRIVMSG $n :Type something:"
}
proc input {n u h a} {
global triggedBy test
if {[info exists triggedBy]&&[string eq $triggedBy $u]} {
set test $a
unset triggedBy
putserv "PRIVMSG $n :ok"
}
}
So if i want to put another text in other variable after the first one text insert, should i do this?!
bind pub - !trigger trigged
bind msgm - * input
proc trigged {n u h c a} {
global triggedBy
set triggedBy $u
putserv "PRIVMSG $n :Type something:"
}
proc input {n u h a} {
global triggedBy test
global triggedBy test2
if {[info exists triggedBy]&&[string eq $triggedBy $u]} {
set test $a
unset triggedBy
putserv "PRIVMSG $n :ok"
putserv "PRIVMSG $n : Insert another thing:"
set test2 $a
unset triggedBy
putserv "PRIVMSG $n : Ok again"
}
}
# some questions
set surveyQ {
"How old are you?"
"Where do you live?"
"Can I come over to your place?"
}
# the binds
bind pub - !survey survey:pub
bind msgm - * survey:msgm
# start
proc survey:pub {n u h c a} {
global surveyQ surveyA
set surveyA($u) {}
putserv "PRIVMSG $n :[lindex $surveyQ 0]"
}
# fetching the answers
proc survey:msgm {n u h a} {
global surveyQ surveyA
if {[info exists surveyA($u)]} {
lappend surveyA($u) $a
if {[llength $surveyA($u)]<[llength $surveyQ]} {
# there are more questions to be asked...
putserv "PRIVMSG $n :[lindex $surveyQ [llength $surveyA($u)]]"
} {
# completed
putserv "PRIVMSG $n :We're done. Now go away!"
putlog "$n has completed the survey:"
foreach q $surveyQ a $surveyA($u) {
putlog "Q: $q"
putlog "A: $a"
}
# DON'T keep surveyA($u) after completion. If you want to keep the
# list of answers use a different variable.
unset surveyA($u)
}
}
}
Was that clear? If you have questions about parts of the code, please don't re-post the entire thing, and please use the code tag to keep it readable.
lindex $surveyA($u) <INDEX> will give you the answers by number...just set the variables from within the "completed" part. (before it's unset)
Or insert this (at the same point):
Hello.
I have made some thing like you said.
But i cant understand one thing.
I have made the tcl to put the variable inside a file so, i made the following
....
proc survey:msgm {n u h a} {
global surveyQ surveyA
if {[info exists surveyA($u)]} {
lappend surveyA($u) $a
if {[llength $surveyA($u)]<[llength $surveyQ]} {
# there are more questions to be asked...
putserv "PRIVMSG $n :[lindex $surveyQ [llength $surveyA($u)]]"
} {
# completed
set fp [open $n a]
puts $fp "..."
.......
close $fp
putserv "PRIVMSG $n: This message don't appear "
putserv "PRIVMSG $n :We're done. Now go away!"
putlog "$n has completed the survey:"
foreach q $surveyQ a $surveyA($u) {
putlog "Q: $q"
putlog "A: $a"
}
# DON'T keep surveyA($u) after completion. If you want tokeepthe
# list of answers use a different variable.
unset surveyA($u)
But the putserv "PRIVMSG $n: this message don't appear" the bot dont say in pvt , why can it be!??!?!
No, you didn't, or you would not have asked the question you asked.
the_crow wrote:So if i want to put another text in other variable after the first one text insert, should i do this?!
set test $a
unset triggedBy
putserv "PRIVMSG $n :ok"
putserv "PRIVMSG $n : Insert another thing:"
set test2 $a
unset triggedBy
putserv "PRIVMSG $n : Ok again"
This is what happens: Each time you trigger the msgm bind, the enire body of the proc is evaluated, and it has to return before anything else (except from the code currently being executed) can happen. There's no magic pause inserted at runtime to wait for more messages to arrive, just because you send a msg to a user asking for more info. The message is sent after the proc has returned, so you'll end up storing the same answer twice and asking more info that you won't store. (because the variable that is used to identify the user is unset (see complete code in your original post))
I have solved all my problems thanks to you. Thank you man
Can i make one more question?!?!
How can i make in tcl, to eggdrop del a file, after he created the file??
Thanks
I try to use the command exec rm $file but it didn't work