T
T
typical_user102020-09-06 11:42:13
Python
typical_user10, 2020-09-06 11:42:13

How to answer a word from a sentence?

Tell me please.
I have a bot that reacts to certain words and then sends the text.
But the problem is that if a person writes a keyword in a sentence, then the bot will not respond.

Example:
Member: test
Bot: test - is in the list!

Participant: I'll go test
Bot: Doesn't react, but I wanted to.

How can this be fixed?
Thank you.

reac_words = [ 'test', 'test1']
slovo = None

@client.event
async def on_message(message):
    msg = message.content.lower()

    if msg in reac_words:
        slovo = msg
        await message.channel.send('{} - есть в списке!'.format(slovo))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2020-09-06
@tumbler

for word in reac_words:
    if word in msg:
        react()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question