This repository has been archived by the owner on Aug 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
68 lines (56 loc) · 2.75 KB
/
config.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 configparser
from ast import literal_eval
config=configparser.ConfigParser()
modules={'main':False,'reload':False}
bot=False
connected=False
datafolder='data/'
dhelp={'kahoot':
"`k!kahoot [time]`: Start a game, time controls how many seconds people have to join.",
'help':
"`k!help [command]`: Prompts the help message. Following it with a command name shows only the help for that command.",
'question':
"`k!question add (Question?) [time]`: Add your own question, you can set the time limit from 10 to 30 seconds. 15 seconds is default.",
'questions':
"`k!questions [search] [by:UserID or User#1234]`: View all the questions, sorted by the number of collections they're in. Supports search, *don't mention people when searching for them.*",
'collection':
"`k!collection create`: Create a collection of questions. You'll need to find questions to add by searching for them, this works the same way as `k!question`, without the command.",
'collections':
"`k!collections`: View all collections, sorted by ratings.",
'ratings':
"`k!ratings [clear]`: View all ratings you've left on collections of questions. Use `clear` if you want them erased.",
'feedback':
"`k!feedback (Your feedback)`: Give feedback directly to the developers, we might get in touch with you.",
'privacy':
"`k!privacy`: Reads you your privacy policy for the external portion of Kahoot.Discord's functionality."}
games={}
authcodes={}
verbose,logchannel,modchannel,apiurl,apiport,ver,lastver,changes,superusers=(None,)*9
questions,collections,ratings=(None,)*3
def reload():
global verbose,logchannel,modchannel,apiurl,apiport,ver,lastver,changes,superusers
global questions,collections,ratings
print('reading config...')
config.read(datafolder+'config.ini')
#settings
verbose=config.getint('settings','verbose')
logchannel=config.getint('settings','logchannel')
modchannel=config.getint('settings','modchannel')
apiurl=config.get('settings','apiurl')
apiport=config.getint('settings','apiport')
#versioning
ver=config.get('settings','ver')
lastver=config.get('settings','lastver')
with open(datafolder+'changes.txt', 'r', encoding='utf-8') as file:
changes=file.readlines()
#kahoot
questions={id:literal_eval(config.get('questions',id)) for id in config['questions']}
collections={id:literal_eval(config.get('collections',id)) for id in config['collections']}
ratings={id:literal_eval(config.get('ratings',id)) for id in config['ratings']}
superusers=[int(superuser) for superuser in config.get('settings','superusers').split(',')]
print('config read!')
def save():
with open(datafolder+'config.ini','w') as f:
config.write(f)
print('config saved!')
reload()