Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/define-build-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 2 additions & 2 deletions .github/workflows/release-tagged-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
3 changes: 2 additions & 1 deletion config.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"test_channel_id": ""
},
"malnotifier": {
"client_id": ""
"client_id": "",
"flare_solverr_ip": ""
},
"spotify": {
"client_id": "",
Expand Down
7 changes: 7 additions & 0 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
7 changes: 6 additions & 1 deletion src/nikobot/modules/mal/flare_solverr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
5 changes: 3 additions & 2 deletions src/nikobot/modules/mal/mal_user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""A module containing the ``MALUser`` class"""

from __future__ import annotations
from typing import Any

from abllib.storage import PersistentStorage

Expand All @@ -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):
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/nikobot/modules/mal/malnotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
5 changes: 3 additions & 2 deletions src/nikobot/modules/mal/manga.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion src/nikobot/modules/spotify/req.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down