-
Notifications
You must be signed in to change notification settings - Fork 8
/
secret_create.py
68 lines (51 loc) · 1.36 KB
/
secret_create.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
class colors:
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
directory = 'secret'
if not os.path.exists(directory):
os.makedirs(directory)
print(f"{colors.BLUE}Creating the secrets.ini file{colors.NC}")
print(f"{colors.RED}Enter Discord Bot Token{colors.NC}")
BOT_TOKEN = input()
print(f"{colors.RED}Please provide the database configurations\n{colors.NC}")
print(f"{colors.RED}Database host ( Use db if using docker postgres service ){colors.NC}")
HOST = input()
print(f"{colors.RED}Database port{colors.NC}")
PORT = input()
print(f"{colors.RED}Database user{colors.NC}")
USER = input()
print(f"{colors.RED}Database password{colors.NC}")
PASSWORD = input()
print(f"{colors.RED}Database name{colors.NC}")
DATABASE = input()
secret_format = f"\
[DISCORD]\n\
BOT_TOKEN={BOT_TOKEN}\n\
\n\
[DATABASE]\n\
DATABASE={DATABASE}\n\
USER={USER}\n\
PASSWORD={PASSWORD}\n\
HOST={HOST}\n\
PORT={PORT}\n\
"
env_fornat = f"\
PYTHON_VERSION=3.8\n\
POSTGRES_VERSION=13-alpine\n\
WORKDIR=app\n\
SECRET_DIR=secret\n\
SECRET_FILE=secret.ini\n\
IMAGE_NAME=sid200026/toxicbot\n\
IMAGE_TAG=1.0.0\n\
POSTGRES_PASSWORD={PASSWORD}\n\
POSTGRES_USER={USER}\n\
POSTGRES_DB={DATABASE}\n\
POSTGRES_PORT={PORT}\n\
"
with open('secret/secret.ini', "w+") as file:
file.write(secret_format)
with open('.env', "w+") as file:
file.write(env_fornat)