<commit_before>import discord
import os
import asyncio
import datetime
from cogs.utils.dataIO import dataIO
from discord.ext import commands
from __main__ import send_cmd_help
from .economy import NoAccount, NegativeValue

class Jobs:
    """Jobs"""

    def __init__(self, bot):
        self.bot = bot
        self.jobs = dataIO.load_json("data/jobs/jobs.json")
        self.active_jobs = []

    @commands.group(pass_context=True)
    async def work(self, ctx):
        """Work commands"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)

    @work.command(pass_context=True)
    async def start(self, ctx, *, job : str):
        """Starts working"""
        server = ctx.message.server
        jobs = self.jobs.get(server.id, [])
        author = ctx.message.author
        has_account = self.check_account(author)
        if has_account is False:
            await self.bot.say("You need a bank account first. {}bank register".format(ctx.prefix))
            return
        elif has_account is None:
            await self.bot.say("Economy cog doesn't seem to be loaded. Contact the owner.")
            return
        if not self.is_user_working(author):
            if job in jobs:
                if self.is_user_eligible(author, job, jobs):
                    new_job = ActiveJob(message=ctx.message, job_name=job, cog=self)
                    self.active_jobs.append(new_job)
                    #print(self.active_jobs)
                    await self.bot.say("You started working.")
                else:
                    await self.bot.say("You don't have the appropriate role for this job.")
            else:
                await self.bot.say("There's no such job.")
        else:
            await self.bot.say("You're already working.")

    @work.command(pass_context=True)
    async def stop(self, ctx):
        """Stops working"""
        author = ctx.message.author
        for job in self.active_jobs:
            if job.member == author:
                self.active_jobs.remove(job)
                #print(self.active_jobs)
                await self.bot.say("You stopped working.")
                return
        else:
            await self.bot.say("You're not working any job")

    @commands.group(pass_context=True)
    async def job(self, ctx):
        """Jobs related commands"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)

    @job.command(pass_context=True)
    async def add(self, ctx, job : str, time : int, payout : int, role : discord.Role=None):
        """Adds job"""
        server = ctx.message.server
        job = job.lower()
        self.jobs.setdefault(server.id, {})
        jobs = self.jobs[server.id]
        role = role.name if role is not None else None
        if job not in jobs:
            jobs[job] = {
                "time" : time,
                "payout" : payout,
                "role" : role
                }
            await self.bot.say("Job added.")
            dataIO.save_json("data/jobs/jobs.json", self.jobs)
        else:
            await self.bot.say("A job with that name already exists.")

    @job.command(pass_context=True)
    async def remove(self, ctx, *, job : str):
        """Removes job"""
        server = ctx.message.server
        job = job.lower()
        jobs = self.jobs.get(server.id, {})
        if job in jobs:
            self.remove_active_jobs_by_name(job)
            del jobs[job]
            await self.bot.say("Job deleted.")
            dataIO.save_json("data/jobs/jobs.json", self.jobs)
        else:
            await self.bot.say("That job doesn't exist.")

    @job.command(name="list", pass_context=True)
    async def _list(self, ctx):
        """Lists server's jobs"""
        server = ctx.message.server
        jobs = self.jobs.get(server.id, {})
        #print(jobs)
        if jobs:
            msg = "Jobs in this server:\n\n```erlang\n"
            for job in jobs:
                job_name = job
                job = jobs[job]<commit_msg>Update jobs.py<commit_after>import discord
import os
import asyncio
import datetime
from cogs.utils.dataIO import dataIO
from discord.ext import commands
from __main__ import send_cmd_help
from .economy import NoAccount, NegativeValue
from cogs.utils import checks

class Jobs:
    """Jobs"""

    def __init__(self, bot):
        self.bot = bot
        self.jobs = dataIO.load_json("data/jobs/jobs.json")
        self.active_jobs = []

    @commands.group(pass_context=True)
    async def work(self, ctx):
        """Work commands"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)

    @work.command(pass_context=True)
    async def start(self, ctx, *, job : str):
        """Starts working"""
        server = ctx.message.server
        jobs = self.jobs.get(server.id, [])
        author = ctx.message.author
        has_account = self.check_account(author)
        if has_account is False:
            await self.bot.say("You need a bank account first. {}bank register".format(ctx.prefix))
            return
        elif has_account is None:
            await self.bot.say("Economy cog doesn't seem to be loaded. Contact the owner.")
            return
        if not self.is_user_working(author):
            if job in jobs:
                if self.is_user_eligible(author, job, jobs):
                    new_job = ActiveJob(message=ctx.message, job_name=job, cog=self)
                    self.active_jobs.append(new_job)
                    #print(self.active_jobs)
                    await self.bot.say("You started working.")
                else:
                    await self.bot.say("You don't have the appropriate role for this job.")
            else:
                await self.bot.say("There's no such job.")
        else:
            await self.bot.say("You're already working.")

    @work.command(pass_context=True)
    async def stop(self, ctx):
        """Stops working"""
        author = ctx.message.author
        for job in self.active_jobs:
            if job.member == author:
                self.active_jobs.remove(job)
                #print(self.active_jobs)
                await self.bot.say("You stopped working.")
                return
        else:
            await self.bot.say("You're not working any job")

    @commands.group(pass_context=True)
    async def job(self, ctx):
        """Jobs related commands"""
        if ctx.invoked_subcommand is None:
            await send_cmd_help(ctx)

    @job.command(pass_context=True)
    @checks.mod_or_permissions(manage_messages=True)
    async def add(self, ctx, job : str, time : int, payout : int, role : discord.Role=None):
        """Adds job"""
        server = ctx.message.server
        job = job.lower()
        self.jobs.setdefault(server.id, {})
        jobs = self.jobs[server.id]
        role = role.name if role is not None else None
        if job not in jobs:
            jobs[job] = {
                "time" : time,
                "payout" : payout,
                "role" : role
                }
            await self.bot.say("Job added.")
            dataIO.save_json("data/jobs/jobs.json", self.jobs)
        else:
            await self.bot.say("A job with that name already exists.")

    @job.command(pass_context=True)
    @checks.mod_or_permissions(manage_messages=True)
    async def remove(self, ctx, *, job : str):
        """Removes job"""
        server = ctx.message.server
        job = job.lower()
        jobs = self.jobs.get(server.id, {})
        if job in jobs:
            self.remove_active_jobs_by_name(job)
            del jobs[job]
            await self.bot.say("Job deleted.")
            dataIO.save_json("data/jobs/jobs.json", self.jobs)
        else:
            await self.bot.say("That job doesn't exist.")

    @job.command(name="list", pass_context=True)
    async def _list(self, ctx):
        """Lists server's jobs"""
        server = ctx.message.server
        jobs = self.jobs.get(server.id, {})
        #print(jobs)
        if jobs:
            msg = "Jobs in this server:\n\n```erlang\n"
            for job in jobs:
                job_name = job
                job = jobs[job]
{'fraction_non_alphanumeric': 0.11158588694909047, 'fraction_numerical': 0.0, 'mean_word_length': 1.8784258608573436, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '447311', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2350, 'n_words': 610}