aboutsummaryrefslogtreecommitdiff
path: root/cogs
diff options
context:
space:
mode:
authorMango0x45 <thomasvoss@live.com>2020-09-12 13:28:56 +0000
committerMango0x45 <thomasvoss@live.com>2020-09-12 13:28:56 +0000
commitcb1dfb23bfb68803626becb9a7b7a55ab4036e7a (patch)
tree5252d6f2c79ed7b9d3b187cb8a1af20e6595d0d2 /cogs
parent0baa36497519711953603db640bf099db19af826 (diff)
downloadsteve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar.gz
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar.bz2
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar.lz
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar.xz
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.tar.zst
steve-bot-cb1dfb23bfb68803626becb9a7b7a55ab4036e7a.zip
Duplicate filter now checks for equal values
Diffstat (limited to 'cogs')
-rwxr-xr-xcogs/src.py27
1 files changed, 16 insertions, 11 deletions
diff --git a/cogs/src.py b/cogs/src.py
index 4c1f82e..81285a1 100755
--- a/cogs/src.py
+++ b/cogs/src.py
@@ -11,15 +11,16 @@ from discord.utils import get
class SubmittedRun:
- def __init__(self, game, _id, category, video, players, duration, _type):
+ def __init__(self, game, _id, category, video, players, duration, type_, values):
self.game = game
self._id = _id
self.category = category
self.video = video
self.players = players
self.duration = duration
- self._type = _type
+ self.type_ = type_
self.link = f"https://www.speedrun.com/{game}/run/{_id}"
+ self.values = values
async def rejectRun(self, apiKey, ctx, run, reason):
@@ -103,6 +104,7 @@ async def pendingRuns(self, ctx):
and run.category == pending_run.category
and run.video == pending_run.video
and run.duration == pending_run.duration
+ and run.values == pending_run.values
):
return True
return False
@@ -144,14 +146,14 @@ async def pendingRuns(self, ctx):
if run["level"]["data"] != []:
category = run["level"]["data"]["name"]
if game == "yd4ovvg1":
- _type = "Individual Level"
+ type_ = "Individual Level"
else:
category = run["category"]["data"]["name"]
if game == "yd4ovvg1":
- _type = "Full Game Run"
+ type_ = "Full Game Run"
if game == "v1po7r76":
- _type = "Category Extension"
+ type_ = "Category Extension"
# Set players to a string if solo, or a list if coop
if len(run["players"]["data"]) == 1:
@@ -161,8 +163,11 @@ async def pendingRuns(self, ctx):
map(lambda player: get_player_name(player), run["players"]["data"])
)
+ # Get the values of the run for the duplicate remover
+ values = run["values"]
+
pending_run = SubmittedRun(
- game, _id, category, video, players, duration, _type
+ game, _id, category, video, players, duration, type_, values
)
pending_runs.append(pending_run)
@@ -200,9 +205,9 @@ async def pendingRuns(self, ctx):
pending_runs.remove(run)
else:
- if run._type == "Full Game Run":
+ if run.type_ == "Full Game Run":
mcbe_runs += 1
- elif run._type == "Individual Level":
+ elif run.type_ == "Individual Level":
mcbeil_runs += 1
else:
mcbece_runs += 1
@@ -212,7 +217,7 @@ async def pendingRuns(self, ctx):
run.players = ", ".join(map(str, run.players))
embed = discord.Embed(
- title=run._type,
+ title=run.type_,
url=run.link,
description=f"{run.category} in `{str(run.duration).replace('000','')}` by **{run.players}**",
color=0x9400D3,
@@ -238,11 +243,11 @@ async def pendingRuns(self, ctx):
headers={
"X-API-Key": self.bot.config["api_key"],
"Accept": "application/json",
- "User-Agent": "mcbeDiscordBot/1.0",
+ "User-Agent": "MCBE_Moderation_Bot/1.0",
},
data=json.dumps(reject),
)
- if r.status_code == 200 or r.status_code == 204:
+ if r.status_code in [200, 204]:
await ctx.send(
f"Run rejected succesfully for `{run[1]}`\nLink: {run[0].link}"
)