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.

help with switch commmand

Help for those learning Tcl or writing their own scripts.
Post Reply
g
ghostscript
Voice
Posts: 13
Joined: Wed Feb 08, 2006 4:08 pm
Location: unknown
Contact:

help with switch commmand

Post by ghostscript »

Hi guys, I am running eggdrop 1.6.17; I am trying to make my bot respond to comments made in private msg between the bot and user. We are having trouble getting the bot to respond dynamically to user input. Here is a sample of my code; any suggestions would be greatly appreciated.

Code: Select all

bind pub - !takethis pub_takethis
bind msg - !question pub_question

proc pub_takethis {nick mask hand channel args} {
        set args_list [split $args "."]
        set tnick [lindex $args_list 0]
        set tcase [lindex $args_list 1]
        set tchannel [lindex $args_list 2]

        putquick "PRIVMSG #bot_city :$tchannel"
        putquick "PRIVMSG $tchannel :!take"
        putquick "PRIVMSG #bot_city :!taken $tcase.$tchannel"
	putquick "PRIVMSG $tnick :Hello there\! My name is AgentBot. Give me a few moments to open and read over the case notes. I'll be right with you."      
}

proc pub_question {nick mask hand channel args} {
	putquick "PRIVMSG #bot_city :$nick it Worked!!"
	switch {$arg} {
		1 putquick { "PRIVMSG $nick :So this is a video issue." }
		2 putquick { "PRIVMSG $nick :so this is an audio issue." }
		3 putquick { "PRIVMSG $nick :so this is a startup issue." }
		default putquick { "PRIVMSG $nick :It could be anything." }
    	}   	
    }
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

switch $arg {
   1 {set str "one"}
   2 {set str "two"}
   3 {set str "three"}
}
puthelp "privmsg $nick :$str"
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

switch $arg {
   1-2 {set str "one or two"}
   3-4 {set str "three or for"}
   5 {set str "five"}
}
puthelp "privmsg $nick :$str" 
Once the game is over, the king and the pawn go back in the same box.
Post Reply