-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.py
More file actions
43 lines (27 loc) · 769 Bytes
/
settings.py
File metadata and controls
43 lines (27 loc) · 769 Bytes
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
import shelve
from config import basedir
import os
import logging
filename = os.path.join(basedir, 'settings.data')
def _get_value(key: str):
logging.info(key)
settings = shelve.open(filename)
value = settings[key]
settings.close()
return value
def _set_value(key: str, value):
settings = shelve.open(filename)
settings[key] = value
settings.close()
def get_right_answer_points() -> int:
return _get_value('right_answer_points')
def set_right_answer_points(points):
_set_value('right_answer_points', points)
def get_bot_state() -> str:
return _get_value('bot_state')
def set_bot_state(state):
_set_value('bot_state', state)
class BotStates:
PAUSED = 'paused'
WORK = 'work'
STOPPED = 'stopped'