-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
166 lines (123 loc) · 4.06 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from Discord.Bot import Bot, bot
from Discord.vars import bots
from config import DiscordCFG
from DB.DB import *
import asyncio
from threading import Thread
from TG.TGBot import TgBotRun
class Aliases:
def __init__(self):
self.p = ['play', 'P', 'Play', 'PLAY']
self.np = ['NP', 'Np']
self.q = ['q', 'Q']
self.fs = ['skip', 'Fs', 'FS', 'Skip', "SKIP"]
self.loop = ['loop', 'Loop']
async def check_bot(ctx):
if bots:
for i in range(len(bots)):
if bots[i].server == ctx.message.guild:
return True, i
return False, -1
async def func_start(command, ctx, text=""):
already_is, bot_index = await check_bot(ctx)
if already_is:
num = bot_index
else:
print(ctx)
bots.append(Bot(len(bots), ctx))
ServerDB().reg(ctx.guild)
num = len(bots) - 1
match command:
case "fs":
await bots[num].fs(ctx)
case "p":
await bots[num].p(ctx, text)
case "leave":
await bots[num].leave(ctx)
case "stop":
await bots[num].stop(ctx)
case "pause":
await bots[num].pause(ctx)
case "resume":
await bots[num].resume(ctx)
case "pp":
await bots[num].play_in_pos(ctx, text)
case "pn":
await bots[num].play_now(ctx, text)
case "np":
await bots[num].np(ctx)
case "queue":
await bots[num].queue1(ctx)
case "vk":
await bots[num].vk(ctx, text)
case "connect":
await bots[num].connect(ctx)
case "channel":
await bots[num].channel(ctx, text)
case "v":
pass
case "pack":
await bots[num].pack(ctx, text)
case "ss":
await bots[num].skip_parameters(ctx, text)
case "pl":
await bots[num].play_loop(ctx, text)
case "key":
await ctx.send(ServerDB().get_key(ctx.guild.id))
@bot.command(pass_context=False, aliases=Aliases().fs)
async def fs(ctx):
await func_start("fs", ctx)
@bot.command(pass_context=True, aliases=Aliases().p)
async def p(ctx, *, text):
await func_start("p", ctx, text)
@bot.command(pass_context=False)
async def leave(ctx):
await func_start("leave", ctx)
@bot.command(pass_context=False)
async def stop(ctx):
await func_start("stop", ctx)
@bot.command(pass_context=False)
async def pause(ctx):
await func_start("pause", ctx)
@bot.command(pass_context=False)
async def resume(ctx):
await func_start("resume", ctx)
@bot.command(pass_context=True)
async def pp(ctx, *, text):
await func_start("pp", ctx, text)
@bot.command(pass_context=True)
async def pn(ctx, *, text):
await func_start("pn", ctx, text)
@bot.command(pass_context=False, aliases=Aliases().np)
async def np(ctx):
await func_start("np", ctx)
@bot.command(pass_context=False, aliases=Aliases().q)
async def queue(ctx):
await func_start("queue", ctx)
@bot.command(pass_context=False)
async def vk(ctx, *, text):
await func_start("vk", ctx, text)
@bot.command(pass_context=False)
async def connect(ctx):
await func_start("connect", ctx)
@bot.command(pass_context=True)
async def channel(ctx, *, text):
await func_start("channel", ctx, text)
@bot.command(pass_context=True)
async def v(ctx, *, text):
await func_start("v", ctx, text)
@bot.command(pass_context=True)
async def pack(ctx, *, text):
await func_start("pack", ctx, text)
@bot.command(pass_context=True)
async def ss(ctx, *, text):
await func_start("ss", ctx, text)
@bot.command(pass_context=True, aliases=Aliases().loop)
async def pl(ctx, *, text):
await func_start("pl", ctx, text)
@bot.command(pass_context=False)
async def key(ctx):
await func_start("key", ctx)
loop = asyncio.get_event_loop()
loop.create_task(TgBotRun())
loop.run_until_complete(bot.start(DiscordCFG().BOT_TOKEN))