Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[eventMacro] if statement bug #1316

Open
Yakov-Chernogor opened this issue Oct 26, 2017 · 5 comments
Open

[eventMacro] if statement bug #1316

Yakov-Chernogor opened this issue Oct 26, 2017 · 5 comments
Labels

Comments

@Yakov-Chernogor
Copy link
Contributor

Yakov-Chernogor commented Oct 26, 2017

I'm doing macro for spam blocking and I'm faced that if statement is bugged, it does not work with some phrases that contains <<<<<<< or >>>>>> symbols
My macro:

automacro spampm {
	PrivMsg /./i
	call {
		if( $.PrivMsgLastMsg =~ /(w.*|W.*|v.*|V.*).*(c[o0]m|C[0O]M)/ ) {
			do ignore 1 $.PrivMsgLastName
			log Ignoring $.PrivMsgLastName
		}
	}
}

Console error message:

[eventMacro] Error in macro 'tempMacro15'
[eventMacro] Line index of the error '0'
[eventMacro] Script of the line 'if ( $.PrivMsgLastMsg =~ /(w.|W.|v.|V.).*(c[o0]m|C[0O]M)/ ) {'
[eventMacro] Error message 'syntax error in if statement'

The private message from spamer:

[PM] (From: uf1295) : WWW.AOAUE.COM >>>>>>>>>>>>>>>10Mil Zeny = 3 usd>>>>Buy Zeny Get 5% Bonus >>>>WWW.AOAUE.COM >>>>>>>>>>>>5700

@Asonael
Copy link

Asonael commented Oct 26, 2017

You're missing a closing bracket.

@Yakov-Chernogor
Copy link
Contributor Author

Yakov-Chernogor commented Oct 26, 2017

Sorry, forgot it when I was trying to reproduce the bug. I've edited first post

@Asonael
Copy link

Asonael commented Oct 26, 2017

Okay, so why use the if statement for the regex detection? I'm sure the parentheses of regex is messing with the if statement formatting. Try this.

automacro spampm {
	PrivMsg /(w.*|W.*|v.*|V.*).*(c[o0]m|C[0O]M)/ 
	call {
		do ignore 1 $.PrivMsgLastName
		log Ignoring $.PrivMsgLastName
	}
}

It will only activate when a private message contains your desired regex. No need for a check for a private message first, then check what the message contains.

@Nipodemos
Copy link
Contributor

Nipodemos commented Oct 26, 2017

regex on eventMacro doesn't support you use ( and ) inside regex on an if condition

however, in a automacro condition, it works normally

there is a Pull Request to solve this issue (i did it) but only the creator of eventMacro can approve, and he is VERY busy with college
#1205

and this regex is wrong
you could do it like this :
if ( $.PrivMsgLastMsg =~ /www\..*\.com/i )

@windhamwong
Copy link
Contributor

I highly recommend you all using the strict regex.

In this case, I suggest www\.[\w\d-_]*\.co(m|\.\w+) to catch the URL.

If you want to examine or test out regex, please try it on online regex tester sites. i.e. https://regexr.com/

@alisonrag alisonrag changed the title eventMacro if statement bug [eventMacro] if statement bug Jul 15, 2018
@alisonrag alisonrag added the bug label Jul 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants