-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
105 lines (70 loc) · 2.46 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
import configparser
from shutil import copy
print("""## Welcome to bot setup ##
If you have additional questions type 'help' on each of answers.
If you wanna abort the setting up just close the program.
Please make sure that you will input the right data.
""")
while True:
token = input('Please enter your token here: ')
if token.lower() == 'help':
print("""Open the discord developer portal, create your application and copy your token.
https://discord.com/developers/applications""")
elif token == '':
continue
else:
break
while True:
owner_id = input('\nPlease enter your discord id: ')
if owner_id.lower() == 'help':
print("""Turn on developer mode in discord app settings. Then copy your id in the profile.
It will need for some commands.""")
elif owner_id == '':
continue
else:
break
while True:
prefix = input('\nPlease enter bot prefix: ')
if prefix.lower() == 'help':
print("""Prefix will be used for some ctx commands.""")
elif prefix == '':
continue
else:
break
while True:
admin_guild = input('\nPlease enter admin guild id: ')
if admin_guild.lower() == 'help':
print("""Admin guild id used for some commands.""")
elif admin_guild == '':
continue
else:
break
while True:
openweather_token = input('\nPlease enter openweather token (type "skip" for skip): ')
if openweather_token.lower() == 'help':
print("""Open https://openweathermap.org/ then login. Create token, copy and paste there.""")
elif openweather_token.lower() == 'skip':
break
elif openweather_token == '':
continue
else:
break
while True:
is_save = input('\nSave settings? (Yes/No): ')
if is_save.lower() == 'yes':
break
elif is_save.lower() == 'no':
exit('\nOkay. Try again.')
else:
continue
copy('config.ini.sample', 'config.ini')
config = configparser.ConfigParser()
config.read('config.ini')
config['bot']['token'] = token
config['bot']['owner_id'] = owner_id
config['bot']['prefix'] = prefix
config['settings']['admin_guild'] = admin_guild
config['weather']['openweather_token'] = '' if openweather_token == 'skip' else openweather_token
with open('config.ini', 'w') as f:
config.write(f)
print('\nDone. Now you can run the bot.')