<commit_before>import discord
from discord.ext import commands
from cogs.utils.dataIO import dataIO, fileIO
from collections import namedtuple, defaultdict
from datetime import datetime
from random import randint
from copy import deepcopy
from .utils import checks
from __main__ import send_cmd_help
import os
import time
import logging
from .economy import Bank, BankError, AccountAlreadyExists, NoAccount, InsufficientBalance, SameSenderAndReceiver

class Counter:
    """My custom cog that does stuff"""
    def __init__(self, bot):
        self.bot = bot
        self.bank = Bank(bot, "data/economy/bank.json")
        

    @commands.command(pass_context=True, no_pm=True)
    async def boop(self, ctx, user : discord.Member=None):
        """Boop!"""
        if user != None:
            author = ctx.message.author
            if user != author:
                await self.bot.say("Boop! /) " + user.mention)
            else:
                await self.bot.say("Boop! /) " + user.mention + "    \n\n*ponk*")
        else:
            await self.bot.say("That does not appear to be something I can boop.")

    @commands.command(pass_context=True, no_pm=True)
    async def unflip(self, ctx, user : discord.Member=None):
        """Now with the ability to unflip!"""
        if user != None:
            author = ctx.message.author
            if user != author:
                await self.bot.say(user.mention + " ノ( ゜-゜ノ)")
            else:
                await self.bot.say(user.mention + " ノ( ゜-゜ノ)    \n\n`It's okay - you look better this way`")
        else:
            await self.bot.say("Really? You want me to unflip *that*?")

    @commands.command()
    async def pong(self, user : discord.Member=None):
        """You've seen ping, now get ready for pong!"""
        await self.bot.say("`Ping!`")

    @commands.command(pass_context=True, no_pm=True)
    async def ship(self, ctx, user_1 : discord.Member=None, user_2 : discord.Member=None):
        "Ship yourself, someone else, or two random people"

        msg = " :heart: "
        extra = ""
        member_list = list()
        author = ctx.message.author
        server = ctx.message.server
        
        if user_1 == None:
            for member in server.members:
                if member.id != author.id:
                    member_list.append(member)
            user_1 = member_list[randint(0, len(member_list)-1)]
        
        if user_2 == None:
            for member in server.members:
                if member.id != author.id:
                    member_list.append(member)
            user_2 = member_list[randint(0, len(member_list)-1)]
            
        if user_1 == self.bot.user and user_2 == self.bot.user:
            extra = "\nOh, how funny. I've never seen that response before, imbecile." 
        elif user_1 == self.bot.user or user_2 == self.bot.user:
            extra = "\nYou're not even worth the cheapest drink I bought today in this pub."
        elif user_1 == self.bot.user and user_1 == author:
            extra = "\nI'm flattered, really, but all I would do is merge your DNA into my programming, thus permanently erasing you from this world. Besides, you aren't my type."
        else:
            if user_1 == author and user_2 == author:
                extra = "\n\n`I wonder how desperate you can get.`"
            elif user_1 == author or user_2 == author:
                extra = "\n\n`You know, there's pathetic, and then there's you.`"
        await self.bot.say(user_1.mention + msg + user_2.mention + extra)

    @commands.command(pass_context=True, no_pm=True)
    async def playing(self, ctx, game=None):
        "Finds users playing a particular game"
        
        member_list = list()
        number = 0
        server = ctx.message.server

        for member in server.members:
            if member.game != None:
                if str(member.game).lower() == str(game).lower():
                    member_list.append(member.name)
                    number += 1
        
        if number > 0:        
            await self.bot.say("```{} users playing {}\n{}```".format(number, game, "\n".join(member_list)))
        else:
            await self.bot.say("```I either can't find {}, or you are a master of Engrish.```".format(game))

    @commands.command(pass_context=True, no_pm=True)
    @checks.admin_or_permissions(administrator=True)
    async def updateboard(self, ctx):
        """Updates usernames"""
        bank_list = self.bank.get_server_accounts(ctx.message.server)
        
        for account in bank_list:
            if account.member != None:
                user = discord.utils.get(ctx.message.server.members, id=account.member.id)
                if user != None:
                    self.bank.accounts[ctx.message.server.id][account.member.id]["name"] = user.name
                    self.bank._save_bank()
            
        await self.bot.say("Updated all registered bank names!\n```It's recommended you reload modules tha rely on accounts```")

    @commands.group(pass_context=True)
    async def top(self, ctx):
        """Lodge moderator reports on users"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            return

    @top.command(pass_context=True, no_pm=True, name="update")
    @checks.admin_or_permissions(administrator=True)
    async def top_update(self, ctx):
        "Get the highest posters"
        ranks = {}
        ranks[ctx.message.server.id] = {}
        for channel in ctx.message.server.channels:
            number = 0
            async for message in self.bot.logs_from(channel, limit=100):
                number = number + 1
                if self.bot.user not in message.mentions and message.author.bot != True:
                    if len(message.content.split(" ")) >= 4 and len(message.content) >= 8 and not message.content.startswith("!"):
                        try:
                            ranks[ctx.message.server.id][message.author.id]["posts"] += 1
                        except KeyError:
                            ranks[ctx.message.server.id][message.author.id] = {}
                            ranks[ctx.message.server.id][message.author.id]["posts"] = 1
                            ranks[ctx.message.server.id][message.author.id]["username"] = message.author.name
                last = message
                
            while number == 100:
                number = 0
                async for message in self.bot.logs_from(channel, limit=100, before=last):
                    number = number + 1
                    if self.bot.user not in message.mentions and message.author.bot != True:
                        if len(message.content.split(" ")) >= 4 and len(message.content) >= 8 and not message.content.startswith("!"):<commit_msg>Update counter.py<commit_after>import discord
from discord.ext import commands
from cogs.utils.dataIO import dataIO, fileIO
from collections import namedtuple, defaultdict
from datetime import datetime
from random import randint
from copy import deepcopy
from .utils import checks
from __main__ import send_cmd_help
import os
import time
import logging
from .economy import Bank, BankError, AccountAlreadyExists, NoAccount, InsufficientBalance, SameSenderAndReceiver

class Counter:
    """My custom cog that does stuff"""
    def __init__(self, bot):
        self.bot = bot
        self.bank = Bank(bot, "data/economy/bank.json")
        

    @commands.command(pass_context=True, no_pm=True)
    async def boop(self, ctx, user : discord.Member=None):
        """Boop!"""
        if user != None:
            author = ctx.message.author
            if user != author:
                await self.bot.say("Boop! /) " + user.mention)
            else:
                await self.bot.say("Boop! /) " + user.mention + "    \n\n*ponk*")
        else:
            await self.bot.say("That does not appear to be something I can boop.")

    @commands.command(pass_context=True, no_pm=True)
    async def unflip(self, ctx, user : discord.Member=None):
        """Now with the ability to unflip!"""
        if user != None:
            author = ctx.message.author
            if user != author:
                await self.bot.say(user.mention + " ノ( ゜-゜ノ)")
            else:
                await self.bot.say(user.mention + " ノ( ゜-゜ノ)    \n\n`It's okay - you look better this way`")
        else:
            await self.bot.say("Really? You want me to unflip *that*?")

    @commands.command()
    async def pong(self, user : discord.Member=None):
        """You've seen ping, now get ready for pong!"""
        await self.bot.say("`Ping!`")

    @commands.command(pass_context=True, no_pm=True)
    async def ship(self, ctx, user_1 : discord.Member=None, user_2 : discord.Member=None):
        "Ship yourself, someone else, or two random people"

        msg = " :heart: "
        extra = ""
        member_list = list()
        author = ctx.message.author
        server = ctx.message.server
        
        if user_1 == None:
            for member in server.members:
                if member.id != author.id:
                    member_list.append(member)
            user_1 = member_list[randint(0, len(member_list)-1)]
        
        if user_2 == None:
            for member in server.members:
                if member.id != author.id:
                    member_list.append(member)
            user_2 = member_list[randint(0, len(member_list)-1)]
            
        if user_1 == self.bot.user and user_2 == self.bot.user:
            extra = "\nOh, how funny. I've never seen that response before, imbecile." 
        elif user_1 == self.bot.user or user_2 == self.bot.user:
            extra = "\nYou're not even worth the cheapest drink I bought today in this pub."
        elif user_1 == self.bot.user and user_1 == author:
            extra = "\nI'm flattered, really, but all I would do is merge your DNA into my programming, thus permanently erasing you from this world. Besides, you aren't my type."
        else:
            if user_1 == author and user_2 == author:
                extra = "\n\n`I wonder how desperate you can get.`"
            elif user_1 == author or user_2 == author:
                extra = "\n\n`You know, there's pathetic, and then there's you.`"
        await self.bot.say(user_1.mention + msg + user_2.mention + extra)

    @commands.command(pass_context=True, no_pm=True)
    async def playing(self, ctx, game=None):
        "Finds users playing a particular game"
        
        member_list = list()
        number = 0
        server = ctx.message.server

        for member in server.members:
            if member.game != None:
                if str(member.game).lower() == str(game).lower():
                    member_list.append(member.name)
                    number += 1
        
        if number > 0:        
            await self.bot.say("```{} users playing {}\n{}```".format(number, game, "\n".join(member_list)))
        else:
            await self.bot.say("```I either can't find {}, or you are a master of Engrish.```".format(game))

    @commands.command(pass_context=True, no_pm=True)
    @checks.admin_or_permissions(administrator=True)
    async def updateboard(self, ctx):
        """Updates usernames"""
        bank_list = self.bank.get_server_accounts(ctx.message.server)
        
        for account in bank_list:
            if account.member != None:
                user = discord.utils.get(ctx.message.server.members, id=account.member.id)
                if user != None:
                    self.bank.accounts[ctx.message.server.id][account.member.id]["name"] = user.name
                    self.bank._save_bank()
            
        await self.bot.say("Updated all registered bank names!\n```It's recommended you reload modules tha rely on accounts```")

    @commands.group(pass_context=True)
    async def top(self, ctx):
        """Lodge moderator reports on users"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)
            return

    @top.command(pass_context=True, no_pm=True, name="update")
    @checks.admin_or_permissions(administrator=True)
    async def top_update(self, ctx):
        "Get the highest posters"
        ranks = {}
        ranks[ctx.message.server.id] = {}
        await self.bot.say("Running post leaderboard update.")
        for channel in ctx.message.server.channels:
            number = 0
            async for message in self.bot.logs_from(channel, limit=100):
                number = number + 1
                if self.bot.user not in message.mentions and message.author.bot != True:
                    if len(message.content.split(" ")) >= 4 and len(message.content) >= 8 and not message.content.startswith("!"):
                        try:
                            ranks[ctx.message.server.id][message.author.id]["posts"] += 1
                        except KeyError:
                            ranks[ctx.message.server.id][message.author.id] = {}
                            ranks[ctx.message.server.id][message.author.id]["posts"] = 1
                            ranks[ctx.message.server.id][message.author.id]["username"] = message.author.name
                last = message
                
            while number == 100:
                number = 0
                async for message in self.bot.logs_from(channel, limit=100, before=last):
                    number = number + 1
                    if self.bot.user not in message.mentions and message.author.bot != True:
                        if len(message.content.split(" ")) >= 4 and len(message.content) >= 8 and not message.content.startswith("!"):
{'fraction_non_alphanumeric': 0.11401008550756413, 'fraction_numerical': 0.0064313381568369505, 'mean_word_length': 1.9923463809315547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1502236', 'n_tokens_mistral': 4011, 'n_tokens_neox': 3861, 'n_words': 1067}