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.

Little problem

Old posts that have not been replied to for several years.
Locked
d
daltonc
Voice
Posts: 29
Joined: Wed Apr 27, 2005 8:50 pm

Little problem

Post by daltonc »

Ok, I am using this code to do my custom commands for my channel.. It doesnt seem to be working... This is what I have:

Code: Select all

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)
User avatar
^DooM^
Owner
Posts: 772
Joined: Tue Aug 26, 2003 5:40 pm
Location: IronForge
Contact:

Post by ^DooM^ »

Code: Select all

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
d
daltonc
Voice
Posts: 29
Joined: Wed Apr 27, 2005 8:50 pm

Post by daltonc »

Ok, another little thing (I think)

Here is my code:

Code: Select all

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"
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

try ${cmd_trigger}set instead of $(cmd_trigger)set.
d
daltonc
Voice
Posts: 29
Joined: Wed Apr 27, 2005 8:50 pm

Post by daltonc »

I need some more help now. :P

Code: Select all

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..
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

I think the error is from here

Code: Select all

if {[$result]} {
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

Code: Select all

if {[info exists result]} {
Although, I'm sure it'll always exist since the set command is right before it :p

Another simple but important thing to do is to replace

Code: Select all

[lrange $arg 2 end]
with

Code: Select all

[join [lrange [split $arg] 2 end]]
so you won't have problem with some particular characters.
d
daltonc
Voice
Posts: 29
Joined: Wed Apr 27, 2005 8:50 pm

Post by daltonc »

Alright sounds good, but the brackets are messed up:

Code: Select all

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?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Looks like the bot doesn't recognize that you're oped, is your net-type setting correct in your bot's config file ?
d
daltonc
Voice
Posts: 29
Joined: Wed Apr 27, 2005 8:50 pm

Post by daltonc »

yup @

But now its retuning nothing and I Get no errors :*(


I can set greeting and trigger but I cant set.. anything after the 'else'
Locked