T
T
typical_user102020-09-06 14:16:06
Python
typical_user10, 2020-09-06 14:16:06

How to remove double output?

Tell me please.

I have a bot that reacts to a keyword (in a list) and outputs certain text.
The problem is that if there are 2 keywords in the text sent by the participant, then the bot will write 2 times.
How can this be fixed? How to make it so that if there are 2 keywords in the sentence, then the bot unsubscribed 1 time with 1 keyword.

Thank you.

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

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    msg = message.content.lower()
 
    for word in reac_words:
        if word in msg:
            slovo = word
            await message.channel.send('{} - есть в списке.'.format(slovo))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-09-06
@typical_user10

break
After messages.channel.send

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question