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.

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

Help for those learning Tcl or writing their own scripts.
Post Reply
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

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

Post by Diamond85 »

Need Help with

Code: Select all

			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: Select all

	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.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

nobody has an idea how I get to run it? :(
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

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: Select all

         set arg [split $arg] 
         switch -exact -- [lindex $arg 0] {
and:

Code: Select all

"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: Select all

   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]
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

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: Select all

   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: Select all

                  } 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: Select all

                        } 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: Select all

                     } 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: Select all

                     } 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: Select all

                  } 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.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

perhaps you understand better now what I care about here is the tcl
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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:)
Last edited by SpiKe^^ on Sat Dec 22, 2012 12:01 am, edited 1 time in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

okay I'll try to find the error.

thank you anyway for your quick reply once and your help :)
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

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: Select all

 			set arg [split $arg]
			switch -exact -- [lindex $arg 0] {
				default {

Code: Select all

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

Code: Select all

	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:28)  (test) !test reg
[Sat, 22/Dec/2012] (03:40:28)  (@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: Select all

 			set arg [split $arg]
			switch -exact -- [lindex $arg 0] {
				"del" {

Code: Select all

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

Code: Select all

	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)"
						}
					}
				}
			}
		}
	}
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Code: Select all

                     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
.
D
Diamond85
Voice
Posts: 27
Joined: Sat Oct 25, 2008 5:12 pm

Post by Diamond85 »

SpiKe^^ thank you so much

now it works the way I wanted!!!

thank thank thank :)
Post Reply