proc command:main {nick uhost hand chan arg} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row $result {
foreach element $row {
putnotc $nick "$element"
set cmd_trigger $element
}
}
if ([string tolower [lindex $arg 0]] == $(cmd_trigger}set} {
putnotc $nick "You ran the 'set' command"
}
}
I am getting this error:
[10:49] extra characters after close-brace
while executing
"proc command:main {nick uhost hand chan arg} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row..."
(file "scripts/main.tcl" line 50)
invoked from within
"source scripts/main.tcl"
(file "bot_configs/eggdrop.conf" line 1343)
proc command:main {nick uhost hand chan arg} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row $result {
foreach element $row {
putnotc $nick "$element"
set cmd_trigger $element
}
}
if {[string tolower [lindex [split $arg] 0]] == $(cmd_trigger)set} {
putnotc $nick "You ran the 'set' command"
}
}
Try this.
The lifecycle of a noob is complex. Fledgling noobs gestate inside biometric pods. Once a budding noob has matured thru gestation they climb out of their pod, sit down at a PC, ask a bunch of questions that are clearly in the FAQ, The Noob is born
bind pub -|- * command:main:set
### MAIN COMMAND FUNCTION ###
proc command:main:set {nick uhost hand chan arg} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row $result {
foreach element $row {
putnotc $nick "$element"
set cmd_trigger $element
}
}
putnotc $nick "$cmd_trigger"
if {[string tolower [lindex [split $arg] 0]] == $(cmd_trigger)set} {
putnotc $nick "You ran the 'set' command"
}
}
Now, I am trying to do this for 'custom' commands, and trying to obtain a trigger from the database which works correctly, I can obtain the trigger, but the bind isnt registring.. I dunno if * is wildcard but.. its not working.
In the database the chan_trigger is set to @ , and am typing @set and its not returning "You ran the 'set' command"
proc command:main:set {nick uhost hand chan arg} {
if {[isop $nick $chan]} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row $result {
foreach element $row {
set cmd_trigger $element
}
}
if {[string tolower [lindex [split $arg] 0]] == "${cmd_trigger}set" && [string tolower [lindex $arg 1]] == "greeting" } {
set greeting "[lrange $arg 2 end]"
putnotc $nick "Set greeting to '^B$greeting^B'"
} elseif {[string tolower [lindex [split $arg] 0]] == "${cmd_trigger}set" && [string tolower [lindex [split $arg] 1]] == "trigger"} {
set trigger "[lrange $arg 2 end]"
set save_trigger [mysql_query "UPDATE bot_channels SET chan_trigger='$trigger'"]
putnotc $nick "Set channel trigger to '^B$trigger^B'"
} else {
set command_input [string tolower [lindex $arg 1]]
set command_input_value "[lrange $arg 2 end]"
set result [mysql_query "SELECT command_name FROM bot_commands WHERE command_chan='$chan' && command_name='$command_input'"]
if {[$result]} {
foreach row $result {
foreach element $row {
set update_command [mysql_query "UPDATE bot_commands SET command_value='$command_input_value'"]
putnotc $nick "Updated $command_input to $command_input_value"
}
}
} else {
set insert_command [mysql_query "INSERT INTO bot_commands (command_chan, command_name, command_value) VALUES ('$chan', '$command_input', '$command_input_value'"]
putnotc $nick "Set $command_input to $command_input_value"
}
}
} else {
putnotc $nick "Error(1): You lack access to $chan"
putnotc $nick "Error(2): Unable to proccess command"
}
}
I'm getting this error:
[22:48] Tcl error [command:main:set]: invalid command name ""
Its kinda confusing. I dont know what line its on.. I just know that thats the proc I am getting the error in. I image its somewhere 'set command_input' and 'set command_input_value' .... etc..
This should return a boolean value (0 or 1). and as it seems in your proc, $result contains some different elements so it's probably not 0 or 1.
If you're trying to see if $result exists, then replace that with
proc command:main:set {nick uhost hand chan arg} {
if {[isop $nick $chan]} {
set result [mysql_query "SELECT chan_trigger FROM bot_channels WHERE chan_name='$chan'"]
foreach row $result {
foreach element $row {
set cmd_trigger $element
}
}
if {[string tolower [lindex [split $arg] 0]] == "${cmd_trigger}set" && [string tolower [lindex $arg 1]] == "greeting" } {
set greeting "[lrange $arg 2 end]"
putnotc $nick "Set greeting to '^B$greeting^B'"
} elseif {[string tolower [lindex [split $arg] 0]] == "${cmd_trigger}set" && [string tolower [lindex [split $arg] 1]] == "trigger"} {
set trigger "[lrange $arg 2 end]"
set save_trigger [mysql_query "UPDATE bot_channels SET chan_trigger='$trigger'"]
putnotc $nick "Set channel trigger to '^B$trigger^B'"
} else {
set command_input [string tolower [lindex $arg 1]]
set command_input_value "[lrange $arg 2 end]"
set result [mysql_query "SELECT command_name FROM bot_commands WHERE command_chan='$chan' && command_name='$command_input'"]
if {[info exist result]} {
foreach row $result {
foreach element $row {
set update_command [mysql_query "UPDATE bot_commands SET command_value='$command_input_value'"]
putnotc $nick "Updated $command_input to $command_input_value"
}
}
} else {
set insert_command [mysql_query "INSERT INTO bot_commands (command_chan, command_name, command_value) VALUES ('$chan', '$command_input', '$command_input_value'"]
putnotc $nick "Set $command_input to $command_input_value"
}
}
} else {
putnotc $nick "Error(1): You lack access to $chan"
putnotc $nick "Error(2): Unable to proccess command"
}
}
The reason I say bracket error is because I am getting this Error(1): You alck access to $chan.. and then the error(2), but I have ops in the channel. Any ideas?