Update README.md
This commit is contained in:
53
README.md
53
README.md
@ -1 +1,52 @@
|
|||||||
# discord-nice-embed-maker-for-my-yoy
|
# discord-embed
|
||||||
|
|
||||||
|
Discord will only create embeds for videos and images if they are smaller than 8MB. We can "abuse" this by using the [twitter:image HTML meta tag](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup).
|
||||||
|
|
||||||
|
This is useful when you send a video and want it to be playable in Discord.
|
||||||
|
|
||||||
|
## How it works
|
||||||
|
|
||||||
|
This program will create a .html that you will send instead of a .mp4 file. Discord will parse the HTML and create an embed for you. The embed will be the same as the one you would get if you send a .mp4 file.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
This implies that you have experience with Nginx. Don't be afraid to contact me if you need help.
|
||||||
|
|
||||||
|
* Install latest version of [git](https://git-scm.com/), [Python](https://www.python.org/), [Poetry](https://python-poetry.org/docs/#installation) and Nginx.
|
||||||
|
* Clone the repository or download the [source code](https://github.com/TheLovinator1/discord-nice-embed-maker-for-my-yoy/archive/refs/heads/master.zip) directly from GitHub.
|
||||||
|
* Install the dependencies using [Poetry](https://python-poetry.org/docs/#installation).
|
||||||
|
* `poetry install`
|
||||||
|
* Rename .env.example to .env and fill in the required values.
|
||||||
|
* Copy discord-embed.service to /etc/systemd/system/discord-embed.service.
|
||||||
|
* `sudo cp discord-embed.service /etc/systemd/system/discord-embed.service`
|
||||||
|
* Change lovinator to your username.
|
||||||
|
* Change DOMAIN to the domain where we will serve the files.
|
||||||
|
* There is a bundled nginx config file that can be used to serve the site.
|
||||||
|
* `sudo cp nginx.conf /etc/nginx/`
|
||||||
|
* Start Nginx at boot.
|
||||||
|
* `sudo systemctl enable --now nginx`
|
||||||
|
* Create directory for uploaded files.
|
||||||
|
* `sudo mkdir /Uploads`
|
||||||
|
* Check what user is running Nginx, Arch is using http. Others could be www-data:
|
||||||
|
* ps aux | grep nginx
|
||||||
|
* Change permissions of /Uploads directory. Change lovinator to your username and http to the user running Nginx.
|
||||||
|
* `sudo chown -R lovinator:http /Uploads`
|
||||||
|
* Create log folder.
|
||||||
|
* `sudo mkdir /var/log/discord-embed`
|
||||||
|
* Change permissions of /var/log/discord-embed directory. Change lovinator to your username.
|
||||||
|
* `sudo chown -R lovinator:lovinator /var/log/discord-embed`
|
||||||
|
* Start the services.
|
||||||
|
* `sudo systemctl enable --now discord-embed.service`
|
||||||
|
* `sudo systemctl enable --now discord-embed.socket`
|
||||||
|
* Check if the services are running.
|
||||||
|
* `sudo systemctl status discord-embed.service`
|
||||||
|
* `sudo systemctl status discord-embed.socket`
|
||||||
|
* Check logs for errors.
|
||||||
|
* `cat /var/log/discord-embed/error.log` and `cat /var/log/discord-embed/access.log`
|
||||||
|
|
||||||
|
## Need help?
|
||||||
|
|
||||||
|
* Email: [tlovinator@gmail.com](mailto:tlovinator@gmail.com)
|
||||||
|
* Discord: TheLovinator#9276
|
||||||
|
* Steam: [TheLovinator](https://steamcommunity.com/id/TheLovinator/)
|
||||||
|
* Send an issue: [discord-embed/issues](https://github.com/TheLovinator1/discord-embed/issues)
|
||||||
|
17
discord-embed.service
Normal file
17
discord-embed.service
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=discord-embed
|
||||||
|
Requires=discord-embed.socket
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=notify
|
||||||
|
# Change lovinator to your username
|
||||||
|
User=lovinator
|
||||||
|
Group=lovinator
|
||||||
|
ExecStart=/home/lovinator/.local/bin/poetry run gunicorn --workers=3 --threads=3 -k uvicorn.workers.UvicornWorker --bind unix:/run/discord-embed.sock --access-logfile /var/log/discord-embed/access.log --error-logfile /var/log/discord-embed/error.log main:app
|
||||||
|
WorkingDirectory=/home/lovinator/discord-embed
|
||||||
|
Environment="DOMAIN=https://i.lovinator.space/"
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
11
discord-embed.socket
Normal file
11
discord-embed.socket
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Socket that Nginx will use to communicate with Gunicorn.
|
||||||
|
|
||||||
|
[Socket]
|
||||||
|
ListenStream=/run/discord-embed.sock
|
||||||
|
|
||||||
|
# Change this to the user that runs nginx. On Arch it is http, on others it is www-data. You can check with "ps aux | grep nginx"
|
||||||
|
SocketUser=http
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=sockets.target
|
98
nginx.conf
Normal file
98
nginx.conf
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
worker_processes auto;
|
||||||
|
events {
|
||||||
|
multi_accept on;
|
||||||
|
worker_connections 1024;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
http {
|
||||||
|
charset utf-8;
|
||||||
|
sendfile on;
|
||||||
|
tcp_nopush on;
|
||||||
|
tcp_nodelay on;
|
||||||
|
types_hash_max_size 4096;
|
||||||
|
types_hash_bucket_size 64;
|
||||||
|
server_tokens off;
|
||||||
|
client_max_body_size 0M;
|
||||||
|
set_real_ip_from 192.168.1.31;
|
||||||
|
|
||||||
|
# MIME
|
||||||
|
include mime.types;
|
||||||
|
default_type application/octet-stream;
|
||||||
|
|
||||||
|
# Log Format
|
||||||
|
log_format cloudflare '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $http_cf_ray $http_cf_connecting_ip $http_x_forwarded_for $http_x_forwarded_proto $http_true_client_ip $http_cf_ipcountry $http_cf_visitor $http_cdn_loop';
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
access_log /var/log/nginx/access.log cloudflare;
|
||||||
|
error_log /var/log/nginx/error.log warn;
|
||||||
|
|
||||||
|
# Load configs
|
||||||
|
include /etc/nginx/conf.d/*.conf;
|
||||||
|
|
||||||
|
keepalive_timeout 65;
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
# This is the URL where we will upload images to
|
||||||
|
server_name upload.lovinator.space;
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
# discord-embed needs to be running before we can use it
|
||||||
|
location / {
|
||||||
|
proxy_pass http://unix:/run/discord-embed.sock;
|
||||||
|
}
|
||||||
|
|
||||||
|
# logging
|
||||||
|
access_log /var/log/nginx/lovinator.space.access.log cloudflare;
|
||||||
|
error_log /var/log/nginx/lovinator.space.error.log warn;
|
||||||
|
|
||||||
|
# favicon.ico
|
||||||
|
location = /favicon.ico {
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# robots.txt
|
||||||
|
location = /robots.txt {
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# gzip
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
# This is the URL that the images will be served from
|
||||||
|
server_name i.lovinator.space;
|
||||||
|
|
||||||
|
# Where the images and videos are stored. Should be the same as "Environment="DOMAIN=https://i.lovinator.space/"" in discord-embed.service
|
||||||
|
root /Uploads;
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ $uri.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# logging
|
||||||
|
access_log /var/log/nginx/lovinator.space.access.log cloudflare;
|
||||||
|
error_log /var/log/nginx/lovinator.space.error.log warn;
|
||||||
|
|
||||||
|
# favicon.ico
|
||||||
|
location = /favicon.ico {
|
||||||
|
log_not_found off;
|
||||||
|
access_log off;
|
||||||
|
}
|
||||||
|
|
||||||
|
# gzip
|
||||||
|
gzip on;
|
||||||
|
gzip_vary on;
|
||||||
|
gzip_proxied any;
|
||||||
|
gzip_comp_level 6;
|
||||||
|
gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user