<commit_before>import json
import logging

logging.basicConfig(format='[%(levelname)s] - %(message)s', level=logging.INFO)
config = json.load(open('config.json'))

class Stats:

    async def dblpost(self):
        headers = {
            'Authorization': self.config['dbl'],
            'Content-Type': 'application/json'
        }
        data = {
            'server_count': len(self.bot.guilds),
            'shard_count': len(self.bot.shards)
        }
        info = await self.bot.application_info()
        req = await self.bot.session.post(f'https://discordbots.org/api/bots/{info.id}/stats', data=json.dumps(data), headers=headers)
        status = req.status
        if status == 200:
            logging.info('poster[dbl]: done')
        else:
            resp = await req.text()
            logging.error(f'poster[dbl]: oops (code {status})')
            logging.error(f'poster[dbl]: response: {resp}')

    async def dpwpost(self):
        headers = {
                'Authorization': self.config['dbots'],
                'Content-Type': 'application/json'
            }
        data = {
                'server_count': len(self.bot.guilds),
                'shard_count': len(self.bot.shards)
            }
        info = await self.bot.application_info()
        req = await self.bot.session.post(f'https://bots.discord.pw/api/bots/{info.id}/stats', data=json.dumps(data), headers=headers)
        status = req.status
        if status == 200:
            logging.info('poster[dbots]: done')
        else:
            resp = await req.text()
            logging.error(f'poster[dbots]: oops (code {status})')
            logging.error(f'poster[dbots]: response: {resp}')

    async def post(self):
        logging.info('poster: starting post')
        await self.dblpost()
        await self.dpwpost()
        logging.info('poster: done')

    def __init__(self, bot):
        self.bot = bot
        self.config = json.load(open('config.json'))

    async def on_guild_join( self, guild ):
        logging.info('Joined guild "' + str(guild.name) + '" ID: ' + str(guild.id))
        await post()

    async def on_guild_remove( self, guild ):
        logging.info('Left ' + str(guild.name))
        awaitpost()

def setup(bot):
    bot.add_cog(Stats(bot))<commit_msg>[cogs(stats)] move shit around, cleanup<commit_after>import json
import logging

logging.basicConfig(format='[%(levelname)s] - %(message)s', level=logging.INFO)

class Stats:

    def __init__(self, bot):
        self.bot = bot
        self.config = json.load(open('config.json'))

    async def dblpost(self):
        headers = {
            'Authorization': self.config['dbl'],
            'Content-Type': 'application/json'
        }
        data = {
            'server_count': len(self.bot.guilds),
            'shard_count': len(self.bot.shards)
        }
        info = await self.bot.application_info()
        req = await self.bot.session.post(f'https://discordbots.org/api/bots/{info.id}/stats', data=json.dumps(data), headers=headers)
        status = req.status
        if status == 200:
            logging.info('poster[dbl]: done')
        else:
            resp = await req.text()
            logging.error(f'poster[dbl]: oops (code {status})')
            logging.error(f'poster[dbl]: response: {resp}')

    async def dpwpost(self):
        headers = {
                'Authorization': self.config['dbots'],
                'Content-Type': 'application/json'
            }
        data = {
                'server_count': len(self.bot.guilds),
                'shard_count': len(self.bot.shards)
            }
        info = await self.bot.application_info()
        req = await self.bot.session.post(f'https://bots.discord.pw/api/bots/{info.id}/stats', data=json.dumps(data), headers=headers)
        status = req.status
        if status == 200:
            logging.info('poster[dbots]: done')
        else:
            resp = await req.text()
            logging.error(f'poster[dbots]: oops (code {status})')
            logging.error(f'poster[dbots]: response: {resp}')

    async def post(self):
        logging.info('poster: starting post')
        await self.dblpost()
        await self.dpwpost()
        logging.info('poster: done')

    async def on_guild_join( self, guild ):
        logging.info('Joined guild "' + str(guild.name) + '" ID: ' + str(guild.id))
        await post()

    async def on_guild_remove( self, guild ):
        logging.info('Left ' + str(guild.name))
        awaitpost()

def setup(bot):
    bot.add_cog(Stats(bot))
{'fraction_non_alphanumeric': 0.149010989010989, 'fraction_numerical': 0.0026373626373626374, 'mean_word_length': 2.1825174825174827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 1, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '173122', 'n_tokens_mistral': 1452, 'n_tokens_neox': 1416, 'n_words': 263}