-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
49 lines (39 loc) · 1.8 KB
/
main.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
import os
from Database import Database
from Server import Server
print('dAmnCaek version 0.1 booting up...')
db = Database()
if False == os.path.exists('Database/config'):
print('Server is not configured.')
print('I\'ll need to ask you a few questions to get things running.')
address = input('What IP will the server run on? [127.0.0.1]: ')
if len(address) < 7:
address = '127.0.0.1'
port = input('What port should the server run on? [3900]: ')
if len(port) == 0:
port = 3900
else:
port = int(port)
max_connections = input('How many people can be connected at once? [50]: ')
if len(max_connections) == 0:
max_connections = 50
else:
max_connections = int(max_connections)
print('Gotcha. So the server will run on {0}:{1}, and accept up to {2} people at once.'.format(address, port, max_connections))
print('Saving config and closing the server, please restart.')
config = {'address':address,'port':port,'maxConnections':max_connections}
db.saveFile('Database/config', config)
else:
print('Attempting to load server configuration...')
config = db.loadFile('Database/config')
if config is None:
print('Failed to load config!')
else:
print('Config loaded!')
print('Starting server...')
serv = Server(str(config['address']),
int(config['port']),
int(config['maxConnections']))
serv.channels['botdom'] = {'owner':'core','desc':'Bots ftw!','title':'this is a title','topic':'this is a topic'} #for now
serv.channels['datashare'] = {'owner':'core','desc':'Bots ftw!','title':'this is a title','topic':'this is a topic'} #for now
serv.run()