From d1d85765f7b5c72bef1804ca8c6455d0a8364acb Mon Sep 17 00:00:00 2001 From: RealistikDash Date: Sun, 16 Jun 2024 23:19:43 +0100 Subject: [PATCH] remove: all references to mmdb (#17) i am NOT waitifing fro len --- .env.example | 1 - CODEOWNERS | 2 +- Dockerfile | 1 - peppy/events/loginEvent.py | 1 - peppy/helpers/geo_helper.py | 29 ----------------------------- peppy/settings.py | 1 - 6 files changed, 1 insertion(+), 34 deletions(-) diff --git a/.env.example b/.env.example index 2113d0f..13a15f5 100644 --- a/.env.example +++ b/.env.example @@ -32,7 +32,6 @@ PS_PY_COMMAND_WHITELIST=1000,1180 # Data Directory Configuration DATA_BEATMAP_DIRECTORY=/path/to/your/beatmap/directory -DATA_GEOLOCATION_PATH=/path/to/geoloc/db DATA_BIBLE_PATH=/path/to/bible # Misc Configuration. diff --git a/CODEOWNERS b/CODEOWNERS index 432364b..3f42dc5 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @RealistikDash @lenforiee \ No newline at end of file +* @RealistikDash @lenforiee diff --git a/Dockerfile b/Dockerfile index c92e732..7d81808 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,7 +8,6 @@ WORKDIR /app COPY ./resources/geolocation_database.mmdb /app/resources/geolocation_database.mmdb COPY ./resources/bible.txt /app/resources/bible.txt -ENV DATA_GEOLOCATION_PATH=/app/resources/geolocation_database.mmdb ENV DATA_BIBLE_PATH=/app/resources/bible.txt # Requirements diff --git a/peppy/events/loginEvent.py b/peppy/events/loginEvent.py index 2afa59b..693ffb2 100644 --- a/peppy/events/loginEvent.py +++ b/peppy/events/loginEvent.py @@ -14,7 +14,6 @@ from constants import serverPackets from helpers import chatHelper as chat from helpers import geo_helper -from helpers.geo_helper import get_full from helpers.timing import Timer from helpers.user_helper import get_country from helpers.user_helper import set_country diff --git a/peppy/helpers/geo_helper.py b/peppy/helpers/geo_helper.py index bd831ed..f3537e2 100644 --- a/peppy/helpers/geo_helper.py +++ b/peppy/helpers/geo_helper.py @@ -1,10 +1,5 @@ from __future__ import annotations -import settings -from geoip2 import database - -db_reader = database.Reader(settings.DATA_GEOLOCATION_PATH) - countryCodes = { "IO": 104, "PS": 178, @@ -280,27 +275,3 @@ def getCountryLetters(code: int) -> str: :return: country letters (XX if not found) """ return countryIds.get(code, "XX") - - -def get_full(ip: str) -> tuple[float, float, str]: - """Fetches the user's full geolocation data and returns the imperative - info retrieved. - - Note: - This uses a really quick IP lookup database. use as a replacement to - full on API requests. - - Args: - ip (str): The IP of the user to fetch the info for. - - Returns: - Tuple of data in order of `(lat, long, country)` - """ - - try: - city = db_reader.city(ip) - - return city.location.latitude, city.location.longitude, city.country.iso_code # type: ignore L - - except Exception: - return 0.0, 0.0, "XX" diff --git a/peppy/settings.py b/peppy/settings.py index e5d280d..6f4a09c 100644 --- a/peppy/settings.py +++ b/peppy/settings.py @@ -49,7 +49,6 @@ def _parse_int_list(value: str) -> list[int]: PS_PY_COMMAND_WHITELIST = _parse_int_list(os.environ["PS_PY_COMMAND_WHITELIST"]) DATA_BEATMAP_DIRECTORY = os.environ["DATA_BEATMAP_DIRECTORY"] -DATA_GEOLOCATION_PATH = os.environ["DATA_GEOLOCATION_PATH"] DATA_BIBLE_PATH = os.environ["DATA_BIBLE_PATH"] IP2LOCATION_API_KEY = os.environ["IP2LOCATION_API_KEY"]