Bob!RynthidZerzelikyrAyanAerlintheNeftetgearknightsdarkisleSanctuary

ChatMessageCapture syntax

Unofficial support for the creating and editing of metas.
HittingSmoke
Posts: 28

ChatMessageCapture syntax

Post#1 » September 14th, 2016, 2:05 am

I'm trying to use ChatMessageCapture on Fellowship messages for a potential meta replacement for the old Make It! plugin.

I've found examples for tells and /vcg but nothing actually documents why there are parts that are so different from generic chat command matches. The wiki doesn't mention it at all. It just goes straight to examples.

Example ChatMessageCapture:
^\<Tell\:IIDString\:[^\:]*\:[^\>]*>(?<tellchar>[^\<]*)\<\\Tell\> tells you\, \"(?<telltext>.*)\"$

Example ChatMessage:
^\[Fellowship\] (|).* (say), \"!command"$

I hate hate hate regex. I searched around but the only references to IIDString are people writing AC plugins but nothing useful to me. I'm figuring it's something under the hood that I can't see?

Let's say I want:
[Fellowship] You say, "!make 10 Chorizite Potion"

...to save "10" as an int in capturegroup_amount and "Chorizite Potion" as a string in capturegroup_item.

How do I construct the ChatMessageCapture for that? I've tried tinkering around with various regexes similar to the example but nothing I've tried is setting the variables.
1 x

Dmdtt
Moderator
Posts: 266

Re: ChatMessageCapture syntax

Post#2 » September 14th, 2016, 9:17 am

Now I just want to say before I begin I know next to nothing about regex, so I am unsure if the specific chars regex is 100% secure. that being said I compared the virindi example and the regex given by validus of morningthaw for protecting chat commands and came up with these examples of chat cap regex.

Regex for capturing any char in any chat (this example will not react off your own personal chat)
(^(\[[A-z]+?\] |).*\<Tell:IIDString:.+:((?<tellchar>[^\<]*))\>.+\<\\Tell\>) (say|says|tells you), \"(?<text>.*)\"$

regex for capturing any character including yourself in any chat.
(^(\[[A-z]+?\] |)((?<tellchar>[^\<]*))|.*\<Tell:IIDString:.+:((?<tellchar>[^\<]*))\>.+\<\\Tell\>) (say|says|tells you), \"(?<text>.*)\"$

regex for specific characters in any chat including you(this example will not capture char name)
(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(Char1|Char2|Char3)\>.+\<\\Tell\>) (say|says|tells you), \"(?<text>.*)\"$

regex for specific channel capturing character name and text will work with your personal character
^\[ChannelName\] (((?<tellchar>[^\<]*))|.*\<Tell:IIDString:.+:((?<tellchar>[^\<]*))\>.+\<\\Tell\>) (say|says), \"(?<text>.*)\"$


now with that out of the way lets get to your example message of

[Fellowship] You say, "!make 10 Chorizite Potion"

for your example I'm going to use regex for specific characters in any channel including you because you don't need to capture character name.

Code: Select all

ChatCap (^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(Char1|Char2|Char3)\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$


this will save getvar[capturegroup_amount]==10 and getvar[capturegroup_item]==Chorizite Potion
1 x

Dmdtt
Moderator
Posts: 266

Re: ChatMessageCapture syntax

Post#3 » September 14th, 2016, 9:28 am

personally for nearly every chat capture involving commands I always use
(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(Char1|Char2|Char3)\>.+\<\\Tell\>) (say|says|tells you), \"(?<text>.*)\"$
as it prevents the rule from going off whenever someone else issues the same command or syntax that I use for my commands.
1 x

HittingSmoke
Posts: 28

Re: ChatMessageCapture syntax

Post#4 » September 14th, 2016, 11:23 am

Will an expression work in that? Could I use:

(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$

...to make it run only by the character the meta is running on without having to hard-code the meta to specific character names? I'd rather avoid that for distribution purposes. This will be more or less an always attended macro for crafting sessions so security it's a huge concern. I'd rather have it be as portable as possible.
1 x

Dmdtt
Moderator
Posts: 266

Re: ChatMessageCapture syntax

Post#5 » September 14th, 2016, 11:39 am

HittingSmoke wrote:Will an expression work in that? Could I use:

(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$

...to make it run only by the character the meta is running on without having to hard-code the meta to specific character names? I'd rather avoid that for distribution purposes. This will be more or less an always attended macro for crafting sessions so security it's a huge concern. I'd rather have it be as portable as possible.


alright in that case you could just use this ^\[Fellowship\] You say, \"!make (?<amount>.*) (?<item>.*)\"$

I am not able to log in at the moment to test it out but in theory at least that should work. it will only react off your personal character and only in fellowship chat, as of right now we cannot use expressions in a chat condition, if you want any channel I think this might work

^(\[[A-z]+?\] |)You (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$
1 x

HittingSmoke
Posts: 28

Re: ChatMessageCapture syntax

Post#6 » September 14th, 2016, 11:59 am

Dmdtt wrote:
HittingSmoke wrote:Will an expression work in that? Could I use:

(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$

...to make it run only by the character the meta is running on without having to hard-code the meta to specific character names? I'd rather avoid that for distribution purposes. This will be more or less an always attended macro for crafting sessions so security it's a huge concern. I'd rather have it be as portable as possible.


alright in that case you could just use this ^\[Fellowship\] You say, \"!make (?<amount>.*) (?<item>.*)\"$

I am not able to log in at the moment to test it out but in theory at least that should work. it will only react off your personal character and only in fellowship chat, as of right now we cannot use expressions in a chat condition, if you want any channel I think this might work

^(\[[A-z]+?\] |)You (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$


I asked the question about expressions because I didn't think I'd have time to test it today but I decided to screw around for a while this morning and it actually does work. My character's name here is Socrethreez.

Condition:
ChatMessageCapture: (^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$

/vt mexec clearallvars[]
[VTank] MExec evaluating expression: "clearallvars[]"
[VTank] Result: 0
/vt dumpmetavars
[VTank] Assigned meta variables:
[Fellowship] Ulyssies says, "!make 15 something"
Ulyssies tells you, "!make 15 something"
/vt dumpmetavars
[VTank] Assigned meta variables:
/f !make 20 things
[Fellowship] You say, "!make 20 things"
[VTank] Meta executing action: None
/vt dumpmetavars
[VTank] Assigned meta variables:
[VTank] capturegroup_0 = [Fellowship] You say, "!make 20 things"
[VTank] capturegroup_1 = [Fellowship] You
[VTank] capturegroup_2 = [Fellowship]
[VTank] capturegroup_4 = say
[VTank] capturegroup_amount = 20
[VTank] capturegroup_item = things
[VTank] capturecolor = 19

I think I might stick with that. Seems secure and portable.

The new problem is this doesn't work with multi-word items.

[VTank] Meta executing action: None
[VTank] Assigned meta variables:
[VTank] capturegroup_0 = [Fellowship] You say, "!make 15 chorizite potoin"
[VTank] capturegroup_1 = [Fellowship] You
[VTank] capturegroup_2 = [Fellowship]
[VTank] capturegroup_4 = say
[VTank] capturegroup_amount = 15 chorizite
[VTank] capturegroup_item = potoin
[VTank] capturecolor = 19

Looks like it splits at the last space. I'm going to mess around with a regex parser and see if I can get it capturing the correct parts.
1 x

Dmdtt
Moderator
Posts: 266

Re: ChatMessageCapture syntax

Post#7 » September 14th, 2016, 12:06 pm

one slight correction for this chat capture though
(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$
it is not reacting off getcharstringprop[1] in this example it is reacting off You near the beginning of the chat capture as I said earlier expressions don't do anything inside of chat message conditions or chat capture.
1 x

Dmdtt
Moderator
Posts: 266

Re: ChatMessageCapture syntax

Post#8 » September 14th, 2016, 12:12 pm

hmm could modify what command you use to You say, !make 10 item Chorizite Potions

then for the actual command portion of the capture you could use this instead

\"!make (?<amount>.*) item (?<item>.*)\"$

or something along those lines. that way it only captures 10 in the capture for amount and Chorizite Potions in the capture for item
1 x

HittingSmoke
Posts: 28

Re: ChatMessageCapture syntax

Post#9 » September 14th, 2016, 12:13 pm

Dmdtt wrote:one slight correction for this chat capture though
(^(\[[A-z]+?\] |)You|.*\<Tell:IIDString:.+:(getcharstringprop[1])\>.+\<\\Tell\>) (say|says|tells you), \"!make (?<amount>.*) (?<item>.*)\"$
it is not reacting off getcharstringprop[1] in this example it is reacting off You near the beginning of the chat capture as I said earlier expressions don't do anything inside of chat message conditions or chat capture.


Ahh. I see what you mean.

I fixed the space problems by only capturing non-zero numbers for <amount> with this:

^(\[[A-z]+?\] |)You (say|says|tells you), \"!make (?<amount>[1-9][0-9]*) (?<item>.*)\"$


[VTank] Meta executing action: None
[VTank] Assigned meta variables:
[VTank] capturegroup_0 = [Fellowship] You say, "!make 10 anything stuff"
[VTank] capturegroup_1 = [Fellowship]
[VTank] capturegroup_2 = say
[VTank] capturegroup_amount = 10
[VTank] capturegroup_item = anything stuff
[VTank] capturecolor = 19

So now I've got the listening logic working. On to building a loop to craft the correct amount of items...
1 x

Return to “VT: Meta Support”

Who is online

Users browsing this forum: No registered users and 2 guests

Login  •  Register