-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdata_structure.py
116 lines (81 loc) · 2.51 KB
/
data_structure.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
106
107
108
109
110
111
112
113
114
115
116
import random
class Server:
def __init__(self):
self.queue = Queue()
self.counter = Counter()
self.bot_info = BotInfo()
async def reset(self):
self.queue.clear()
await self.counter.reset()
self.bot_info.reset()
class Bot:
def __init__(self):
self.server = {}
def startup(self, guilds):
for guild in guilds:
self.new_server(guild)
def new_server(self, guild):
self.server[str(guild.id)] = Server()
class Queue:
def __init__(self):
self.music_list = []
def __len__(self):
return len(self.music_list)
def __getitem__(self, index):
return self.music_list[index]
def __setitem__(self, index, url):
self.music_list.insert(index, url)
def append(self, url):
self.music_list.append(url)
def remove(self, index):
return self.music_list.pop(index)
def imprime(self):
print(self.music_list)
def move(self, starting_index, final_index):
self.music_list.insert(final_index, self.music_list.pop(starting_index))
def clear(self):
self.music_list.clear()
def shuffle(self):
random.shuffle(self.music_list)
class Counter:
def __init__(self):
self.counter = 0
async def add_timer(self):
self.counter += 1
async def reset(self):
self.counter = 0
async def get_time(self):
return self.counter
async def set_time(self, time):
self.counter = time
class BotInfo:
def __init__(self):
self.loop = False
self.loop_queue = False
self.seek = False
self.seek_time = 0
def reset(self):
self.loop = False
self.loop_queue = False
self.seek = False
self.seek_time = 0
def change_loop(self):
self.loop = not self.loop
return self.loop
def get_loop(self):
return self.loop
def change_loop_queue(self):
self.loop_queue = not self.loop_queue
return self.loop_queue
def get_loop_queue(self):
return self.loop_queue
def seek_set_true(self, time):
self.seek = True
self.seek_time = time
def seek_set_false(self):
self.seek = False
self.seek_time = 0
def get_seek(self):
return self.seek
def get_seek_time(self):
return self.seek_time