class BotMaintainance:
    utils: BotUtils
    database: BotDatabase
    profanity_filter: ProfanityFilter

    def __init__(self, database: BotDatabase, utils: BotUtils):
        self.utils = utils
        self.database = database
        self.profanity_filter = ProfanityFilter()
        self.profanity_filter.set_censor("^")

    async def handle_censor_channel(self,
                                    message_context: discord.Message) -> None:
        if await self.database.censored_channels.is_censored(
                message_context.channel.id):
            censored_message = self.profanity_filter.censor(
                message_context.content)
            if censored_message != message_context.content:
                await self.utils.messages.replace_message(
                    message_context, censored_message)
                await self.utils.messages.delete_message(message_context)

    async def handle_maintainance(self,
                                  message_context: discord.Message) -> None:
        await self.handle_censor_channel(message_context)
# In[4]:


pf = ProfanityFilter()


# In[5]:


pf.censor("That's bullshit!")


# In[6]:


pf.set_censor("@")


# In[7]:


pf.censor("That's bullshit!")


# In[8]:


pf.define_words(["icecream", "choco"])


# In[9]:
Beispiel #3
0
_D='ascii'
_C=None
_B=True
_A=False
import discord,base64
from operator import itemgetter
import requests,random,asyncio,psutil,urllib,datetime,random,sys,traceback,urllib.parse,urllib.request
from json import loads
from discord.ext.commands import has_permissions,MissingPermissions
from discord.ext import commands
from discord.utils import find
import time,redis,os,json,subprocess
from profanityfilter import ProfanityFilter
import homoglyphs as hg
pf=ProfanityFilter()
pf.set_censor('#')
homoglyphs=hg.Homoglyphs(languages={'en'},strategy=hg.STRATEGY_LOAD)
userspecific=_B
yesemoji='👍'
noemoji='👎'
numberemojis=['1️⃣','2️⃣','3️⃣','4️⃣']
categories={_W:'9',_c:_z,_d:'11',_e:'12',_f:'13',_g:'14',_h:'15',_i:'16',_j:'17',_k:'18',_l:'19',_m:'20',_n:'21',_o:'22',_p:'23',_q:'24',_r:'25',_s:'26',_t:'27',_u:'28',_v:'29',_w:'30',_x:'31',_y:'32'}
TOKEN=os.getenv('bottoken')
if TOKEN==_C:TOKEN=input('Token Please:')
redisurl=os.getenv('REDIS_URL')
if redisurl==_C:redisurl=input('Please enter the REDIS URL:')
dbl_token=os.getenv('DBL_TOKEN')
HEROKU_RELEASE_CREATED_AT=os.getenv('HEROKU_RELEASE_CREATED_AT')
HEROKU_RELEASE_VERSION=os.getenv('HEROKU_RELEASE_VERSION')
HEROKU_SLUG_COMMIT=os.getenv('HEROKU_SLUG_COMMIT')
HEROKU_SLUG_DESCRIPTION=os.getenv('HEROKU_SLUG_DESCRIPTION')
Beispiel #4
0
Admin_file = os.getenv('ADMINS_LIST')

client = discord.Client()

pf1 = ProfanityFilter()  #for user defined slangs (just a workaround)
pf2 = ProfanityFilter()  #for pre defined slangs

Profane_file = './slangs.csv'
slang_list = []
with open(Profane_file, 'r') as pf:
    slangs = csv.reader(pf)
    for slang in slangs:
        slang_list.append(slang[0])  # slang is [word], so slang[0] is word
    print('profane list loaded [OK]')

pf1.set_censor('*')
pf1.define_words(slang_list)
print("define slangs [OK]")

#getting admins
admin_list = []
with open(Admin_file, 'r') as adms:
    _list = csv.reader(adms)
    for name in _list:
        admin_list.append(name[0])
    print('admin list loaded [OK]')


@client.event
async def on_ready():
    guild = discord.utils.find(lambda g: g.name == GUILD, client.guilds)
Beispiel #5
0
def censor(text):
    '''censor all offensive words with *'''
    pf = ProfanityFilter()
    pf.set_censor("*")
    censored = pf.censor(text)
    return censored