<commit_before>from imports import *

# Other imports
from requests import HTTPError
from wordcloud import WordCloud

class Utils:
	
	def __init__(self, conf, reddit, config_name, replied_name, current, replied_current):
		
		self.out = 'cloud.png'
		self.config = conf
		self.reddit = reddit
		self.banned = set(conf['banned'])

		self.start = 0
		
		self.config_file = config_name
		self.replied_file = replied_name

		self.current = current
		self.replied_current = replied_current
		
		resp = []
		
		if os.path.exists(self.replied_file):
		
			temp = config.load(self.replied_file)
			resp = temp['replied']
			
		self.replied = set(resp)
		
	def handle_rate_limit(self, submission, reply):
		
		while True:
			
			try:
				
				submission.add_comment(reply)
				break
				
			except praw.errors.RateLimitExceeded as error:
				
				print('> Rate limit exceeded! Sleeping for %s seconds...' % error.sleep_time)
				time.sleep(error.sleep_time)
				
	def get_submission_comments(self, id):
		
		submission = self.reddit.get_submission(submission_id = id, comment_limit = None)
		comments = praw.helpers.flatten_tree(submission.comments)
		text = ''
		
		for comment in comments:
			
			if isinstance(comment, praw.objects.Comment):
				
				body = re.sub(r'https?://(?:www\.)?[A-z0-9-]+\.[A-z\.]+[\?A-z0-9&=/]*', '', comment.body, flags = re.IGNORECASE)
				body = re.sub(r'<.*?>|&.*?;|/.+?(?= )|/.*', '', body)
				text += body + '\n'
				
		return text
		
	def make_cloud(self, text):
		
		self.start = random.randint(0, 255)
		cloud = WordCloud(font_path = 'bot/fonts/' + random.choice(os.listdir('bot/fonts/')), background_color = 'rgb(10, 10, 10)', width = 1280, height = 720, scale = 1, color_func = self.light_colour_func)
		cloud.generate(text)
		cloud.to_file(self.out)<commit_msg>Fuck it, let's make it full on black.<commit_after>from imports import *

# Other imports
from requests import HTTPError
from wordcloud import WordCloud

class Utils:
	
	def __init__(self, conf, reddit, config_name, replied_name, current, replied_current):
		
		self.out = 'cloud.png'
		self.config = conf
		self.reddit = reddit
		self.banned = set(conf['banned'])

		self.start = 0
		
		self.config_file = config_name
		self.replied_file = replied_name

		self.current = current
		self.replied_current = replied_current
		
		resp = []
		
		if os.path.exists(self.replied_file):
		
			temp = config.load(self.replied_file)
			resp = temp['replied']
			
		self.replied = set(resp)
		
	def handle_rate_limit(self, submission, reply):
		
		while True:
			
			try:
				
				submission.add_comment(reply)
				break
				
			except praw.errors.RateLimitExceeded as error:
				
				print('> Rate limit exceeded! Sleeping for %s seconds...' % error.sleep_time)
				time.sleep(error.sleep_time)
				
	def get_submission_comments(self, id):
		
		submission = self.reddit.get_submission(submission_id = id, comment_limit = None)
		comments = praw.helpers.flatten_tree(submission.comments)
		text = ''
		
		for comment in comments:
			
			if isinstance(comment, praw.objects.Comment):
				
				body = re.sub(r'https?://(?:www\.)?[A-z0-9-]+\.[A-z\.]+[\?A-z0-9&=/]*', '', comment.body, flags = re.IGNORECASE)
				body = re.sub(r'<.*?>|&.*?;|/.+?(?= )|/.*', '', body)
				text += body + '\n'
				
		return text
		
	def make_cloud(self, text):
		
		self.start = random.randint(0, 255)
		cloud = WordCloud(font_path = 'bot/fonts/' + random.choice(os.listdir('bot/fonts/')), background_color = 'black', width = 1280, height = 720, scale = 1, color_func = self.light_colour_func)
		cloud.generate(text)
		cloud.to_file(self.out)
{'fraction_non_alphanumeric': 0.14630760688506386, 'fraction_numerical': 0.01110494169905608, 'mean_word_length': 3.3567110036275696, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4279637', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1254, 'n_words': 260}