feat: add PublicDomain in config.ini
DMZ in stupid routers sucks Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
25768e4c90
commit
e5277d50f8
3 changed files with 6 additions and 4 deletions
|
@ -4,4 +4,5 @@ SourceUrl =
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Name = Danbooru
|
Name = Danbooru
|
||||||
Domain = danbooru.donmai.us
|
Domain = danbooru.donmai.us
|
||||||
|
PublicDomain = danbooru.donmai.us
|
|
@ -21,7 +21,7 @@ async def inline_query(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||||
return
|
return
|
||||||
|
|
||||||
from main import config
|
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:
|
if response.status_code != 200:
|
||||||
await invalid_query(update, query)
|
await invalid_query(update, query)
|
||||||
|
@ -41,7 +41,7 @@ async def answer_query(update: Update, query: str,
|
||||||
keyboard = [
|
keyboard = [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(f"Open in {config.get('Service', 'Name')}",
|
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'])
|
InlineKeyboardButton("View original", url=data['file_url'])
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
3
main.py
3
main.py
|
@ -34,9 +34,10 @@ def main() -> None:
|
||||||
|
|
||||||
|
|
||||||
def validate_config() -> None:
|
def validate_config() -> None:
|
||||||
|
# TODO: do some PublicDomain checks or something
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
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:
|
if response.status_code != 200:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Reference in a new issue