Counting the number of times of a phrase received

Posted by Artel on Thu 21 Oct 2004 02:28 AM — 7 posts, 25,247 views.

USA #0
Sorry for the repost, I think I was on the wrong board..anyways:

I want to count the number of times a particular person says a particular phrase on two different channels.(q/a channel)

For example:
Rathik answers 'yes :)'
Rathik questions 'anyone help me? :) Please? :)'

I want to make a few triggers that will record the number of times :) is said by a particular player on the question and answer channel. After each :) by only that particular player, I also want to send to commands to the world, 'desc -' and 'desc +<number of total :)>'. So far, there have been three :) in the example.
But, I don't see a way to do this.

Any help would be greatly appreciated.
USA #1
You can do it a few ways, one requires three triggers, the other requires one, but then takes some scripting.

Actually, I cant seem to get the multiple trigger one working.
Nick, I have a regexp to match on :) and it matches multiple times, but the script only executes once (per line)? Is that a bug?
Also, if I use positive lookahead (?=) without a end of line ($) mushclient hangs. Is this new (is it thinking that it might be a multiline thing?), heck, it actually hangs sometimes a few lines before its even turned on (is that time between recieve and display?), sort of wierd stuff going on with that positive lookahead.

But just match on any line with a trigger ("XXX (questions|answers) (.*):)")
and then use %0 (which is the full line) and use VBscript to search for ":)" in that, and then add that to a variable.
Amended on Thu 21 Oct 2004 04:46 AM by Flannel
Australia Forum Administrator #2
Scripts are queued up and only executed once per line, even if there were multiple matches on a regexp.

I'm not sure about the hang on the lookahead regexp, could be a bug there.

What might work for you is to have a regexp matching ":)" and then in a script do a "split" using ":)" as the splitting delimiter. Then see how many array items you get from the split.

eg.

blah :) blah :) blah

If split at :) would give 3 items, so there must have been two delimiters.
USA #3
I have the one :) per line working fine now. I just don't have enough scripting knowledge to try to count two :) in a line. If it is going to be really complicated, I could just settle for what I have.
USA #4
Change the regexp to whatever it should be. I tried to make it what you said it was though.
This works though, just make sure the trigger catches the full line.
I also colored it so you can test to make sure its matching, and it notes instead of sending. Tweak that, obviously.

<triggers>
  <trigger
   custom_colour="1"
   enabled="y"
   ignore_case="y"
   keep_evaluating="y"
   match="^Rathik (questions|answers) \'(.*?)\:\)(.*?)\'$"
   regexp="y"
   send_to="12"
   sequence="100"
  >
  <send>Dim SmileArray, i, j
SmileArray = Split(&quot;%0&quot;, &quot;:)&quot;, -1, 1)
j = -1
For Each i in SmileArray
j = j + 1
Next
setvariable &quot;smilecount&quot;, CInt(getvariable(&quot;smilecount&quot;)) + j
note getvariable(&quot;smilecount&quot;)</send>
  </trigger>
</triggers>
<variables>
  <variable name="smilecount">0</variable>
</variables>
USA #5
Now how would I match everything except something?
I tried the help file, and I couldn't get it to work. (nothing happens)

^(?!Rathik) answers \'(.*?)\'$<-- that is the right way to match everything except me, right?
Australia Forum Administrator #6
This is a completely different topic, right? Can you start a new thread? No-one will look here for "how to match everyone but me".