-
Notifications
You must be signed in to change notification settings - Fork 0
/
discord_bot.py
89 lines (74 loc) · 2.91 KB
/
discord_bot.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
import denvot_ai
import discord
import nest_asyncio
from time import sleep
from threading import Thread
from config import DISCORD_TOKEN
from discord.ext import commands
nest_asyncio.apply()
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>', intents=intents)
can_speak = True
audio_paths = []
voice_client = None
def playlist():
while 0<1:
if len(audio_paths) > 0 and voice_client != None and not voice_client.is_playing():
audio = audio_paths[0]
print(audio_paths.pop(0))
voice_client.play(discord.FFmpegPCMAudio(source=audio))
else: sleep(1)
Thread(target=playlist).start()
def audio_append(message):
audio_paths.append(denvot_ai.send(message))
def tts_append(message):
audio_paths.append(denvot_ai.ttss(message))
@bot.command()
async def join(ctx):
if ctx.author.voice != None:
channel = ctx.author.voice.channel
await channel.connect()
global voice_client
voice_client = ctx.voice_client
else: await ctx.send("Ты не в войсике, Пупс!!! 🤬")
@bot.command()
async def leave(ctx):
if ctx.voice_client != None:
await ctx.voice_client.disconnect()
global voice_client
voice_client = None
else: await ctx.send("Я не в войсике, Пупс!!! 🤬")
@bot.command()
async def clear(ctx):
denvot_ai.clear()
await ctx.send("Прочищено, Пупсик! 😏")
@bot.command()
async def dnvhelp(ctx):
await ctx.send("""
Бригада приехала!
`/dnv (запрос)` - денвот ответит на хорошие вопросы и сочинит интересные истории!
`--tts-rate (число)` - дополняет скорость речи!
`--tts-volume (число)` - качает громкость речи!
`--tts-pitch (число)` - изменяет тональность нетрезвой речи!
`--rvc-pitch (число)` - изменяет тональность трезвой речи (рек. использовать это, вместо --tts-pitch)!
""")
@bot.command()
async def dnv(ctx, *args):
if ctx.voice_client != None:
message = ctx.message.author.name + ": " + " ".join(args)
Thread(target=audio_append, args=[message]).start()
await ctx.send("Я в деле! 🤓")
else: await ctx.send("Я не в войсике, Пупс!!! 🤬")
@bot.command()
async def dnvtts(ctx, *args):
if ctx.voice_client != None:
message = " ".join(args)
Thread(target=tts_append, args=[message]).start()
await ctx.send("Я в деле! 🤓")
else: await ctx.send("Я не в войсике, Пупс!!! 🤬")
@bot.command()
async def dnvset(ctx, *args):
denvot_ai.sets(args[0], args[1], args[2])
await ctx.send("rvc:" + args[0] + " tts:" + args[1] + " pitch:" + args[2])
bot.run(DISCORD_TOKEN)