I do a message filter in the Telegram bot. Faced such a problem.

I have the following:
слова_и_фразы = ["слово0 слово1", "слово2", ("слово3" || "слово4") && ("слово5" || "слово6" || "слово7")]

I need to find a word or words in the incoming line.

I do the following:
написанная_фраза.ИндексОф(слова_и_фразы[цикл] != -1) {console.log("Успешно")}

if I write bot - "слово0 слово1" - all is well
if I write bot - "слово0 слово2" - all is well
if I write bot - "слово3 слово6" or "слово6 слово3" - bad
the bot responds to слово3 , while ignoring the condition

I'm new, do not scold too much

How do you tell me?

  • Does the bot need to give a string or boolean? Who should parlay the country, client or server? - L11VADIS
  • what is it in the "word3" that makes the bot react to it like that? And who is the bot you have, does he have a name? - L11VADIS
  • @ Alexey, so what should I give the bot ??? is there any word or phrase in the array, tipo tru or falls. Or is the ordinal index in the array, what can this bot need it in the general object waiting for? - L11VADIS
  • @ Aleksey Only a string bot or he still needs a callback for work, so it means the bot is some kind of method on the client side? - L11VADIS 10:02 pm

1 answer 1

I solved the problem by constructing a double array (array in sub array). Where 0 is the first phrase, 1 is the second phrase. Next, check in two cycles. Thank you all who helped)