feat: use status.json for "Open in" button
oh yeah and we're also going to make breaking changes to config because we can Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
parent
e5277d50f8
commit
4a2a2e9920
3 changed files with 5 additions and 5 deletions
|
@ -4,5 +4,4 @@ SourceUrl =
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Name = Danbooru
|
Name = Danbooru
|
||||||
Domain = danbooru.donmai.us
|
Host = 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"http://{config.get('Service', 'Domain')}/posts/{query}.json")
|
response = requests.get(f"http://{config.get('Service', 'Host')}/posts/{query}.json")
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
await invalid_query(update, query)
|
await invalid_query(update, query)
|
||||||
|
@ -38,10 +38,11 @@ async def answer_query(update: Update, query: str,
|
||||||
copyrights = humanize_tags_from_json(data['tag_string_copyright'], "unknown copyright")
|
copyrights = humanize_tags_from_json(data['tag_string_copyright'], "unknown copyright")
|
||||||
artists = humanize_tags_from_json(data['tag_string_artist'], "unknown artist")
|
artists = humanize_tags_from_json(data['tag_string_artist'], "unknown artist")
|
||||||
rating = format_rating(data['rating'])
|
rating = format_rating(data['rating'])
|
||||||
|
status_json = requests.get(f"http://{config.get('Service', 'Host')}/status.json").json()
|
||||||
keyboard = [
|
keyboard = [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(f"Open in {config.get('Service', 'Name')}",
|
InlineKeyboardButton(f"Open in {config.get('Service', 'Name')}",
|
||||||
url=f"https://{config.get('Service', 'PublicDomain')}/posts/{query}"),
|
url=f"https://{status_json['headers']['Host']}/posts/{query}"),
|
||||||
InlineKeyboardButton("View original", url=data['file_url'])
|
InlineKeyboardButton("View original", url=data['file_url'])
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
2
main.py
2
main.py
|
@ -37,7 +37,7 @@ def validate_config() -> None:
|
||||||
# TODO: do some PublicDomain checks or something
|
# TODO: do some PublicDomain checks or something
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
try:
|
try:
|
||||||
response = requests.get(f"http://{config.get('Service', 'Domain')}/profile.json")
|
response = requests.get(f"http://{config.get('Service', 'Host')}/status.json")
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Add table
Reference in a new issue