Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Triggering on imput from chat plugin snoop
|
Triggering on imput from chat plugin snoop
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Thu 21 Aug 2008 01:45 AM (UTC) Amended on Thu 21 Aug 2008 01:55 AM (UTC) by RichKK
|
| Message
| I really enjoy the chat.xml plugin and the built in chat session feature and make a lot of use out of #snoop %name and #command %name functions.
I'd like to know how I can have triggers on my client side match strings of snooped output from another computer.
I went over the chat.xml plugin but am unsure what needs to be done to. If necessary I can modify the chat.xml plugin on my MUSHclient and or the MUSHclient I'm snooping.
edit: would I be able to make use of
the world.ChatMessage function for triggering purposes? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Thu 21 Aug 2008 06:20 AM (UTC) |
| Message
| Have you read this?
http://www.gammon.com.au/mushclient/chat.htm
There is a description down near the bottom about making one chat client inform another one - if that doesn't answer your question let us know. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Reply #2 on Thu 21 Aug 2008 04:26 PM (UTC) |
| Message
| Are you referring to "Using a custom message number"?
My understanding is that still requires a trigger to capture strings and to send them with a custom message number?
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #3 on Thu 21 Aug 2008 09:16 PM (UTC) |
| Message
| OK, so you want to match on incoming snoops? That won't be a trigger because it is not MUD output. Check out Lua_Chat.xml plugin (or the VB one) and look for the function OnPluginChatMessage. That handles incoming chat messages.
You will want to detect message type 30 or 31 (snoop) and then use something like an if test or a regular expression to match on it. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Reply #4 on Thu 21 Aug 2008 10:26 PM (UTC) |
| Message
| | That's exactly what I wanted to do, thanks as always. | | Top |
|
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Reply #5 on Mon 09 Mar 2009 01:53 AM (UTC) Amended on Mon 09 Mar 2009 01:56 AM (UTC) by RichKK
|
| Message
| I don't understand how I can match a string with a wildcard here from snoop_data.
Example of a received Chat plugin message:
1500[37m[40mYou roll a [33m7[37m.
I chose not to strip the ANSI since in my game that is the best means I know to confirm the string is legitimately sourced from the gameplay and not simulated by a player.
This was my approach:
if message == 31 and sText == "1500[37m[40mYou roll a [33m(?P<roll>.+)[37m." then -- Match on that text. 31 is the message number for snoop_data
SetVariable ("roll", "%<roll>") -- Store the %<roll> variable
return true
end
The aim is to be able to match snoop_data strings against regular expression. I tried working with string.match, rex functions but the wildcard is still my impasse.
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #6 on Mon 09 Mar 2009 02:21 AM (UTC) |
| Message
| You can't do this:
sText == "1500[37m[40mYou roll a [33m(?P<roll>.+)[37m."
... because that is simply looking for a literal match, brackets and all.
With variable text you need string.match, and also convert the escape sequences. Things like [37m are really <esc>37m, which in a Lua literal would be: "\02737m" - where \027 is an "escape" character.
So, something like this would be required:
if message == 31 then -- 31 is the message number for snoop_data
local roll = string.match (sText, "1500\02737m\02740mYou roll a \02733m(%d+)\02737m%.")
-- if matched, roll will not be nil
if roll then
SetVariable ("roll", roll) -- Store the %<roll> variable
return true
end -- matched on roll
end -- if message 31
I haven't tested this, but it is closer to what you want. The sequence \027 where it appears above in bold is the escape character. The regular expression has a single wildcard which is (%d+), which will be returned in the "roll" variable.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Reply #7 on Mon 09 Mar 2009 05:21 AM (UTC) |
| Message
| | Thanks as always. I can now get a match with the ANSI stripped but not with. I won't give up on it :D | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #8 on Mon 09 Mar 2009 06:27 AM (UTC) |
| Message
| |
| Posted by
| RichKK
(33 posts) Bio
|
| Date
| Reply #9 on Mon 09 Mar 2009 07:32 AM (UTC) |
| Message
| | ha, awesome. much appreciated. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
31,708 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top