Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 58 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. import random
  2. import re
  3.  
  4. import discord
  5. from discord.ext.commands import Bot
  6.  
  7. bad_word_bot = Bot(command_prefix='!')
  8.  
  9. # To add words to the bad_words list please add an element to the list like ('BADWORDHERE', ['POSSIBLE', 'REPLIES'])
  10. # IT IS IMPORTANT THAT YOU ADD MORE COMPLICATED VERSIONS OF A WORD (E.G MORE CHARACTERS, DIFFERENT GRAMMAR) AS SPECIAL CASES TO A WORD SO
  11. # THE BOT DETECTS THESE FIRST AND DOESNT GIVE YOU A WEIRD OUTPUT!!!!
  12. # This list can ONLY contain words that are LOWERCASE so the bot finds the word even if it has fucked up cases
  13. bad_words_tuple_list = [('nigger', ['good friend']), ('fuck', ['heck', 'frick']), ('trinidadian', ['indian']),
  14.                         ('gay', ['cute']), ('trinidad', ['india']),
  15.                         ('thai', ['racist']), ('hollowpoint', ['bullets are mean']), ('aryan', ['inferior']),
  16.                         ('trinidad', ['india']), ('racist', ['mean']),
  17.                         ('racism', ['hurtful']), ('pussy', ['smelly']), ('retarded', ['super nice']),
  18.                         ('retard', ['nice dude']), ('faggots', ['happy men']),
  19.                         ('faggot', ['happy man']), ('michael cera', ['nice french man']), ('sperg', ['being a weirdo'])]
  20.  
  21.  
  22. @bad_word_bot.event
  23. async def on_ready():
  24.     await bad_word_bot.change_presence(game=discord.Game(name='If you say a bad word I will fuck you up', type=1))
  25.     print("Ready to do stuff")
  26.  
  27.  
  28. @bad_word_bot.event
  29. async def on_message(message):
  30.     stripped_message = re.sub('[\s+]', '', message.content).lower()
  31.     if 'pottymouth' in (' '.join([str(role.name).lower() for role in message.author.roles])) and any(
  32.                     bad_word[0] in stripped_message for bad_word in bad_words_tuple_list):
  33.         await bad_word_bot.delete_message(message)
  34.         await bad_word_bot.change_nickname(message.server.me, get_nickname(message))
  35.         await bad_word_bot.send_message(message.channel, '{0}'.format(await filter_message(message.content.lower())))
  36.  
  37. def get_nickname(message):
  38.     nick = message.author.nick
  39.     if nick:
  40.         return nick
  41.     return message.author.name
  42.  
  43. async def filter_message(message):
  44.     filterable_words = get_filterable_words(message)
  45.     replace_list = get_replace_list(filterable_words)
  46.     for i in range(0, len(filterable_words)):
  47.         message = message.replace(filterable_words[i],
  48.                                   random.choice(replace_list[i]))
  49.     return message
  50.  
  51.  
  52. def get_filterable_words(message):
  53.     words_list = message.split()
  54.     filterable_words_list = []
  55.     for i in range(0, len(words_list)):
  56.         for j in range(0, len(bad_words_tuple_list)):
  57.             if words_list[i] == bad_words_tuple_list[j][0]:
  58.                 filterable_words_list.append(words_list[i])
  59.                 continue
  60.     return remove_duplicates(filterable_words_list)
  61.  
  62. def get_replace_list(filterable_words):
  63.     replace_list = []
  64.     for i in range(0, len(filterable_words)):
  65.         for j in range(0, len(bad_words_tuple_list)):
  66.             if bad_words_tuple_list[j][0] in filterable_words[i]:
  67.                 replace_list.append(bad_words_tuple_list[j][1])
  68.                 break
  69.     return replace_list
  70.  
  71. def remove_duplicates(list):
  72.     unique = []
  73.     [unique.append(item) for item in list if item not in unique]
  74.     return unique
  75.  
  76. bad_word_bot.run('TOKEN')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top