diff --git a/docker-compose.yml b/docker-compose.yml index ae466bd6b6..4ae6de3c90 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,7 +16,7 @@ services: - SITE_NAME=Drama - CLOUDFLARE_ZONE=vcxvdfgfc6r554etrgd - CLOUDFLARE_KEY=vcxvdfgfc6r554etrgd - - TENOR_KEY=vcxvdfgfc6r554etrgd + - GIPHY_KEY=vcxvdfgfc6r554etrgd - MAILGUN_KEY=vcxvdfgfc6r554etrgd - MAILGUN_DOMAIN=rdrama.net - FORCE_HTTPS=0 diff --git a/files/__main__.py b/files/__main__.py index a6d1c5e16d..71ebbc0e6b 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -87,8 +87,6 @@ app.config["CACHE_OPTIONS"]={'connection_pool':redispool} if app.config["CACHE_T app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0"))) app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False))) -app.config["TENOR_KEY"]=environ.get("TENOR_KEY",'').strip() - Markdown(app) cache = Cache(app) diff --git a/files/routes/giphy.py b/files/routes/giphy.py new file mode 100644 index 0000000000..28b2bfadf1 --- /dev/null +++ b/files/routes/giphy.py @@ -0,0 +1,22 @@ +from flask import * +from os import environ +import requests + +from files.__main__ import app + +GIPHY_KEY = environ.get('GIPHY_KEY').rstrip() + + +@app.route("/giphy", methods=["GET"]) +@app.route("/giphy", methods=["GET"]) +def giphy(): + + searchTerm = request.args.get("searchTerm", "") + limit = int(request.args.get("limit", "")) + if searchTerm and limit: + url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}" + elif searchTerm and not limit: + url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48" + else: + url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48" + return jsonify(requests.get(url).json()) \ No newline at end of file diff --git a/files/templates/gif_modal.html b/files/templates/gif_modal.html index abab86a1ba..291b48cc5f 100644 --- a/files/templates/gif_modal.html +++ b/files/templates/gif_modal.html @@ -25,11 +25,4 @@ - - - diff --git a/giphy.py b/giphy.py new file mode 100644 index 0000000000..28b2bfadf1 --- /dev/null +++ b/giphy.py @@ -0,0 +1,22 @@ +from flask import * +from os import environ +import requests + +from files.__main__ import app + +GIPHY_KEY = environ.get('GIPHY_KEY').rstrip() + + +@app.route("/giphy", methods=["GET"]) +@app.route("/giphy", methods=["GET"]) +def giphy(): + + searchTerm = request.args.get("searchTerm", "") + limit = int(request.args.get("limit", "")) + if searchTerm and limit: + url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit={limit}" + elif searchTerm and not limit: + url = f"https://api.giphy.com/v1/gifs/search?q={searchTerm}&api_key={GIPHY_KEY}&limit=48" + else: + url = f"https://api.giphy.com/v1/gifs?api_key={GIPHY_KEY}&limit=48" + return jsonify(requests.get(url).json()) \ No newline at end of file diff --git a/readme.md b/readme.md index 85759a978c..115d8af124 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ docker-compose up 4- That's it! Visit `localhost` in your browser. -5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, tenor and mailgun), please edit the variables in the docker-compose.yml file. +5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, giphy and mailgun), please edit the variables in the docker-compose.yml file. --- @@ -51,7 +51,7 @@ source setup 4- That's it. Visit `localhost` in your browser. -5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, tenor and mailgun), please run this command and edit the variables: +5- Optional: to configure the site settings and successsfully integrate it with the external services we use (hcaptcha, cloudflare, discord, giphy and mailgun), please run this command and edit the variables: ``` nano /drama/docker-compose.yml