forked from eibex/reaction-light
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·154 lines (119 loc) · 4.54 KB
/
setup.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
MIT License
Copyright (c) 2019-2021 eibex
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""
from os import path
from shutil import copy
import configparser
folder = path.dirname(path.realpath(__file__))
with open(f"{folder}/.version") as f:
__version__ = f.read().rstrip("\n").rstrip("\r")
print("Original Repository: https://github.com/eibex/reaction-light")
print(f"Version: {__version__}")
print("License: MIT\n")
print("### ### Reaction Light Setup ### ###")
print(
"If you would like more information about any of the steps, type 'help' as an"
" answer."
)
print(
"If you would like to abort the configuration close the program. No input will be"
" written to file until the setup is complete."
)
print(
"Default values are shown inside square brackets [] where applicable. Pressing"
" enter and leaving the field empty will accept the default value."
)
while True:
token = input(
"\nPaste the token of your bot user (you can create one at:"
" https://discord.com/developers/applications/) "
)
if token.lower() == "help":
print(
"\nThe bot token looks like this:"
" NDYzODUwNzM2OTk3MTA1NjY2.XSH7WA.w0WPO4tafLJ9rZoitBq1Q43AgnQ\n"
)
elif token == "":
continue
else:
break
prefix = input("\nInsert the prefix of the bot (help not available for this) [rl!] ")
if prefix == "":
prefix = "rl!"
while True:
name = input("\nInsert the name you wish to give the bot [Reaction Light] ")
if name.lower() == "help":
print("\nThe name will be shown in the embed footers created by the bot.")
elif name == "":
name = "Reaction Light"
break
else:
break
while True:
logo = input(
"\nPaste the URL to your preferred logo file (should end in *.png, *.jpg,"
" *.webp, ...) [readme.md logo] "
)
if logo.lower() == "help":
print("\nThe logo is the picture shown in the footer of the embeds.\n")
elif logo == "":
logo = "https://cdn.discordapp.com/attachments/671738683623473163/693451064904515645/spell_holy_weaponmastery.jpg"
break
else:
break
while True:
system_channel = input(
"Paste the ID of the channel you wish to receive system notifications (e.g."
" errors, new versions of the bot). This is optional and you can set it up"
" later by using the systemchannel command.\n"
)
if system_channel.lower() == "help":
print(
"Currently only new versions are going to be fetched. Less than one message"
" per week. Leave blank if no updates or error notifications want to be"
" received."
)
else:
break
while True:
colour = input(
"Insert the hexadecimal value of the embed colour you prefer [0xffff00] "
)
if colour.lower() == "help":
print(
"\nThe default is yellow. You can use a colour hex picker. You can change"
" the colour later with a command\n"
)
elif colour.lower() == "":
colour = "0xffff00"
break
else:
break
copy("{}/config.ini.sample".format(folder), "{}/config.ini".format(folder))
config = configparser.ConfigParser()
config.read("{}/config.ini".format(folder))
config["server"]["token"] = token
config["server"]["prefix"] = prefix
config["server"]["name"] = name
config["server"]["logo"] = logo
config["server"]["system_channel"] = system_channel
config["server"]["colour"] = colour
with open("{}/config.ini".format(folder), "w") as f:
config.write(f)
input("Done. You can now start the bot.")