Help: A trigger using regular expressions that excludes certain things

Posted by Kersoix on Tue 18 Jan 2011 10:21 PM — 8 posts, 30,812 views.

#0
Hi, I would like a trigger that makes a beep when tells are sent to me; however, I would like certain tells to not trigger this.

For example -

ABC tells you: hey. -- this should trigger the sound, but

Gaspode tells you: hey. -- this should NOT trigger the sound, as well as

Duck Man's duck tells you: hey. -- this should NOT trigger the sound.

I've had a great deal of trouble getting the trigger to work properly -- either all 3 examples trigger the beep, or none of them trigger the beep.

I've also has success writing simple triggers using colours and/or beeps.

I've tried the following triggers using regular expressions, but none of them have worked.

^(?!Gaspode|Duckman).* tells you.*$

^.*(?!Gaspode|Duckman) tells you.*$

^.*(?!Gaspode|Duckman) (\w*) tells you.*$

^.*(?!Gaspode|Duckman)tells you.*$

as well as variations with and without spaces at various places.

I'm not sure what I'm doing wrong, or whether this is possible at all, although in the past I did manage to get something like this working before. I just can't recall how, ever since I accidentally deleted my previous version of the MUD.

Would appreciate a simple answer to the above, since as you can tell I'm ok at simple but fail at anything more complex.

Cheers.
Australia Forum Administrator #1
By far the simplest way is to ignore the look-behind negative assertions you seem to be playing with and just script the decisions.

For example, match on:


* tells you: *


(This is NOT a regular expression).

Then send to script, and in the script test if %1 (the person doing the telling) is in a list of exclusions.

eg.


exclusions = {
  Gaspode = true,
  Duckman = true,
-- more here
  }

-- play sound if NOT in table:

if exclusions ["%1"] == nil then
  Sound ("ding.wav")
end -- if


#2
Thanks, Nick. I'm trying out what you said, but I'm not quite sure I got it right. Well, it's not working out yet.

I've attached a screenshot here... could someone take a look please?

http://www.flickr.com/photos/98525667@N00/5369803767/

Thanks.
Amended on Wed 19 Jan 2011 04:27 PM by Kersoix
Australia Forum Administrator #3
I can test more easily if you simply use the inbuilt copying rather than taking screen-shots.

Template:copying
For advice on how to copy aliases, timers or triggers from within MUSHclient, and paste them into a forum message, please see Copying XML.


Also please post the MUD output you are testing against. For example:


Duck Man's duck tells you ...


That won't match (although elsewhere you said Duckman not "Duck Man"). First there is the space between "Duck" and "Man" and also there is the lack of space after "Duck Man" (because of the apostrophe).

So the trigger:


* tells you: *


... would match, but the %1 would be "Duck Man's duck". To really match "Duck Man's duck" (as an exclusion) it would need to be in the table, like this:


exclusions = {
  Gaspode = true,
  Duckman = true,
  ["Duck Man's duck"] = true,
-- more here
  }



Also, matching is case-sensitive.
#4
Yeah, you're right, it should be Duck Man, not Duckman. My bad.

Anyways, here's the code you asked for. What happens now is that the trigger still sounds on every tell.


<triggers>
  <trigger
   enabled="y"
   match="* tells you: *"
   match_bold="y"
   match_inverse="y"
   match_italic="y"
   send_to="12"
   sequence="101"
   sound="C:\Program Files\MUSHclient\worlds\Ding.wav"
   other_text_colour="orange"
   other_back_colour="midnightblue"
  >
  <send>exclusions = {
  Gaspode = true,
  ["The Duck Man's duck"] = true,
-- more here
  }
-- play sound if NOT in table:
if exclusions ["%1"] == nil then
  Sound ("ding.wav")
end -- if</send>
  </trigger>
</triggers>


Tells that should sound look like this:

Yase tells you: no, i'm not

Thalic tells you: There's a hole in our group, yes :)

Basically it includes every human being on the MUD.


Tells that should not sound look like this:

The Duck Man's duck tells you: Is it really, dear? Okay, then, I believe you.

Gaspode tells you: Vote for us now!

Basically I don't want tells from these characters on the MUD to make a beep.

Thanks.
Amended on Thu 20 Jan 2011 02:10 AM by Kersoix
Australia Forum Administrator #5

sound="C:\Program Files\MUSHclient\worlds\Ding.wav"


You are still playing the sound on the trigger match. You should change that to "no sound" and then let the trigger decide whether or not to play a sound.
#6
I wonder if there's a specific directory I have to put the sound file into?
Amended on Wed 12 Nov 2014 06:14 AM by Kersoix2
Australia Forum Administrator #7
If you use backslashes in the sound pathname you are likely to run into trouble. It *does* work but you sometimes need to double or quadruple the number of backslashes, because of the way backslashes are handled in strings.

I suggest putting the sounds into the "sounds" sub-folder under the MUSHclient.exe program (make it if it isn't there already). Then PlaySound at least looks for sound files there (I'm not sure about the Sound function). Then you don't need backslashes.