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 

How to ignore channel messages with a specific phrase?

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


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 19, 2014 4:54 am    Post subject: How to ignore channel messages with a specific phrase? Reply with quote

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.
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sat Jul 19, 2014 11:07 am    Post subject: Reply with quote

Put something like this into the proc that does the replying...
Code:
if {$txt eq "good morning!"} {  return 0  }

Then do the channel reply after this line.
_________________
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
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 19, 2014 11:17 am    Post subject: Reply with quote

I get a TCL error:
Quote:
Tcl error [good:msg]: can't read "txt": no such variable


This is the code I am using:

Code:
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
 }
}
Quote:
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sat Jul 19, 2014 11:23 am    Post subject: Reply with quote

Because you did not change the var name to fit into your proc:)

Code:
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
 }
}

_________________
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
daigo
Voice


Joined: 27 Jun 2014
Posts: 37

PostPosted: Sat Jul 19, 2014 11:29 am    Post subject: Reply with quote

Oops Embarassed Thank you Spike
Back to top
View user's profile Send private message
SpiKe^^
Owner


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

PostPosted: Sat Jul 19, 2014 1:13 pm    Post subject: Reply with quote

Or maybe more like this, cleaned up a little...
Code:
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
}

_________________
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
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