2

I would like to create a banned list of words in a text file. Then when a command is typed check if the banned word is in the command and then add their username to a list of blocked usernames.

So far I have created a banned users list that works perfectly. However I have come to a lot of problems when making a blocked words list and have it check if the word has been said.

So far I have this:

bannedwords = open('bannedwords.txt')
bannedwords = str(bannedwords)

if "a" in chat:
    with open('bannedwords.txt') as f:
        if bannedwords in chat:
            send("abcde","snappingbot")

Example of a word in twitch irc chat:

@badge-info=;badges=moderator/1,glitchcon2020/1;color=#008000;display-name=Turtoise;emotes=;flags=;id=94575409-70ea-4b53-9481-3146fc0bc4e7;mod=1;room-id=191739645;subscriber=0;tmi-sent-ts=1608229323648;turbo=0;user-id=80805824;user-type=mod :turtoise!turtoise@turtoise.tmi.twitch.tv PRIVMSG #snappingbot :abc

Example of the blocked user command that works:

if ":+turtfact" in chat:
    with open('banlist.txt') as f:
        if username in f.read():
            send("/w " + username + " you are on the banned list of users for this bot.", "turtoise")
        else:
            try:
                test = (choice(list(open('turtfact.txt'))))
                sendcommand("/me " + test, channel)
            except:send("error","turtlelurk")
Turtoise
  • 27
  • 4

0 Answers0