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.

How to do string match for IRC Action?

Help for those learning Tcl or writing their own scripts.
Post Reply
J
JaySon
Voice
Posts: 6
Joined: Mon Aug 04, 2014 7:12 pm

How to do string match for IRC Action?

Post by JaySon »

I want to do something like:

Code: Select all

bind pubm - * reply:action

proc reply:action {nick host hand chan txt} {
  set txt [string tolower $txt]

  if {([string match -nocase "goes to sleep" $txt] || [string match -nocase "wants to sleep" $txt]) && ![isbotnick $nick]} {
  puthelp "PRIVMSG $chan :$nick, don't fall asleep"
  }

  return 0
}
But, I want this command to be performed only when a user says: /me goes to sleep or /me wants to sleep (\001ACTION \001), and not a PRIVMSG. How can I change the string match so it works only with ACTION, and not PRIVMSG?
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

bind ctcp - ACTION reply:action 
 
proc reply:action {nick uhost hand dest key text} { 
    if {[string match -nocase "*goes*sleep*" $text] || \
	    [string match -nocase "*want*sleep*" $text] && $dest ne $::botnick} {
	    
		  puthelp "PRIVMSG $dest :$nick, don't fall asleep" 
		}
}
http://www.eggheads.org/support/egghtml ... html#binda
Last edited by heartbroken on Fri Aug 08, 2014 9:14 pm, edited 1 time in total.
Life iS Just a dReaM oN tHE wAy to DeaTh
J
JaySon
Voice
Posts: 6
Joined: Mon Aug 04, 2014 7:12 pm

Post by JaySon »

Thank you

I'm having another issues:

Code: Select all

bind ctcp - ACTION reply:action

proc reply:action {nick uhost hand dest key text} {
    if {[string match -nocase "*goes*sleep*" $text] || \
       [string match -nocase "*want*sleep*" $text] && $dest eq "JaySon"} {
      
      puthelp "PRIVMSG $dest :$nick, don't fall asleep"
      }
}
I want it to make it only respond to one user, but even when other users besides "JaySon" say "*goes*sleep*" or "*want*sleep*", the bot still responds this message in the channel.
User avatar
heartbroken
Op
Posts: 110
Joined: Thu Jun 23, 2011 11:15 pm
Location: somewhere out there

Post by heartbroken »

Code: Select all

bind ctcp - ACTION reply:action 
 
proc reply:action {nick uhost hand dest key text} { 
    if {![string match -nocase "*goes*sleep*" $text] || \
	    ![string match -nocase "*want*sleep*" $text] && $dest eq $::botnick} { return }
	
    if {[string equal -nocase "JaySon" $nick]} {
		  puthelp "PRIVMSG $dest :$nick, don't fall asleep"	
		 }
}
Life iS Just a dReaM oN tHE wAy to DeaTh
s
shipmark33
Voice
Posts: 1
Joined: Wed Oct 01, 2014 3:53 pm

Mohsin

Post by shipmark33 »

I want it to make it only respond to one user, but even when other users besides "JaySon" say "*goes*sleep*" or "*want*sleep*", the bot still responds this message in the channel.
You can get score highest marks in brain dumps dumps exam using ICMA and New York University .
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

Try restart the bot and se what happens
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
Post Reply