diff --git a/.github/workflows/define-build-image.yml b/.github/workflows/define-build-image.yml index 0cf70e3..e31d283 100644 --- a/.github/workflows/define-build-image.yml +++ b/.github/workflows/define-build-image.yml @@ -22,7 +22,7 @@ jobs: docker save -o /tmp/image.tar ${{ env.IMAGE_NAME }}:latest - name: Cache docker image run: | - curl --fail-with-body -X POST -F "file=@/tmp/image.tar" -F "project_id=nikobot" -F "issue_id=1" http://192.168.0.145:25000/dump + curl --fail-with-body -X POST -F "file=@/tmp/image.tar" -F "project_id=nikobot" -F "issue_id=1" http://192.168.0.11:25000/dump - name: Remove local image run: | docker image rm ${{ env.IMAGE_NAME }} diff --git a/.github/workflows/release-tagged-image.yml b/.github/workflows/release-tagged-image.yml index 7756068..fe3310e 100644 --- a/.github/workflows/release-tagged-image.yml +++ b/.github/workflows/release-tagged-image.yml @@ -70,7 +70,7 @@ jobs: echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV} - name: Download cached docker image run: | - curl --fail-with-body -X GET http://192.168.0.145:25000/attachments/nikobot/1/image.tar -o /tmp/image.tar + curl --fail-with-body -X GET http://192.168.0.11:25000/attachments/nikobot/1/image.tar -o /tmp/image.tar - name: Load image run: | docker load --input /tmp/image.tar @@ -87,7 +87,7 @@ jobs: - name: Remove cached docker image if: always() run: | - curl --fail-with-body -X DELETE http://192.168.0.145:25000/attachments/nikobot/1/image.tar + curl --fail-with-body -X DELETE http://192.168.0.11:25000/attachments/nikobot/1/image.tar release: needs: [push] diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 7407315..5770e16 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -49,7 +49,7 @@ jobs: echo "IMAGE_NAME=`echo ${{github.repository}} | tr '[:upper:]' '[:lower:]'`" >>${GITHUB_ENV} - name: Download cached docker image run: | - curl --fail-with-body -X GET http://192.168.0.145:25000/attachments/nikobot/1/image.tar -o /tmp/image.tar + curl --fail-with-body -X GET http://192.168.0.11:25000/attachments/nikobot/1/image.tar -o /tmp/image.tar - name: Load image run: | docker load --input /tmp/image.tar @@ -64,4 +64,4 @@ jobs: - name: Remove cached docker image if: always() run: | - curl --fail-with-body -X DELETE http://192.168.0.145:25000/attachments/nikobot/1/image.tar + curl --fail-with-body -X DELETE http://192.168.0.11:25000/attachments/nikobot/1/image.tar diff --git a/config.template.json b/config.template.json index a8df661..a91d023 100644 --- a/config.template.json +++ b/config.template.json @@ -17,7 +17,8 @@ "test_channel_id": "" }, "malnotifier": { - "client_id": "" + "client_id": "", + "flare_solverr_ip": "" }, "spotify": { "client_id": "", diff --git a/src/main.py b/src/main.py index b387ebb..d8c24df 100644 --- a/src/main.py +++ b/src/main.py @@ -76,8 +76,15 @@ def save_func(): or config["malnotifier"]["client_id"] == "": raise ValueError("Missing client_id for use with the malnotifier module. " + "You can create one https://myanimelist.net/apiconfig and add it to your config.json.") + if "malnotifier" not in config \ + or "flare_solverr_ip" not in config["malnotifier"] \ + or config["malnotifier"]["flare_solverr_ip"] == "": + raise ValueError("Missing flare_solverr_ip for use with the malnotifier module. " + + "Take a look at https://github.com/FlareSolverr/FlareSolverr " \ + "on how to set up your own instance, then add its IP to your config.json.") VolatileStorage["mal.client_id"] = config["malnotifier"]["client_id"] + VolatileStorage["mal.flare_solverr_ip"] = config["malnotifier"]["flare_solverr_ip"] if "spotify.spotify" in config["modules"]: if "spotify" not in config \ diff --git a/src/nikobot/modules/mal/flare_solverr.py b/src/nikobot/modules/mal/flare_solverr.py index 5465e45..f4b8ffe 100644 --- a/src/nikobot/modules/mal/flare_solverr.py +++ b/src/nikobot/modules/mal/flare_solverr.py @@ -34,7 +34,12 @@ def solve(key: str, url: str) -> tuple[dict[str, str], dict[str, str]]: "url": url, "maxTimeout": 60000 } - r = requests.post("http://192.168.0.145:9213/v1", timeout=30, headers=headers, json=data) + r = requests.post( + f"http://{VolatileStorage['mal.flare_solverr_ip']}/v1", + timeout=30, + headers=headers, + json=data + ) if "status" in r.json() and r.json()["message"] == "Challenge not detected!": logger.debug("No cf challenge necessary") diff --git a/src/nikobot/modules/mal/mal_user.py b/src/nikobot/modules/mal/mal_user.py index 6771f54..cf59c5e 100644 --- a/src/nikobot/modules/mal/mal_user.py +++ b/src/nikobot/modules/mal/mal_user.py @@ -1,6 +1,7 @@ """A module containing the ``MALUser`` class""" from __future__ import annotations +from typing import Any from abllib.storage import PersistentStorage @@ -20,7 +21,7 @@ def __init__(self, mal_username: str, discord_id: int) -> None: self.manga: dict[int, Manga] = {} @staticmethod - def from_export(discord_user_id: int, export: dict[str, str]) -> MALUser: + def from_export(discord_user_id: int, export: dict[str, Any]) -> MALUser: """Factory method creating a new MALUser object using the export data created by my_user.export()""" if not isinstance(discord_user_id, int): @@ -43,7 +44,7 @@ def add_manga(self, manga: Manga) -> None: self.manga[manga.mal_id] = manga - def export(self) -> dict[str, str]: + def export(self) -> dict[str, Any]: """Create a dictionary which is JSON-compliant and can be used to recreate this exact User""" return { diff --git a/src/nikobot/modules/mal/malnotifier.py b/src/nikobot/modules/mal/malnotifier.py index 7447056..aea54fe 100644 --- a/src/nikobot/modules/mal/malnotifier.py +++ b/src/nikobot/modules/mal/malnotifier.py @@ -241,7 +241,7 @@ async def notify_user(self, user_id: int, maluser: MALUser) -> None: await self.notify_manga(user_id, manga) # avoid rate limits - await sleep(1) + await sleep(5) maluser.save_to_storage() diff --git a/src/nikobot/modules/mal/manga.py b/src/nikobot/modules/mal/manga.py index 4b9f014..493322b 100644 --- a/src/nikobot/modules/mal/manga.py +++ b/src/nikobot/modules/mal/manga.py @@ -5,6 +5,7 @@ import os from datetime import datetime from enum import Enum +from typing import Any from abllib import fs from abllib.log import get_logger @@ -71,7 +72,7 @@ def __init__(self, mal_id: int, title: str, title_translated: str | None, synony # pylint: disable=protected-access @staticmethod - def from_export(export: dict[str, str]) -> Manga: + def from_export(export: dict[str, Any]) -> Manga: """Factory method creating a new Manga object using the export data created by my_manga.export()""" if not isinstance(export["mal_id"], int): @@ -112,7 +113,7 @@ def from_mal_id(mal_id: int) -> Manga: data["score"]) return manga - def export(self) -> dict[str, str]: + def export(self) -> dict[str, Any]: """Create a dictionary which is JSON-compliant and can be used to recreate this exact Manga""" export_data = { diff --git a/src/nikobot/modules/spotify/req.py b/src/nikobot/modules/spotify/req.py index 6857d34..ac2001e 100644 --- a/src/nikobot/modules/spotify/req.py +++ b/src/nikobot/modules/spotify/req.py @@ -1,4 +1,4 @@ -"""A module containing wrapping functions around requests which retires on rate-limit exceedings""" +"""A module containing wrapping functions around requests which retries on rate-limit exceedings""" import asyncio