Help with some RegEx please?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Help with some RegEx please?

Post by PepeLapiu » 08 Feb 2023, 14:37

Okay guys. Some of the code below was provided graciously by one of the senior members here. While I understand some of it, I am not sure what is going on here.

Here is the goal of the script: on a page chat section, my software asks a question that ends with "(YES or NO only please)" And it keeps asking this question until it gets either a yes or a no answer. So the RegEx seeks to find the first following message directly after the last instance of my question.

Code: Select all

	Loop, Parse, chat_copy, `n, `r
		{
		pepe   := RegExMatch(A_LoopField, "^PepeBot says:.*\(YES or NO only please\)$")
		nTimes := pepe ? 0 : nTimes
		nTimes += time := RegExMatch(A_LoopField, "^\d{1,2}:\d\d:\d\d .M$")
		answer := !time && !pepe && nTimes = 1 && A_LoopField > "" ? A_LoopField : answer
		}
	MsgBox,% "[" answer "]"
	
And here is a sample of my chat_copy variable, which is basically the content of the chat copied into the variable chat_copy:
chat_copy:=
"Admin
ATTENTION! BE AWARE OF THE SCAMMERS!
Admin
Do not send the funds until the contract is in the In-progress status. Do not release the funds until you have received the payment. Admin will never contact you first, will not share any external links or request your payment password or other sensitive information. If you feel suspicious about your counterparty, start the dispute immediately!
PepeBot says: Hi PepeProton. Please give me a moment to gather some information.
2/8/2023, 11:28:10 AM

PepeBot says: The payment amount for this is contract is $10.03 CAD, not including miner fee.
2/8/2023, 11:28:41 AM

PepeBot says: Estimating miner fee.......
2/8/2023, 11:28:44 AM

PepeBot says: Do you agree to pay the miner fee of $1.63 CAD for this contract for a total payment of $11.66 CAD ? (YES or NO only please)
2/8/2023, 11:28:49 AM

Yes
2/8/2023, 11:28:53 AM"
Well, that bit of script has worked flawlessly for the last 7-8 months, But all of a sudden, it no longer works. And the only value I get for the variable answer is "", no matter what the user posts.

Can you tell me why it's no longer working?

PepeLapiu
Posts: 324
Joined: 19 Jun 2020, 14:06

Re: Help with some RegEx please?

Post by PepeLapiu » 08 Feb 2023, 18:49

Never mind. I found a work around.

Post Reply

Return to “Ask for Help (v1)”