Exemplo n.º 1
0
def convert_information(user_list):
    information_list = deque([])
    pass_list = dict()
    for k in user_list.keys():
        word_list = make_word_file()

        secure_random = SystemRandom()
        first_word = secure_random.choice(word_list).strip()
        second_word = secure_random.choice(word_list).strip()

        # check if the password is either too long or contains profanity
        pf = ProfanityFilter()
        while len(first_word + second_word) > 10 or len(first_word + second_word) < 6 or \
                "'" in first_word or "'" in second_word or pf.is_profane(first_word) or pf.is_profane(second_word):
            first_word = secure_random.choice(word_list).strip()
            second_word = secure_random.choice(word_list).strip()

        pwd = (first_word + second_word + str(randint(0, 9)) +
               str(randint(0, 9)))
        pass_list[k] = pwd

        first_name = user_list[k][0].title()
        last_name = user_list[k][1].title()
        full_name = first_name + ' ' + last_name
        email = k + "@xyz.org"
        information = pwd + ',' + k + ',' + full_name + ',' + last_name + ',' + first_name + ',' + email

        information_list.append(information)

    return information_list, pass_list
Exemplo n.º 2
0
 def feedback_check(self, description=None):
     pf = ProfanityFilter()
     if description:
         result = str(pf.is_profane(description)).lower()
     else:
         result = 'None'
     return result
Exemplo n.º 3
0
def getRoomCode(stringLength=4):
    pf = ProfanityFilter()
    letters = string.ascii_uppercase
    roomCode = ''.join(random.choice(letters) for i in range(stringLength))
    # need to check also whether the room code is already being used
    while pf.is_profane(roomCode) or db.seders.count_documents(
        {'roomCode': roomCode}) > 0:
        roomCode = ''.join(random.choice(letters) for i in range(stringLength))
    return roomCode
Exemplo n.º 4
0
class Swearjar(object):
	defaultSwearIncrement = 1

	def __init__(self):
		self.swearlist = swears
		self.defaultMultiplier = 0.25
		self.storage = BatchPostgres()
		self.userSwearCountCache = {}
		self.filter = ProfanityFilter()

	def hasSwear(self, text):
		return self.filter.is_profane(text)
		# for token in doc:
		# 	print(f'{token}:'
		# 		f'censored={token._.censored}, '
		# 		f'is_profane={token._.is_profane}, '
		# 		f'original_profane_word={token._.original_profane_word}'
		# 	)

		#return set(x.lower() for x in text.split()) & self.swearlist

	def getSwearList(self):
		return self.swears

	def addToSwearJar(self, user, swearIncrement = defaultSwearIncrement):
		swearCount = self.storage.incrementSwearCount(user, swearIncrement)
		self.userSwearCountCache[user] = swearCount
		return swearCount

	def checkSwearJar(self, user):
		if user in self.userSwearCountCache:
			return self.userSwearCountCache[user]
		return self.storage.getSwearCount(user)

	def getMoneyOwed(self, user):
		return self.swearsToDollarAmount(self.checkSwearJar(user))
		 
	def addNewUser(self, userinfo):
		return self.storage.addNewUser(userinfo)

	def getUserData(self, user):
		return self.storage.getUserData(user)

	def getAllBalances(self):
		swearCounts = self.storage.getAllUserSwearCounts()
		balances = "Balances: \n"
		for userSwearCount in swearCounts:
			balances += "%s: $%.2f\n" % (userSwearCount[1], self.swearsToDollarAmount(userSwearCount[2]))
			self.userSwearCountCache[userSwearCount[0]] = userSwearCount[2] 
		return balances

	def swearsToDollarAmount(self, swears):
		 money = swears * self.defaultMultiplier
		 return math.ceil(money * 100) / 100
Exemplo n.º 5
0
def profanity_check(cleaned_comment):
    custom_profanity_list = config.get('ckan.comments.profanity_list', [])

    if custom_profanity_list:
        pf = ProfanityFilter(
            custom_censor_list=custom_profanity_list.splitlines())
    else:
        # Fall back to original behaviour of built-in Profanity bad words list
        # combined with bad_words_file and good_words_file
        more_words = load_bad_words()
        whitelist_words = load_good_words()

        pf = ProfanityFilter(extra_censor_list=more_words)
        for word in whitelist_words:
            pf.remove_word(word)

    return pf.is_profane(cleaned_comment)
Exemplo n.º 6
0
def submit():

    pf = ProfanityFilter(no_word_boundaries=True)
    serial = request.form['serial']
    name = request.form['name']
    location = request.form['location']
    amount = request.form['amount']

    #Since this is an open text field accessible on a public website,
    #some form of profanity check is needed
    if pf.is_profane(name):
        return redirect("/warehouse")

    else:
        db = Database()
        db.addItem(serial, name, location, amount)
        return redirect("/warehouse")
def isTrash(text):
    # has profane vocab
    pf=ProfanityFilter()
    if pf.is_profane(text):
        return True
    # trash filtering
    urls=re.findall(URL_REGEX, text)
    if len(urls)> 1:
        return True
    # > 3 hashtags
    hashtags=re.findall(r"#\S+",text)
    if len(hashtags)> 3:
        return True
    # > 2 usernames
    users=re.findall(r"@\S+",text)
    if len(users)> 2:
        return True
    return False
Exemplo n.º 8
0
def create_student(information_list, grade_level_list):
    while True:
        logging.info("Enter the student's First name: ")
        first_name = input().strip()
        while check_name(first_name) is False:
            logging.info(
                "A name must be alphabetical, or contain hyphens, spaces, or apostrophes."
            )
            logging.info("Enter the student's First name: ")
            first_name = input().strip()

        logging.info("Enter the student's Last name: ")
        last_name = input().strip()
        while check_name(last_name) is False:
            logging.info(
                "A name must be alphabetical, or contain hyphens, spaces, or apostrophes."
            )
            logging.info("Enter the student's Last name: ")
            last_name = input()

        while True:
            try:
                logging.info("Enter the student's Grade level (-2 - 12): ")
                grade_level = int(input())
            except ValueError:
                logging.info("The grade level must be a number (-2 - 12).")
                continue
            break

        while grade_level not in range(-2, 13):
            logging.info("The grade level must be between -2 and 12.")
            logging.info("Enter the student's Grade level (-2 - 12): ")

            try:
                grade_level = int(input())
            except ValueError:
                logging.info("The grade level must be a number (-2 - 12).")
                continue

        graduation_year = (datetime.date.today().year + (12 - grade_level))
        first_name_split = split_name(first_name)
        last_name_split = split_name(last_name)
        grade_level_list.append(grade_level)

        username_list = usernames_from_sftp()[0]

        if len(last_name_split) >= 5:
            candidate = (str(graduation_year)[2:] + last_name_split[:5] +
                         first_name_split[0]).lower()
            while check_name_in_ldap(candidate) is False:
                candidate = \
                    resolve_username(candidate, username_list, first_name_split, last_name_split[:5], graduation_year,
                                     'student')
        else:
            candidate = (str(graduation_year)[2:] + last_name_split +
                         first_name_split[0]).lower()
            while check_name_in_ldap(candidate) is False:
                candidate = \
                    resolve_username(candidate, username_list, first_name_split, last_name_split, graduation_year,
                                     'student')

        logging.info('\nCandidate username is: ' + candidate)

        word_list = make_word_file()

        secure_random = SystemRandom()
        first_word = secure_random.choice(word_list).strip()
        second_word = secure_random.choice(word_list).strip()

        # check if the password is either too long or contains profanity
        pf = ProfanityFilter()
        while len(first_word + second_word) > 10 or len(first_word + second_word) < 6 or \
                "'" in first_word or "'" in second_word or pf.is_profane(first_word) or pf.is_profane(second_word):
            first_word = secure_random.choice(word_list).strip()
            second_word = secure_random.choice(word_list).strip()

        pwd = (first_word + second_word + str(randint(0, 9)) +
               str(randint(0, 9)))

        full_name = first_name.title() + ' ' + last_name.title()
        email = candidate + "@xyz.org"
        logging.info("\nInformation:")
        information =\
            pwd + ',' + candidate + ',' + full_name + ',' + last_name.title() + ',' + first_name.title() + ',' + email
        logging.info(information)

        logging.info("\nDo you want to keep creating student accounts?(y/n): ")
        user_prompt = input().lower()
        while not ((user_prompt == 'y') or (user_prompt == 'yes') or
                   (user_prompt == 'n') or (user_prompt == 'no')):
            logging.info("You must enter y, yes, n, or no.")
            logging.info(
                "Do you want to keep creating student accounts?(y/n): ")
            user_prompt = input().lower()
        if (user_prompt == 'y') or (user_prompt == 'yes'):
            information_list.append(information)
            continue
        elif (user_prompt == 'n') or (user_prompt == 'no'):
            information_list.append(information)
            return information_list, grade_level_list
Exemplo n.º 9
0
    async def on_message(self, message):
        if message.author.bot:
            return

        DB_NAME = "db name"
        db_path = os.path.abspath("db path" + DB_NAME + ".db")
        self.db = sqlite3.connect(db_path)
        self.db_cursor = self.db.cursor()
        print(f"Connected")

        if message.author.bot:
            return

        if discord.utils.get(message.author.roles, name="Muted") != None:
            return
        if discord.utils.get(message.author.roles, name="Hardmute") != None:
            return

        author_id = str(message.author.id)
        guild_id = str(message.guild.id)

        negativeph = [
            'reddit', 'owo', 'bisexual', 'bi sexual', 'bi-sexual', 'ahigay',
            'c**k', 'femb', 'indica', 'christianity', 'tsuki', 'nibba',
            'phobic', 'black p', 'systemsp', 'trans', 'homosexual', 'pog',
            'tolerance', 'non binary', 'nonbinary', 'non-binary',
            'genderfluid', 'gender fluid', 'gender-fluid', 'femmy', 'cum',
            'boyp', 'b0ip', 'boy p', 'b0i p', 'boi p', 'boip', 'b0y p',
            'b0y p', 'uwu', 'phobe'
        ]
        convoph = [
            'sup', 'hot', 'initiate', 'great', 'shit', 'shiet', 'raype',
            'based', 'redpill', 'https', 'cute', 'loli', 'tomboy'
        ]
        channelid = message.channel.name

        pf = ProfanityFilter()

        if discord.utils.get(message.author.roles, name="Muted") != None:
            return
        if discord.utils.get(message.author.roles, name="Hardmute") != None:
            return

        self.db_cursor.execute(
            f"SELECT * FROM fucku WHERE UserID='{author_id}' AND GuildID='{guild_id}'"
        )
        user = self.db_cursor.fetchone()
        if user:
            print("User found")
            sql = ("UPDATE fucku SET XP=? WHERE UserID=? AND GuildID=?")
            val = (int(user[1] + 1), int(message.author.id),
                   int(message.guild.id))
            self.db_cursor.execute(sql, val)
            self.db.commit()

            if pf.is_profane(f"{message.content}") == True:
                sql = (
                    "UPDATE fucku SET Credit=? WHERE UserID=? AND GuildID=?")
                val = (int(user[4] + 50), int(message.author.id),
                       int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()

            if re.compile('|'.join(convoph),
                          re.IGNORECASE).search(message.content):
                sql = (
                    "UPDATE fucku SET Credit=? WHERE UserID=? AND GuildID=?")
                val = (int(user[4] + 10), int(message.author.id),
                       int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()
            if re.compile('|'.join(negativeph),
                          re.IGNORECASE).search(message.content):
                sql = (
                    "UPDATE fucku SET Credit=? WHERE UserID=? AND GuildID=?")
                val = (int(user[4] - 50), int(message.author.id),
                       int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()

            if self.act_up_fuck(user):
                print(f"leveled up!")
                current_xp = int(user[1])
                current_lvl = int(user[2])
                if current_xp >= round((4 * (current_lvl**3)) / 5):
                    sql = (
                        "UPDATE fucku SET Level=? WHERE UserID=? AND GuildID=?"
                    )
                    val = (int(user[2] + 1), int(message.author.id),
                           int(message.guild.id))

                    self.db_cursor.execute(sql, val)
                    self.db.commit()

            if "nigger" in message.content or "niggers" in message.content or "NIGGER" in message.content or "NIGGERS" in message.content:
                s = str(message.content)
                sb = 'nigger'
                results = 0
                sub_len = len(sb)
                for i in range(len(s)):
                    if s[i:i + sub_len] == sb:
                        results += 1

                fuckk = int(results)

                sql = ("UPDATE fucku SET Nword=? WHERE UserID=? AND GuildID=?")
                val = (int(user[3] + fuckk), int(message.author.id),
                       int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()

            currentcredit = int(user[4])

            if currentcredit <= 40:
                sql = (
                    "UPDATE fucku SET Credit=100 WHERE UserID=? AND GuildID=?")
                val = (int(message.author.id), int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()

            if currentcredit >= 1000:
                sql = (
                    "UPDATE fucku SET Credit=1000 WHERE UserID=? AND GuildID=?"
                )
                val = (int(message.author.id), int(message.guild.id))
                self.db_cursor.execute(sql, val)
                self.db.commit()

            try:
                self.db_cursor.close()
                self.db.close()
            except Exception as e:
                return
        else:
            print(f"User not found proceeding...")
            sql = (
                "INSERT INTO fucku (UserID, XP, Level, Nword, Credit, GuildID) VALUES (?, ?, ?, ?, ?, ?)"
            )
            val = (int(message.author.id), 1, 1, 0, 100, int(message.guild.id))
            self.db_cursor.execute(sql, val)
            print(f"inserted {val}")
            self.db.commit()
            print(f"committed")

        try:
            self.db_cursor.close()
            self.db.close()
        except Exception as e:
            return
Exemplo n.º 10
0
#public_tweets = api.search('Tesla')
#
#
#for tweet in public_tweets:
#    print(tweet.text)
#
##Perform Sentiment Analysis on Tweets
#    analysis = TextBlob(tweet.text)
#    print(analysis.sentiment)
#print("")
#Profanity_removed = pf.censor(speech)#censors the tweet  without any hyperlink
#print(Profanity_removed)#print just for confermation
'''
@Profanity_removed stores tweet which is free for curse words

'''
'''
To add some indian curse words remove below comment

'''
#pf.define_words(["mc","bc","MC","BC"])
msg = input('Enter the Tweet : ')

Approval = pf.is_profane(msg)

if Approval == True:
    print("Explicit Contect detected")
else:
    print("nice and clean !")
    print("updating status...")
    api.update_status(msg)
Exemplo n.º 11
0
max_e = 50000

"""Builds a backup model (i.e. one that does not keep updating)"""
es = Elasticsearch(['https://9ed43f138f41c3cfbd42ceef576fbeb8.eu-central-1.aws.cloud.es.io:9243'],
                   http_auth=('elastic', '0VkwdsbNK00frpoRFFFlYD97'))

with open("/home/tiina/dev/internet_list.txt", 'r') as f:

    own_list_o=f.readlines()


own_list=[]
for l in own_list_o:
    own_list.append(l.replace('\n', ''))
pf = ProfanityFilter(custom_censor_list=own_list)
print(pf.is_profane('VK'))

how_many = max_e
doc = {
    'size': how_many,

    "query":
        {
            "bool": {
                "must": [{
          "match": {
              "data.origin.country": "JP"
          }
      }, {
          "match": {
             "data.isAd": "false"
Exemplo n.º 12
0
    async def on_message(self, message):
        if "lain" in message.author.display_name:
            await message.author.edit(nick="f****t")
        if "🐊" in message.author.display_name:
            await message.author.edit(nick="Gatorfree zone")
        if message.author.bot or message.content.startswith("."):
            return
        message.content = message.content.lower().replace('', '')
        user = message.author
        username = message.author.display_name
        pfp = message.author.avatar_url_as(size=1024)
        channelid = message.channel.name
        webhookurl = 'https://discord.com/api/webhooks/whatever'

        if "discordapp.com/attachments" in message.content:
            return

        #if "tenor." in message.content:
        #    await message.delete();

        if "discord.com/channels" in message.content:
            return

        if "discord.gg" in message.content or "discord." in message.content or ".gg/" in message.content:
            await message.delete()
            quotee = re.compile(
                r'(?!\bbased\b|\bsexpilled\b|\bis\b|\bare\b|\bhow\b|\byou\b|\bhello\b|\band\b|\bad\b|\byou\b|\blain\b|\bmy\b|\bdick\b|\bpenis\b|\bpussy\b|\bfag\b|\bam\b|\bnigger\b|\bi|\bI\b|\bu\b)\b[^\s]+\b'
            )
            subit = "https://cdn.discordapp.com/attachments/673308690157404211/743601553356751002/unknown.png"
            result = re.sub(quotee, subit, message.content)
            print(message.content)
            print(result)

            async with aiohttp.ClientSession() as session:
                webhook = Webhook.from_url(
                    webhookurl, adapter=AsyncWebhookAdapter(session))
                await webhook.send(f'{result}',
                                   username=str(username),
                                   avatar_url=str(pfp))

        if discord.utils.get(message.author.roles, name="Muted") != None:
            if message.author.id == 759621355708350484:
                return
            else:
                return await message.delete()
        if discord.utils.get(message.author.roles, name="Hardmute") != None:
            if message.author.id == 759621355708350484:
                return
            else:
                return await message.delete()

        if message.content == 'f':
            await message.channel.send(
                f"**{message.author.name}** has paid their respect {random.choice(['❤', '💛', '💚', '💙', '💜'])}"
            )

        elif message.content.startswith('f '):
            reason = message.content.partition("f ")[2]
            await message.channel.send(
                f"**{message.author.name}** has paid their respect for **{reason}** {random.choice(['❤', '💛', '💚', '💙', '💜'])}"
            )

        elif message.content.startswith('say'):
            if message.content.endswith('name'):
                embed = discord.Embed(color=0xe1a6e1)
                embed.set_image(
                    url=
                    "https://cdn.discordapp.com/attachments/660982562331820032/834182511781347328/unknown-61.png"
                )
                await message.channel.send(embed=embed)

        #--------------------------------------------------------------------
        if channelid != "degeneral":
            return
        if message.author.bot:
            return
        if ":trump" in message.content or "kenya" in message.content or "maya" in message.content or "sanya" in message.content or "tanya" in message.content or "chechnya" in message.content or "thnyan" in message.content or ":nyan:" in message.content or "nyaggot" in message.content or "https://" in message.content or "indication" in message.content or "excludedfag" in message.content or "blacksmith" in message.content:
            return
        a = message.content
        b = lists.censorship
        if "chinese" in a:
            pf = ProfanityFilter()
            if pf.is_profane(f"{a}") == True:
                word1 = "chinese"
                word2 = "GLORIOUS CHINESE"
                a = a.replace(f"{word1}", f"{word2}")
        if "china" in a:
            pf = ProfanityFilter()
            if pf.is_profane(f"{a}") == True:
                word1 = "china"
                word2 = "CHINA IS GLORIOUS RIDE DA TIGA I LOVE CHINA"
                a = a.replace(f"{word1}", f"{word2}")
        if "black woman" in a:
            answer = random.choice(lists.niggerresponse)
            word1 = "black woman"
            word2 = str(answer)
            a = a.replace(f"{word1}", f"{word2}")
        if "black people" in a:
            answer = random.choice(lists.niggerresponse)
            word1 = "black people"
            word2 = str(answer)
            a = a.replace(f"{word1}", f"{word2}")
        if "black person" in a:
            answer = random.choice(lists.niggerresponse)
            word1 = "black person"
            word2 = str(answer)
            a = a.replace(f"{word1}", f"{word2}")
        if "african" in a:
            answer = random.choice(lists.niggerresponse)
            word1 = "african"
            word2 = str(answer)
            a = a.replace(f"{word1}", f"{word2}")
        if "blacks" in a:
            if "blacksmith" in a:
                return
            answer = random.choice(lists.niggerresponse)
            word1 = "blacks"
            word2 = str(answer) + "s"
            a = a.replace(f"{word1}", f"{word2}")
        for x, y in b.items():
            a = a.replace(x, y)
        if message.content == a: return
        async with aiohttp.ClientSession() as session:
            webhook = Webhook.from_url(webhookurl,
                                       adapter=AsyncWebhookAdapter(session))
            await message.delete()
            await webhook.send(f'{a}',
                               username=str(username),
                               avatar_url=str(pfp))

        try:
            if "https:" in message.content or "brother" in message.content:
                return
            else:
                for wordw in data:
                    #print(wordw)
                    if wordw.lower() in message.content.lower():
                        print(wordw.lower())
                        async with aiohttp.ClientSession() as session:
                            fuckkw = message.content.lower()
                            fuwfuwfu = fuckkw.replace(
                                f"{wordw.lower()}", f"((({wordw.lower()})))")
                            webhook = Webhook.from_url(
                                webhookurl,
                                adapter=AsyncWebhookAdapter(session))
                            await message.delete()
                            await webhook.send(f'{fuwfuwfu}',
                                               username=str(username),
                                               avatar_url=str(pfp))

        except Exception as e:
            print(f"{e}")

        if "@everyone" in message.content or "@here" in message.content:
            if discord.utils.get(user.roles, name="Heimdallar") != None:
                return
            elif message.author.id == 857346075585151006:
                return
            else:
                await message.delete()

        elif "pornhub.com/" in message.content:
            await message.channel.send(f'Meet someone in real lyfe, virgin xd')

        if "bot" in message.content or "laika" in message.content:
            if "both" in message.content:
                return
            pf = ProfanityFilter()
            if "kill" in message.content or "hate" in message.content:
                answer = random.choice(lists.anger)
                await message.channel.send(f'{answer}')
            if pf.is_profane(f"{message.content}") == True:
                answer = random.choice(lists.anger)
                await message.channel.send(f'{answer}')
            elif pf.is_clean(f"{message.content}") == True:
                return
        if "kill myself" in message.content:
            answer = random.choice(lists.suicide)
            await message.channel.send(f'{answer}')
        if "fix your bot" in message.content:
            answer = random.choice(lists.anger)
            await message.channel.send(f'{answer}')