From e5277d50f885c2b4771731138dc59080a34a7dc2 Mon Sep 17 00:00:00 2001 From: mctaylors Date: Mon, 24 Mar 2025 20:40:08 +0300 Subject: [PATCH] feat: add PublicDomain in config.ini DMZ in stupid routers sucks Signed-off-by: mctaylors --- config.ini | 3 ++- inline_query.py | 4 ++-- main.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/config.ini b/config.ini index 2004516..cfde3e4 100644 --- a/config.ini +++ b/config.ini @@ -4,4 +4,5 @@ SourceUrl = [Service] Name = Danbooru -Domain = danbooru.donmai.us \ No newline at end of file +Domain = danbooru.donmai.us +PublicDomain = danbooru.donmai.us \ No newline at end of file diff --git a/inline_query.py b/inline_query.py index 9a2d43b..65b1cfb 100644 --- a/inline_query.py +++ b/inline_query.py @@ -21,7 +21,7 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No return from main import config - response = requests.get(f"https://{config.get('Service', 'Domain')}/posts/{query}.json") + response = requests.get(f"http://{config.get('Service', 'Domain')}/posts/{query}.json") if response.status_code != 200: await invalid_query(update, query) @@ -41,7 +41,7 @@ async def answer_query(update: Update, query: str, keyboard = [ [ InlineKeyboardButton(f"Open in {config.get('Service', 'Name')}", - url=f"https://{config.get('Service', 'Domain')}/posts/{query}"), + url=f"https://{config.get('Service', 'PublicDomain')}/posts/{query}"), InlineKeyboardButton("View original", url=data['file_url']) ] ] diff --git a/main.py b/main.py index 49be0a1..7329782 100644 --- a/main.py +++ b/main.py @@ -34,9 +34,10 @@ def main() -> None: def validate_config() -> None: + # TODO: do some PublicDomain checks or something # noinspection PyBroadException try: - response = requests.get(f"https://{config.get('Service', 'Domain')}/profile.json") + response = requests.get(f"http://{config.get('Service', 'Domain')}/profile.json") if response.status_code != 200: raise except: