<commit_before>import asyncio
import discord
import datetime
import random
from   discord.ext import commands
from   operator import itemgetter
from   Cogs import Settings
from   Cogs import DisplayName
from   Cogs import Nullify
from   Cogs import CheckRoles

# This is the xp module.  It's likely to be retarded.

class Xp:

	# Init with the bot reference, and a reference to the settings var
	def __init__(self, bot, settings):
		self.bot = bot
		self.settings = settings
		self.bot.loop.create_task(self.addXP())
		
	async def addXP(self):
		while not self.bot.is_closed:
			await asyncio.sleep(600) # runs only every 10 minutes (600 seconds)
			print("Adding XP: {}".format(datetime.datetime.now().time().isoformat()))
			for server in self.bot.servers:
				# Iterate through the servers and add them
				xpAmount   = int(self.settings.getServerStat(server, "HourlyXP"))
				xpAmount   = float(xpAmount/6)
				xpRAmount  = int(self.settings.getServerStat(server, "HourlyXPReal"))
				xpRAmount  = float(xpRAmount/6)
				
				onlyOnline = self.settings.getServerStat(server, "RequireOnline")
				
				for user in server.members:
					bumpXP = False
					if onlyOnline.lower() == "no":
						bumpXP = True
					else:
						if str(user.status).lower() == "online":
							bumpXP = True
							
					if bumpXP:
						if xpAmount > 0:
							# User is online add hourly xp reserve
							xpLeftover = float(self.settings.getUserStat(user, server, "XPLeftover"))
							gainedXp = xpLeftover+xpAmount
							gainedXpInt = int(gainedXp) # Strips the decimal point off
							xpLeftover = float(gainedXp-gainedXpInt) # Gets the < 1 value
							self.settings.setUserStat(user, server, "XPLeftover", xpLeftover)
							self.settings.incrementStat(user, server, "XPReserve", gainedXpInt)
						
						if xpRAmount > 0:
							# User is online add hourly xp
							xpRLeftover = float(self.settings.getUserStat(user, server, "XPRealLeftover"))
							gainedXpR = xpRLeftover+xpRAmount
							gainedXpRInt = int(gainedXpR) # Strips the decimal point off
							xpRLeftover = float(gainedXpR-gainedXpRInt) # Gets the < 1 value
							self.settings.setUserStat(user, server, "XPLeftover", xpRLeftover)
							self.settings.incrementStat(user, server, "XP", gainedXpRInt)

							# Check for promotion/demotion
							try:
								await CheckRoles.checkroles(user, server.default_channel, self.settings, self.bot)<commit_msg>Hopefully the last bugfix on the new xp system<commit_after>import asyncio
import discord
import datetime
import random
from   discord.ext import commands
from   operator import itemgetter
from   Cogs import Settings
from   Cogs import DisplayName
from   Cogs import Nullify
from   Cogs import CheckRoles

# This is the xp module.  It's likely to be retarded.

class Xp:

	# Init with the bot reference, and a reference to the settings var
	def __init__(self, bot, settings):
		self.bot = bot
		self.settings = settings
		self.bot.loop.create_task(self.addXP())
		
	async def addXP(self):
		while not self.bot.is_closed:
			await asyncio.sleep(600) # runs only every 10 minutes (600 seconds)
			print("Adding XP: {}".format(datetime.datetime.now().time().isoformat()))
			for server in self.bot.servers:
				# Iterate through the servers and add them
				xpAmount   = int(self.settings.getServerStat(server, "HourlyXP"))
				xpAmount   = float(xpAmount/6)
				xpRAmount  = int(self.settings.getServerStat(server, "HourlyXPReal"))
				xpRAmount  = float(xpRAmount/6)
				
				onlyOnline = self.settings.getServerStat(server, "RequireOnline")
				
				for user in server.members:
					bumpXP = False
					if onlyOnline.lower() == "no":
						bumpXP = True
					else:
						if str(user.status).lower() == "online":
							bumpXP = True
							
					if bumpXP:
						if xpAmount > 0:
							# User is online add hourly xp reserve
							xpLeftover = float(self.settings.getUserStat(user, server, "XPLeftover"))
							gainedXp = xpLeftover+xpAmount
							gainedXpInt = int(gainedXp) # Strips the decimal point off
							xpLeftover = float(gainedXp-gainedXpInt) # Gets the < 1 value
							self.settings.setUserStat(user, server, "XPLeftover", xpLeftover)
							self.settings.incrementStat(user, server, "XPReserve", gainedXpInt)
						
						if xpRAmount > 0:
							# User is online add hourly xp
							xpRLeftover = float(self.settings.getUserStat(user, server, "XPRealLeftover"))
							gainedXpR = xpRLeftover+xpRAmount
							gainedXpRInt = int(gainedXpR) # Strips the decimal point off
							xpRLeftover = float(gainedXpR-gainedXpRInt) # Gets the < 1 value
							self.settings.setUserStat(user, server, "XPRealLeftover", xpRLeftover)
							self.settings.incrementStat(user, server, "XP", gainedXpRInt)

							# Check for promotion/demotion
							try:
								await CheckRoles.checkroles(user, server.default_channel, self.settings, self.bot)
{'fraction_non_alphanumeric': 0.09287035134579823, 'fraction_numerical': 0.005753030614341483, 'mean_word_length': 3.296557811120918, 'pattern_counts': {'":': 4, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6733257', 'n_tokens_mistral': 2051, 'n_tokens_neox': 1552, 'n_words': 423}