Compare commits
1 Commits
1a1247da7a
...
12a96665c7
Author | SHA1 | Date |
---|---|---|
Charlotte | 12a96665c7 |
|
@ -55,10 +55,23 @@ async def load_config(path: str) -> None:
|
|||
config = json.load(config_file)
|
||||
homeserver_url = config["homeserver"]
|
||||
access_token = config["access_token"]
|
||||
try:
|
||||
giphy_api_key = config["giphy_api_key"]
|
||||
giphy_mxc_prefix = config["giphy_mxc_prefix"]
|
||||
except KeyError:
|
||||
# these two are not mandatory, assume GIF search is disabled
|
||||
print("Giphy related parameters not found in the config file.")
|
||||
except FileNotFoundError:
|
||||
print("Matrix config file not found. Please enter your homeserver and access token.")
|
||||
homeserver_url = input("Homeserver URL: ")
|
||||
access_token = input("Access token: ")
|
||||
print("If you want to enable GIF search, enter your giphy API key. Otherwise, leave it empty.")
|
||||
giphy_api_key = input("Giphy API key: ").strip()
|
||||
giphy_mxc_prefix = "mxc://giphy.mau.dev/"
|
||||
if giphy_api_key:
|
||||
print("If you want to self-host the matrix->giphy proxy, enter the mxc URI prefix here")
|
||||
print("Defaults to mxc://giphy.mau.dev/ if left empty.")
|
||||
giphy_mxc_prefix = input("Giphy MXC prefix: ").strip() or giphy_mxc_prefix
|
||||
whoami_url = URL(homeserver_url) / "_matrix" / "client" / "r0" / "account" / "whoami"
|
||||
if whoami_url.scheme not in ("https", "http"):
|
||||
whoami_url = whoami_url.with_scheme("https")
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as widgetAPI from "./widget-api.js";
|
|||
import {SearchBox} from "./search-box.js";
|
||||
|
||||
const GIPHY_SEARCH_DEBOUNCE = 1000
|
||||
let GIPHY_API_KEY = "HQku8974Uq5MZn3MZns46kXn2R4GDm75"
|
||||
let GIPHY_API_KEY = ""
|
||||
let GIPHY_MXC_PREFIX = "mxc://giphy.mau.dev/"
|
||||
|
||||
export function giphyIsEnabled() {
|
||||
|
|
|
@ -166,9 +166,7 @@ class App extends Component {
|
|||
}
|
||||
const indexData = await indexRes.json()
|
||||
HOMESERVER_URL = indexData.homeserver_url || HOMESERVER_URL
|
||||
if (indexData.giphy_api_key !== undefined) {
|
||||
setGiphyAPIKey(indexData.giphy_api_key, indexData.giphy_mxc_prefix)
|
||||
}
|
||||
setGiphyAPIKey(indexData.giphy_api_key, indexData.giphy_mxc_prefix)
|
||||
// TODO only load pack metadata when scrolled into view?
|
||||
for (const packFile of indexData.packs) {
|
||||
let packRes
|
||||
|
|
Loading…
Reference in New Issue