madelsberger / if_StreamlabsParameter

An if-else parameter for streamlabs chatbot
MIT License
2 stars 0 forks source link

Only one expression being evaluated? #4

Open MyrTheMoth opened 2 years ago

MyrTheMoth commented 2 years ago

I'm trying to validate a command argument in a way such as

$if(' "$escMsg" != "enemy" and "$escMsg" != "friend" ', ' You must specify enemy or friend. ', '')

So that when chat uses the command in any other way besides !command enemy or !command friend they get the validation message.

!command and !command any-other-argument-besides-enemy-or-friend work as intended and respond in chat with the true message

But for some reason, !command enemy always returns the true message instead of returning the false empty message, and !command friend doesn't return anything as expected.

It seems the first expression of the evaluation is being ignored and only last expression is evaluated? I tried wrapping it with parenthesis and it's the same result, I used eval() in the actual python interpreter and such an expression would return True and False as expected.

In the end, what worked for me was to change it to

$if(' "$escMsg" not in ["enemy", "friend"] ', ' You must specify enemy or friend. ', '')

So it would only have to parse a single expression.