aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Matei Pintilie <luca@lucamatei.com>2023-09-02 20:17:21 +0000
committerLuca Matei Pintilie <luca@lucamatei.com>2023-09-02 20:17:21 +0000
commit663a4ab7598cd96c3a84e5d1d69109ef076f3d1f (patch)
tree90973f375e538429d154dd8d10ea3c46dfa38804
parent9d7563a24d952b7e70c61eac5c70d75e14f8e1d4 (diff)
downloadsteve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar.gz
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar.bz2
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar.lz
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar.xz
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.tar.zst
steve-bot-663a4ab7598cd96c3a84e5d1d69109ef076f3d1f.zip
src.py: Fix runs_blacklist functionality after package bump
Diffstat (limited to '')
-rwxr-xr-xcogs/src.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/cogs/src.py b/cogs/src.py
index 47607ef..0ec8ae0 100755
--- a/cogs/src.py
+++ b/cogs/src.py
@@ -2,6 +2,7 @@ import json
from datetime import timedelta
from pathlib import Path
+import aiohttp
import discord
import requests
from discord.ext import commands, tasks
@@ -91,11 +92,16 @@ async def deleteRun(self, apiKey, ctx, run):
async def pendingRuns(self, ctx):
def banned_player_coop(run) -> bool:
- for player in run.players:
- if player in self.bot.runs_blacklist["players"]:
+ if isinstance(run.players, list):
+ for player in run.players:
+ if player in self.bot.runs_blacklist["players"]:
+ return True
+ else:
+ if run.players in self.bot.runs_blacklist["players"]:
return True
return False
+
def duplicate_run(run) -> bool:
for pending_run in pending_runs:
if (
@@ -122,9 +128,10 @@ async def pendingRuns(self, ctx):
game_ids = ("yd4ovvg1", "v1po7r76") # [mcbe, mcbece]
head = {"Accept": "application/json", "User-Agent": "mcbeDiscordBot/1.0"}
+ session = aiohttp.ClientSession()
for game in game_ids:
runs = []
- async with self.bot.session.get(
+ async with session.get(
f"https://www.speedrun.com/api/v1/runs?game={game}&status=new&max=200&embed=category,players,level&orderby=submitted",
headers=head,
) as temp:
@@ -136,7 +143,7 @@ async def pendingRuns(self, ctx):
or temp_json["pagination"]["size"] < 200
):
break
- temp = await self.bot.session.get(
+ temp = await session.get(
{
item["rel"]: item["uri"]
for item in temp_json["pagination"]["links"]
@@ -353,7 +360,8 @@ async def verifyNew(self, apiKey=None, userID=None):
async def verifiedCount(self, ctx, modName):
head = {"Accept": "application/json", "User-Agent": "mcbeDiscordBot/1.0"}
- async with self.bot.session.get(
+ session = aiohttp.ClientSession()
+ async with session.get(
f"https://www.speedrun.com/api/v1/users/{modName}", headers=head
) as r:
if r.status != 200:
@@ -367,7 +375,7 @@ async def verifiedCount(self, ctx, modName):
return
hold = []
- async with self.bot.session.get(
+ async with session.get(
f"https://www.speedrun.com/api/v1/runs?examiner={modID}&max=200", headers=head
) as temp:
while True:
@@ -378,7 +386,7 @@ async def verifiedCount(self, ctx, modName):
hold.extend(temp_json["data"])
if "pagination" not in temp_json or temp_json["pagination"]["size"] < 200:
break
- temp = await self.bot.session.get(
+ temp = await session.get(
{item["rel"]: item["uri"] for item in temp_json["pagination"]["links"]}[
"next"
],