-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshelvetry.py
79 lines (64 loc) · 1.84 KB
/
shelvetry.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
import shelve
def setans(chat_id, mode, task):
from quiz import count, generate
from prime import isprime, inventing
from polynom import mult
from radius import voluming
with shelve.open("data") as storage:
list = storage[str(chat_id)]
list[0] = task
if (mode == 0):
storage[str(chat_id)] = list
if(mode == 1):
storage[str(chat_id)] = list
if(mode == 2):
storage[str(chat_id)] = list
if(mode == 3):
storage[str(chat_id)] = list
storage.close()
def setgame(id):
with shelve.open("data") as storage:
storage[str(id)] = [0, 0, 0]
storage.close()
def getanswer(chat_id):
with shelve.open("data") as storage:
try:
list = storage[str(chat_id)]
ans = list[0]
storage.close()
return ans
except KeyError:
storage.close()
return None
def endgame(chat_id):
with shelve.open("data") as storage:
try:
del storage[str(chat_id)]
storage.close()
except KeyError:
storage.close()
return
def incscore(id):
with shelve.open("data") as storage:
list = storage[str(id)]
list[1] += 1
storage[str(id)] = list
storage.close()
def decscore(id):
with shelve.open("data") as storage:
list = storage[str(id)]
list[1] -= 2
storage[str(id)] = list
storage.close()
def setdif(id, dif):
with shelve.open("data") as storage:
list = storage[str(id)]
list[-1] = dif
storage[str(id)] = list
storage.close()
def getdif(id):
with shelve.open("data") as storage:
return storage[str(id)][-1]
def getscore(id):
with shelve.open("data") as storage:
return storage[str(id)][1]