I'm currently working on an IRC bot for Twitch.tv and I was wondering how I can implement a banned words list? Here is what I have so far and I'm stumped because of my limited knowledge of python. Everything is working great so far except checking to see if banned words are in the message. This is the bit of code in question:
if bannedWords.split in message:
sendMessage(s, "/ban " + user)
break
I was thiking of checking a list to see if the message containts anything from the list?
bannedWords = ["badword1", "badword1"]
But I'm just not sure..
import string
from Read import getUser, getMessage
from Socket import openSocket, sendMessage
from Initialize import joinRoom
s = openSocket()
joinRoom(s)
readbuffer = ""
bannedWords = ["badword1", "badword1"]
while True:
readbuffer = readbuffer + s.recv(1024)
temp = string.split(readbuffer, "\n")
readbuffer = temp.pop()
for line in temp:
print(line)
if "PING" in line:
s.send(line.replace("PING", "PONG"))
break
user = getUser(line)
message = getMessage(line)
print user + " typed :" + message
if bannedWords.split in message:
sendMessage(s, "/ban " + user)
break
Thanks in advance!!