egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[SOLVED] Need Help on: set arg ... switch -exact ...

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Wed Dec 19, 2012 2:41 pm    Post subject: [SOLVED] Need Help on: set arg ... switch -exact ... Reply with quote

Need Help with
Code:
         set arg [split $arg]

         switch -exact -- [lindex $arg 0]


and the "del" code but !sm del works fine but the !sm del <nick> dont work the bot tell me only you no in my list ... the text in the tcl is in german.

any a idee for me?

sorry for my bad english :(

Code:
   namespace eval S_A {
      proc sa_action {nick host hand chan arg} {
         set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            "del" {
               if {[channel get $chan $S_M::S_I::si_name]} {
                  if {[matchattr $hand $S_M::G_S::gs_flags]} {
                     if {$arg == ""} {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
                     } else {
                        if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
                           putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg \00304existierst nicht \00314in meiner Datenbank\003."
                        } else {
                           S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
                           putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg wurde aus meiner datenbank \00304gelöscht\003."
                        }
                     }
                  } else {
                     if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $nik]'"] == ""} {
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du \00304existierst nicht \00314in meiner Datenbank\003."
                     } else {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
                     }   
                  }
               }
            }
            default {......................



edit: so by default wen i use $arg works now fine......


Last edited by Diamond85 on Sat Dec 22, 2012 3:48 am; edited 2 times in total
Back to top
View user's profile Send private message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 12:28 pm    Post subject: Reply with quote

nobody has an idea how I get to run it? Sad
Back to top
View user's profile Send private message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 9:14 pm    Post subject: Reply with quote

SpiKe^^ wrote:
Sorry, I know nothing about mysql or the tcl code needed to work it.


My problem has nothing to do with mysql.

my problem is the part removed.

if i write del he clears me. this is correct.
if i del nick writing he always says I'm not in its list. and he shall remove the nick.


my problem is the:
Code:
         set arg [split $arg]
         switch -exact -- [lindex $arg 0] {


and:
Code:

"del" {

if {$arg == ""} { ....


"Del" is indeed a "$ arg"
I guess that's why he my "! del <nick>" rather than "$ arg" recognizes

I'm sorry for my bad english

Code:
   namespace eval S_A {
      proc sa_action {nick host hand chan arg} {
         set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
           "del" {
               if {[channel get $chan $S_M::S_I::si_name]} {
                  if {[matchattr $hand $S_M::G_S::gs_flags]} {
                     if {$arg == ""} {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
                     } else {
                        if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
                           putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg \00304existierst nicht \00314in meiner Datenbank\003."
                        } else {
                           S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
                           putnow "PRIVMSG $chan :\00309$nick\003. \00314$arg wurde aus meiner datenbank \00304gelöscht\003."
                        }
                     }
                  } else {
                     if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $nik]'"] == ""} {
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du \00304existierst nicht \00314in meiner Datenbank\003."
                     } else {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan :\00309$nick\003. \00314Du wurdest aus meiner datenbank \00304gelöscht\003."
                     }   
                  }
               }
            }
            default {......................
[/code]
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Dec 21, 2012 9:18 pm    Post subject: Reply with quote

That has everything to do with mysql. It's not being able to find the nick in the database, or atleast that my understanding of the question:)
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 9:43 pm    Post subject: Reply with quote

SpiKe^^ wrote:
That has everything to do with mysql. It's not being able to find the nick in the database, or atleast that my understanding of the question:)


So for me it is a matter that the code is not quite right and I do not know how to be.
it should be so:
(bot owner)! del to delete me.
else you're not in my list
(bot owner)! del <nick> to delete arg
else arg is not in my list.
(user)! del to delete user.
else user you are not in my list

for example:
I am the bot owner

Diamond85: !del
EggDrop: I deleted you from the list
Code:

   namespace eval S_A {
      proc sa_action {nick host hand chan arg} {
         set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            "del" {
               if {[channel get $chan $S_M::S_I::si_name]} {
                  if {[matchattr $hand $S_M::G_S::gs_flags]} {
                     if {$arg == ""} {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan : I deleted you from the list"


Diamond85: !del
EggDrop: you're not in my list
Code:
                  } else {
                     if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $nik]'"] == ""} {
                        putnow "PRIVMSG $chan :you're not in my list"


Diamond85: !del test
EggDrop: I deleted test from the list
Code:
                        } else {
                           S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
                           putnow "PRIVMSG $chan :I deleted test from the list"
                        }
                     }


Diamond85: !del test
EggDrop: test is not in my list
Code:
                     } else {
                        if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
                           putnow "PRIVMSG $chan :test is not in my list"


Test: !del
EggDrop: I deleted you from the list
Code:
                     } else {
                        S_M::M_A::ma_query "DELETE FROM `$S_M::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan :I deleted you from the list"
                     }   
                  }
               }
            }


Test: !del
EggDrop: you're not in my list
Code:
                  } else {
                     if {[S_M::M_A::ma_query "SELECT Points FROM $S_M::M_S::ms_table WHERE Nick = '[mysqlescape $nik]'"] == ""} {
                        putnow "PRIVMSG $chan :you're not in my list"



Do you understand now what I mean?

mysql works perfectly. Only I know the sequence is not exactly from top to bottom so. bot owner. then check. then command. check again. then delete. check again. etc.
Back to top
View user's profile Send private message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 9:52 pm    Post subject: Reply with quote

perhaps you understand better now what I care about here is the tcl
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Dec 21, 2012 10:02 pm    Post subject: Reply with quote

Understood that the whole time.....

Your if statements are tied to your mysql database!

You are either using the wrong sql commands, or may be it's as easy as just typing the nick in the Exact same Case as it is in the sql database.

I'm betting it's just the search is Cese Sensitive, but as I said, I know nothing about mysql or the tcl code needed to work it. I'm just basing that on the fact you can remove yourself when you don't have to type the nick, and it's provided to the script as $nick as one of the procs arguments:)
_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.


Last edited by SpiKe^^ on Sat Dec 22, 2012 12:01 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 10:08 pm    Post subject: Reply with quote

okay I'll try to find the error.

thank you anyway for your quick reply once and your help Smile
Back to top
View user's profile Send private message
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Fri Dec 21, 2012 10:54 pm    Post subject: Reply with quote

SpiKe^^ wrote:
Understood that the whole time.....

Your if statements are tied to your mysql database!

You are either using the wrong sql commands, or may be it's as easy as just typing the nick in the Exact same Case as it is in the sql database.

I'm betting it's just the search is Cese Sensitive, but as I said, I know nothing about mysql or the tcl code needed to work it. I'm just basing that on the fact you can remove yourself when you don't have to type the nick, and it's provided to the script as $nick as one of the procs arguments:)

Either way, I'm Done With This String, GoodLuck.


okay it's not because of mysql
I have tested it again properly!

how it works:

[Sat, 22/Dec/2012] (03:36:13)  (test) !test reg
[Sat, 22/Dec/2012] (03:36:13)  (@EggDrop) [Test_Tcl] okay
[Sat, 22/Dec/2012] (03:36:16)  (Diamond85) !test reg
[Sat, 22/Dec/2012] (03:36:17)  (@EggDrop) [Test_Tcl] okay
[Sat, 22/Dec/2012] (03:36:31)  (Diamond85) !del
[Sat, 22/Dec/2012] (03:36:31)  (@EggDrop) I deleted you from the list
[Sat, 22/Dec/2012] (03:36:33)  (Diamond85) !del
[Sat, 22/Dec/2012] (03:36:33)  (@EggDrop) you're not in my list
[Sat, 22/Dec/2012] (03:36:50)  (Diamond85) !del test
[Sat, 22/Dec/2012] (03:36:50)  (@EggDrop) Diamond85 I deleted test from the list
[Sat, 22/Dec/2012] (03:36:55)  (Diamond85) !del test
[Sat, 22/Dec/2012] (03:36:55)  (@EggDrop) Diamond85 test is not in my list
[Sat, 22/Dec/2012] (03:38:23)  (test) !del
[Sat, 22/Dec/2012] (03:38:23)  (@EggDrop) I deleted you from the list
[Sat, 22/Dec/2012] (03:38:54)  (test) !del
[Sat, 22/Dec/2012] (03:38:54)  (@EggDrop) you're not in my list

It is because:
Code:
          set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            default {


Code:
               if {[channel get $chan $T_T::S_I::si_name]} {
                  if {[matchattr $hand $T_T::G_S::gs_flags]} {
                     if {$arg == ""} {


Code:
   namespace eval S_A {
    #############################################################################
    #                               Start_Action                                #
    #############################################################################

      proc sa_action {nick host hand chan arg} {
          set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            default {
               if {[matchattr $hand $T_T::G_S::gs_flags]} {
                  if {![channel get $chan $T_T::S_I::si_name]} {
                     putnow "PRIVMSG $chan :\003\[\00304$T_T::S_I::si_name\003\] \00314ist \00304Deaktiviert\003! \00314Benutze Bitte \003$T_T::G_S::gs_char\00309$T_T::G_S::gs_bind \003(\00307On\003)"
                  }
               }
               if {[channel get $chan $T_T::S_I::si_name]} {
                  if {[matchattr $hand $T_T::G_S::gs_flags]} {
                     if {$arg == ""} {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $nick]'"] == ""} {
                           putnow "PRIVMSG $chan :you're not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                           putnow "PRIVMSG $chan : I deleted you from the list"
                        }
                     } else {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
                           putnow "PRIVMSG $chan :$nick $arg is not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
                           putnow "PRIVMSG $chan :$nick I deleted $arg from the list"
                        }
                     }
                  } else {
                     if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $nick]'"] == ""} {
                        putnow "PRIVMSG $chan :you're not in my list "
                     } else {
                        T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan : I deleted you from the list"
                     }   
                  }
               }
            }
         }
      }
   }


it does not work.

[Sat, 22/Dec/2012] (03:40:23)  (Diamond85) !test reg
[Sat, 22/Dec/2012] (03:40:24)  (@EggDrop) [Test_Tcl] okay
[Sat, 22/Dec/2012] (03:40:2Cool  (test) !test reg
[Sat, 22/Dec/2012] (03:40:2Cool  (@EggDrop) [Test_Tcl] okay
[Sat, 22/Dec/2012] (03:40:33)  (Diamond85) !del
[Sat, 22/Dec/2012] (03:40:45)  (Diamond85) !del del
[Sat, 22/Dec/2012] (03:40:45)  (@EggDrop) Diamond85 del is not in my list
[Sat, 22/Dec/2012] (03:41:02)  (Diamond85) !del del test
[Sat, 22/Dec/2012] (03:41:02)  (@EggDrop) Diamond85 del test is not in my list

it does not work because:
Code:
          set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            "del" {


Code:
               if {[channel get $chan $T_T::S_I::si_name]} {
                  if {[matchattr $hand $T_T::G_S::gs_flags]} {
                     if {$arg == ""} {


Code:
   namespace eval S_A {
    #############################################################################
    #                               Start_Action                                #
    #############################################################################

      proc sa_action {nick host hand chan arg} {
          set arg [split $arg]
         switch -exact -- [lindex $arg 0] {
            "del" {
               if {[matchattr $hand $T_T::G_S::gs_flags]} {
                  if {![channel get $chan $T_T::S_I::si_name]} {
                     putnow "PRIVMSG $chan :\003\[\00304$T_T::S_I::si_name\003\] \00314ist \00304Deaktiviert\003! \00314Benutze Bitte \003$T_T::G_S::gs_char\00309$T_T::G_S::gs_bind \003(\00307On\003)"
                  }
               }
               if {[channel get $chan $T_T::S_I::si_name]} {
                  if {[matchattr $hand $T_T::G_S::gs_flags]} {
                     if {$arg == ""} {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $nick]'"] == ""} {
                           putnow "PRIVMSG $chan :you're not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                           putnow "PRIVMSG $chan : I deleted you from the list"
                        }
                     } else {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $arg]'"] == ""} {
                           putnow "PRIVMSG $chan :$nick $arg is not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $arg]';"
                           putnow "PRIVMSG $chan :$nick I deleted $arg from the list"
                        }
                     }
                  } else {
                     if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $nick]'"] == ""} {
                        putnow "PRIVMSG $chan :you're not in my list "
                     } else {
                        T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                        putnow "PRIVMSG $chan : I deleted you from the list"
                     }   
                  }
               }
            }
            default {
               if {[matchattr $hand $T_T::G_S::gs_flags]} {
                  if {![channel get $chan $T_T::S_I::si_name]} {
                     putnow "PRIVMSG $chan :\003\[\00304$T_T::S_I::si_name\003\] \00314ist \00304Deaktiviert\003! \00314Benutze Bitte \003$T_T::G_S::gs_char\00309$T_T::G_S::gs_bind \003(\00307On\003)"
                  }
               }
            }
         }
      }
   }
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 792
Location: Tennessee, USA

PostPosted: Fri Dec 21, 2012 11:54 pm    Post subject: Reply with quote

Code:

                     if {[lindex $arg 1] == ""} {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape $nick]'"] == ""} {
                           putnow "PRIVMSG $chan :you're not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape $nick]';"
                           putnow "PRIVMSG $chan : I deleted you from the list"
                        }
                     } else {
                        if {[T_T::M_A::ma_query "SELECT Count FROM $T_T::M_S::ms_table WHERE Nick = '[mysqlescape [lindex $arg 1]]'"] == ""} {
                           putnow "PRIVMSG $chan :$nick $arg is not in my list"
                        } else {
                           T_T::M_A::ma_query "DELETE FROM `$T_T::M_S::ms_table` WHERE `Nick` = '[mysqlescape [lindex $arg 1]]';"
                           putnow "PRIVMSG $chan :$nick I deleted $arg from the list"
                        }
                     }


_________________
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Back to top
View user's profile Send private message Visit poster's website
Diamond85
Voice


Joined: 25 Oct 2008
Posts: 27

PostPosted: Sat Dec 22, 2012 3:47 am    Post subject: Reply with quote

SpiKe^^ thank you so much

now it works the way I wanted!!!

thank thank thank Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber