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 for those learning Tcl or writing their own scripts.
daigo
Voice
Posts: 37 Joined: Fri Jun 27, 2014 8:02 pm
Post
by daigo » Sat Jul 19, 2014 4:54 am
My bot responds to any phrase with "good morning" in it said by a user in a channel with "the sun is up" (so if a user said in the channel, "today is a good morning" my bot would still respond with "the sun is up").
How would I make it so that if a user says "good morning!" (with an exclamation point after the letter 'g'), my bot doesn't respond to this message and just ignores it?
I would like to know how to do this in general with any phrase.
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Jul 19, 2014 11:07 am
Put something like this into the proc that does the replying...
Code: Select all
if {$txt eq "good morning!"} { return 0 }
Then do the channel reply after this line.
daigo
Voice
Posts: 37 Joined: Fri Jun 27, 2014 8:02 pm
Post
by daigo » Sat Jul 19, 2014 11:17 am
I get a TCL error:
Tcl error [good:msg]: can't read "txt": no such variable
This is the code I am using:
Code: Select all
set goodchan "#daigo"
bind pubm - * good:msg
proc good:msg {nick host hand chan arg} {
global goodchan
if {[string match -nocase "*good morning*" $arg] && $chan == $goodchan && $nick != "daigo"} {
puthelp "PRIVMSG $goodchan :the sun is up"
return 0
}
}
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Jul 19, 2014 11:23 am
Because you did not change the var name to fit into your proc:)
Code: Select all
set goodchan "#daigo"
bind pubm - * good:msg
proc good:msg {nick host hand chan arg} {
global goodchan
if {[string tolower $arg] eq "good morning!"} { return 0 }
if {[string match -nocase "*good morning*" $arg] && $chan == $goodchan && $nick != "daigo"} {
puthelp "PRIVMSG $goodchan :the sun is up"
return 0
}
}
daigo
Voice
Posts: 37 Joined: Fri Jun 27, 2014 8:02 pm
Post
by daigo » Sat Jul 19, 2014 11:29 am
Oops
Thank you Spike
SpiKe^^
Owner
Posts: 831 Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:
Post
by SpiKe^^ » Sat Jul 19, 2014 1:13 pm
Or maybe more like this, cleaned up a little...
Code: Select all
set goodchan "#daigo"
bind pubm - * good:msg
proc good:msg {nick host hand chan txt} {
set txt [string tolower $txt]
if {$chan ne $::goodchan || $nick eq "daigo" || $txt eq "good morning!"} {
return 0
}
if {[string match "*good morning*" $txt]} {
puthelp "PRIVMSG $chan :the sun is up"
}
return 0
}