madelsberger / if_StreamlabsParameter

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

$msg parameter #2

Closed oberstlynild closed 5 years ago

oberstlynild commented 5 years ago

Hi.

I cannot make the "or" operator work. Is it possible? Here my command: $if('"$msg" == "fc" || "FC" || "Fc" || "fC"', 'Nice FC count is $count', '$dummy')

This command is working, but only if i do not use capitol letters: $if('"$msg" == "fc"', 'Nice FC count is $count', '$dummy')

Best regards Oberstlynild

oberstlynild commented 5 years ago

Also tried this: $if('"$msg" == "fc" || "$msg" == "FC"', 'Nice FC tæller er på $count', '$dummy')

Also does not seem to be working :(.

I also tried with only one |. Don't know why tho..

oberstlynild commented 5 years ago

And now i tried this: $if('("$msg" == "fc") | ("$msg" == "FC")', 'Nice FC tæller er på $count', '$dummy')

And that is working WTF hahaha. Sorry for the issues. Hope it could help someone tho.

madelsberger commented 5 years ago

UPDATE - fixed (I hope) the suggested expression below; I typed it incorrectly initially

Hello! It looks like you've found a workable solution, but to provide a little more context: the expression given to $if is interpreted by Python and must follow Python's rules for operator usage (and expressions in general). So || combines conditions (as you found in your final working version), not values (as in your original version).

That said, since what you're trying to do is a case-insensitive comparison, you might want to just convert $msg to lowercase and compare the result against "fc'. With only two letters, it is possible to use || and go through all possible matching values, but for anything longer it would start to be a real hassle.

'"$msg".lower() == "fc"'

Thanks for your interest in the $if script, and best of luck.