예제 #1
0
async def declineScore(ctx, ID: int):
    guild = client.get_guild(guildid)
    teamID = db.getTeamNumber(ctx.author.id)
    League_ID = db.getLeagueNumber(ctx.author.id)
    LeagueInfo = db.getTeamNames(League_ID)[0]
    scoreChat = discord.utils.get(guild.channels,
                                  id=db.getLeagueObjectID(League_ID, "Scores"))
    score = db.getScore(ID)
    Team_1 = score[3]
    Team_2 = score[4]
    score_1 = score[5]
    score_2 = score[6]
    Fixture_Pos = score[2]
    if (teamID == Team_1 or teamID == Team_2):
        await ctx.channel.send("Thank you, we will let the League know")
        db.deleteScore(League_ID, Fixture_Pos)
        scoreMessage = str(Fixture_Pos) + ":       **" + str(
            score_1) + "**" + "     " + str(
                LeagueInfo[Team_1 + 1]) + " vs " + str(
                    LeagueInfo[Team_2 +
                               1]) + "     " + "**" + str(score_2) + "**"
        await scoreChat.send("The following score has been **declined** by " +
                             ctx.author.name + ":\n" + scoreMessage)
    else:
        await ctx.channel.send("Invalid Submission ID")
예제 #2
0
async def acceptScore(ctx, ID: int):
    guild = client.get_guild(guildid)
    teamID = db.getTeamNumber(ctx.author.id)
    League_ID = db.getLeagueNumber(ctx.author.id)
    manager = db.getManager(League_ID, teamID)
    scoreChat = discord.utils.get(guild.channels,
                                  id=db.getLeagueObjectID(League_ID, "Scores"))
    score = db.getScore(ID)
    if (ctx.author.id == manager):
        if (teamID == Team_1 or teamID == Team_2):
            Team_1 = score[3]
            Team_2 = score[4]
            LeagueInfo = db.getTeamNames(League_ID)[0]
            score_1 = score[5]
            score_2 = score[6]
            Fixture_Pos = score[2]
            db.addFixtureScore(League_ID, Fixture_Pos, score_1, score_2)
            db.deleteScore(League_ID, Fixture_Pos)
            await ctx.channel.send("We will add this to the fixtures now!")
            scoreMessage = str(Fixture_Pos) + ":       **" + str(
                score_1) + "**" + "     " + str(
                    LeagueInfo[Team_1 + 1]) + " vs " + str(
                        LeagueInfo[Team_2 +
                                   1]) + "     " + "**" + str(score_2) + "**"
            await scoreChat.send(
                "The following score has been **accepted** by both managers:\n"
                + scoreMessage)
        else:
            await ctx.channel.send("Invalid Submission ID")
    else:
        await ctx.channel.send("You are not a manager!")
예제 #3
0
async def scores(ctx):
    if await isRegistered(ctx) == False:
        return

    if await inPublicChannel(
            ctx,
            msg=
            f"Hey, <@{ctx.author.id}>, don't show your scores in public channels..."
    ):
        return

    if ctfRunning() == False:
        await ctx.send("CTF isn't running yet")
        return

    # individual score
    msg = ''
    with db.db_session:
        user = db.User.get(name=username(ctx))  #simpler

        individual_points = db.getScore(user)
        if SETTINGS['_debug'] == True and SETTINGS['_debug_level'] == 2:
            logger.debug(f'{user.name} individual points {individual_points}')

        # teammates scores
        teammates = db.getTeammateScores(user)
        teammates = sorted(teammates, key=lambda x: x[1], reverse=True)
        teammates.insert(0, ['Teammate', 'Score'])
        table = GithubFlavoredMarkdownTable(teammates)

        team_points = sum([v for k, v in teammates[1:]])  #skip header

        msg += f'Your score is `{individual_points}`\n'
        msg += f'\nTeam `{user.team.name}` has `{team_points}` ```{table.table}```'

        if SETTINGS['scoreboard'] == 'public':
            #top 3 team scores
            scores = db.getTopTeams(
                num=SETTINGS['_scoreboard_size'])  # private settings with _
            scores.insert(0, ['Team Name', 'Score'])
            table = GithubFlavoredMarkdownTable(scores)

            msg += f'Top {SETTINGS["_scoreboard_size"]} Team scores \n```{table.table}```'
        else:
            msg += f"Scoreboard is set to private\n"

        if SETTINGS['_show_mvp'] == True:
            # top players in the game
            topPlayers = db.topPlayers(num=SETTINGS['_mvp_size'])
            data = [(p.name, p.team.name, v) for p, v in topPlayers]
            data.insert(0, ['Player', 'Team', 'Score'])
            table = GithubFlavoredMarkdownTable(data)
            table = GithubFlavoredMarkdownTable(data)
            msg += f'Top {SETTINGS["_mvp_size"]} Players\n```{table.table}```'
        else:
            msg += f"MVP is set to False    "

        await ctx.send(msg)
예제 #4
0
    def users(self):
        """Dump all users, which team they're on and their individual score. 
        """
        data = db.select(u for u in db.User)[:]
        
        data = [(u.id, u.name,u.team.name, db.getScore(u)) for u in data]

        data.insert(0, ['ID', 'Name','Team', 'Score'])
        table = mdTable(data)
        print(table.table)
예제 #5
0
async def tip(ctx,
              target_user: Union[discord.User, str],
              tip_amount: float,
              msg=None):
    if await isRegistered(ctx) == False:
        return

    if msg == None:
        msg = "Thank you for being a friend."  # make this a random friendly message?

    if tip_amount < 1:
        await ctx.send("nice try... ")
        return

    with db.db_session:

        sender = db.User.get(name=username(ctx))

        recipient = db.User.get(name=username(target_user))
        if recipient == None:
            await ctx.send(f"invalid recipient...`{target_user}`")
            return

        # check funds
        points = db.getScore(sender)
        logger.debug(f'my points {points} tip amount {tip_amount}')
        if points < tip_amount:
            await ctx.send(
                f"You only have {points} points and can't send {tip_amount}..."
            )
            return

        msg = msg[:100]

        tip = db.Transaction(
            sender=sender,
            recipient=recipient,
            value=tip_amount,
            type='tip',
            message=msg,
        )

        db.commit()

    recipient_discord_user = await getDiscordUser(ctx, username(target_user))
    message = f'<@{ctx.author.id}> is sending a tip of `{tip_amount}` points to <@{recipient_discord_user.id}> with message ```{msg}```'
    await ctx.send(message)
    if SETTINGS['_debug'] == True and SETTINGS['_debug_level'] == 1:
        logger.debug(f'{username(ctx)} - {message}')