I found this great script which can make some decisions for me. It works like this:
<user> [ ] option 1 [ ] option 2 [ ] option 3
<bot> [x] option 1 [ ] option 2 [ ] option 3
The idea is great but I'd like to modify it a bit. The best way to avoid channel flooding is to set the user input on private messages and the actual output on the channel. Example:
User sends a private message to bot: "[ ] option 1 [ ] option 2 [ ] option 3"
Bot chooses randomly an option and prints the output on #channel:
<bot> user on private: [ ] option 1 [x] option 2 [ ] option 3
So I modified the code like this (Note: I haven't touched the actual text manipulating. I've only changed the first four lines and the puthelp-line):
Code: Select all
set channl #channel
bind msg - \[ proc:decision
proc proc:decision {nick host hand arguments} {
global channl
set arguments [split $arguments]
set count 1
set klammer_count 0
if {([lindex $arguments 0] == "]") || ([string first "]" [lindex $arguments 0]] == 0)} {
incr klammer_count
} else {
return
}
while {$count != [llength $arguments]} {
if {[lindex $arguments $count] == "\["} {
set tmp $count
incr tmp
if {([lindex $arguments $tmp] == "]") || ([string first "]" [lindex $arguments $tmp]] == 0)} {
incr klammer_count
}
}
incr count
}
set count 0
set myrand [rand $klammer_count]
set klammer_count 0
if {$myrand == 0} {
set output "\[x"
while {$count != [llength $arguments]} {
set output "$output[lindex $arguments $count] "
incr count
}
} else {
set output "\["
while {$count != [llength $arguments]} {
if {[lindex $arguments $count] == "\["} {
set tmp $count
incr tmp
if {([lindex $arguments $tmp] == "]") || ([string first "]" [lindex $arguments $tmp]] == 0)} {
incr klammer_count
}
}
if {$klammer_count == $myrand} {
if {([lindex $arguments $count] == "]") || ([string first "]" [lindex $arguments $count]] == 0)} {
set output "[string range $output 0 end]x"
} else {
set output "$output "
}
} else {
set output "$output "
}
set output "$output[lindex $arguments $count]"
incr count
}
}
puthelp "PRIVMSG $channl :$nick on private: '$output'"
}
So could someone help me? I'm really running out of ideas. Thanks in advance.
P.S. My first post
