Help with 'Gag' Trigger.

Posted by Lemon-Aid on Wed 18 Aug 2010 06:35 AM — 8 posts, 36,672 views.

USA #0
I need some help. I'm trying to make a Gag, that, whenever a person's name is mentioned, it just Gag's the trigger, and can keep it in a list. For example.

Quote:

Sally Keeps Yin's Ball all to Herself.

Yin Says "Hello!"

Barry Kick's Yin's face.


would all be gagged, as it contains the name 'Yin' (or match the plural 'Yin's)

I'd like to be able to add other names to this too.

This is what I currently have:

Match On: ^Yin|Yin|Yang|DreamFox*
Check: Omit From Output
Check: Ignore Case
Check: Regular Expression


This...Works.... kind of, I know it's busted, already. Mainly...I had to type 'Yin' Twice at the beginning to make it work....

as well, It will catch, and Gag words containing 'Yin', for example: 'Trying' and 'Flying', which I do not want it to. For example the sentence:

Quote:
I am Trying To Make This Gag Work


Will be Gagged and not appear.

I am new to this, and just worked with what I could find online. Help would be appreciated, as I'm stumped.



Amended on Wed 18 Aug 2010 06:38 AM by Lemon-Aid
Australia Forum Administrator #1
Check out:

Template:post=6609
Please see the forum thread: http://gammon.com.au/forum/?id=6609.


In your case I think one problem is you don't have brackets around the alternatives, eg. do this:


Match On: (Yin|Yang|DreamFox)


Also your use of ^Yin meant it would only match on Yin at the very start of the line.

Next, to match words, but \b around it, like this:



Match On: \b(Yin|Yang|DreamFox)\b


For more details see:

Template:regexp
Regular expressions
  • Regular expressions (as used in triggers and aliases) are documented on the Regular expression tips forum page.
  • Also see how Lua string matching patterns work, as documented on the Lua string.find page.
USA #2
Okay, THAT worked! Thank you!
Amended on Wed 18 Aug 2010 07:09 AM by Lemon-Aid
USA #3
Was going to start a new subject, but this works as well.
(i'm using VBscript if it means anything)

the line i am trying to gag is


vial61589      the toxin ether (thick)          25          4 


what i am using to gag it is:

<triggers>
  <trigger
   group="toxincheck"
   match="vial*      the toxin * (*)          *          *"
   omit_from_output="y"
   sequence="9"
  >
  </trigger>
</triggers>


it works on the line above, but not on the one below it, which is

vial168958     the toxin ether (thick)          40          131


Am i doing something wrong, or just missing something?
Amended on Thu 19 Aug 2010 05:10 AM by Nick Gammon
Australia Forum Administrator #4
It worked alright for me on both lines, once I enabled the trigger. You posted it disabled.
Australia Forum Administrator #5
Ah I see the spaces better now. I would make that a regexp and not be so dependant on the exact number of spaces.

Something like this:


<triggers>
  <trigger
   enabled="y"
   group="toxincheck"
   match="^vial\d+\s+the toxin\s+.*?\s+\(.*?\)\s+\d+\s+\d+\s*$"
   omit_from_output="y"
   regexp="y"
   sequence="9"
  >
  </trigger>
</triggers>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.


Instead of counting spaces the symbols \s+ mean "one or more spaces", and \d+ means "one or more digits".
Amended on Thu 19 Aug 2010 05:18 AM by Nick Gammon
USA #6
OH ok. yeah I was looking for that code thing. Thanks a bunch for that!

But, I replaced mine with your version, and now it won't omit anything at all.
Amended on Thu 19 Aug 2010 05:25 AM by Shou
Netherlands #7
Try this one instead....

<triggers>
  <trigger
   enabled="y"
   group="toxincheck"
   match="^vial\d+\s+the toxin.*?\s+\d+\s+\d+\s*$"
   omit_from_output="y"
   regexp="y"
   sequence="9"
  >
  </trigger>
</triggers>


It's hard to guess what's wrong, but my guess it is an IRE mud you are playing, and I know from experience their shop listings have poor mans layouts being used, where backspaces are being used to hide stuff. Maybe they fixed it since, but by leaving out the bracketed prt in the regexp, and making it a full wildcard, it might fix your problems.

Hopefully it works better for you.