Currently trying to find if an input contains anything within a list using python. I'm building a Discord Bot with rewrite, and want it to look at a message's content, and see if anything within is found in a list. I currently have it responding to messages that are equivalent to and item in the list, but I want it to respond to a message, for example that says "Hello world", not just "Hello".
greetings = ['hi', 'hello', 'bonjour', 'hola', 'hey', 'howdy', 'sup', 'welcome', 'greetings', 'yo', 'yoo', 'suh',
'hey there', 'hey y'all', 'what's up', 'whats up', 'whatsup', 'wassup', 'sup?', 'what's shakin'', 'what's new?',
'long time no see', 'good evening', 'good afternoon']
@client.event
async def on_message(message):
await client.process_commands(message)
content = message.content.lower()
if message.author == client.user:
return
if content in greetings:
await message.channel.send('Hello.')
return
question from:
https://stackoverflow.com/questions/65849508/using-a-list-against-an-input-and-seeing-if-it-contains-anything-within-a-list 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…