So currently I have this basic little chat bot that can read commands and can timeout users if their message contains a banned word or phrase. I was wondering how I can improve on this bot to be able to !add "word"
to the set of banned words and overall general flaw improvements.
import string
from Read import getUser, getMessage
from Socket import openSocket, sendMessage
from Initialize import joinRoom
s = openSocket()
joinRoom(s)
readbuffer = ""
banned_set = {"badword1", "badword2"}
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 not banned_set.isdisjoint(message.lower().split()):
sendMessage(s, "/timeout " + user)
break
if "!guitars" in message:
sendMessage(s, "Ibanez RG920QM Premium")
break
!add "word"
idea may not be realised here. \$\endgroup\$