Feature When a chat message contains"/w", do not discard the beginning of the message

slyz

Developer
When a chat message contains"/w", do not discard the beginning of the message

I didn't mark this as a bug, but maybe the behavior isn't intended.

When sending a chat message like this:
Code:
test /w faxbot test
ChatSender.getGrafs() recognizes the "/w" and turns the message into
Code:
/w faxbot test

When checking for other commands in the message, the code uses startsWith(), but in the case of PRIVATE_MESSAGE_PATTERN, it will match even if the "/w" is in the middle of the message.

I guess a "start of line" could be added to PRIVATE_MESSAGE_PATTERN, or line 248 of ChatSender.java could be changed to
Code:
if ( message.startsWith( "/w " ) && privateMessageMatcher.find() )
 

Grotfang

Developer
Only problem with that is it ignores all the other things people could do, like include "/whisper" or "/msg" in the middle of a message. It might solve your own problem, but it wouldn't make the solution elegant. startsWith requires a string argument, so can't use a matcher there and lots of OR statements seem messy. I've only had time to give this a cursory glance, but it'll take more than just the code you've posted. I get home in a few days; if no-one else wants to do this, I'll take another look then. I am not gifted with good regex abilities, so am very careful about screwing around with that, but a start of line on the regex seems to me to be the best solution.
 
Yeah, if startsWith is inelegant and you want to match any and all commands, but ignore them in any place that KoL vanilla would ignore them (goal, right?) then wouldn't
Code:
(?:^|&&)\s*/(\w+)
be the matcher? This would grab any /command that starts a line or immediately follows the double-ampersand.
 
Last edited:

slyz

Developer
I hadn't noticed the "msg|whisper|w|tell", and didn't think about people chaining chat commands with "&&". Adding
Code:
(?:^|&&)
at the beginning of PRIVATE_MESSAGE_PATTERN should do the trick.
 
Top