Compare commits
No commits in common. "bce9abd10ad400ddb32c266b6f1152cf44a70654" and "c6c5d9c9a7e0d89b7e3377ad4342464807527c7c" have entirely different histories.
bce9abd10a
...
c6c5d9c9a7
@ -20,7 +20,7 @@ License: `GNU GENERAL PUBLIC LICENSE Version 3`
|
|||||||
Author discord: `a31#6403`
|
Author discord: `a31#6403`
|
||||||
Author email: `a31@demb.design`
|
Author email: `a31@demb.design`
|
||||||
Source code on github: <https://github.com/norohind/SileroTTSBot>
|
Source code on github: <https://github.com/norohind/SileroTTSBot>
|
||||||
Source code on gitea a31's instance: <https://gitea.demb.design/a31/SileroTTSBot>
|
Source code on gitea's a31 instance: <https://gitea.demb.design/a31/SileroTTSBot>
|
||||||
Invite link: https://discord.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot%20applications.commands
|
Invite link: https://discord.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot%20applications.commands
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -25,29 +25,8 @@ class TTSCore(commands.Cog, Observ.Observer):
|
|||||||
self.tts_queues: dict[int, list[discord.AudioSource]] = defaultdict(list)
|
self.tts_queues: dict[int, list[discord.AudioSource]] = defaultdict(list)
|
||||||
self.speakers_adapter: SpeakersSettingsAdapterDiscord = speakers_settings_adapter
|
self.speakers_adapter: SpeakersSettingsAdapterDiscord = speakers_settings_adapter
|
||||||
|
|
||||||
@commands.command('drop')
|
|
||||||
async def drop_queue(self, ctx: Context):
|
|
||||||
"""
|
|
||||||
Drop tts queue for current server
|
|
||||||
|
|
||||||
:param ctx:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
try:
|
|
||||||
del self.tts_queues[ctx.guild.id]
|
|
||||||
await ctx.send('Queue dropped')
|
|
||||||
|
|
||||||
except KeyError:
|
|
||||||
await ctx.send('Failed on dropping queue')
|
|
||||||
|
|
||||||
@commands.command('exit')
|
@commands.command('exit')
|
||||||
async def leave_voice(self, ctx: Context):
|
async def leave_voice(self, ctx: Context):
|
||||||
"""
|
|
||||||
Disconnect bot from current channel, it also drop messages queue
|
|
||||||
|
|
||||||
:param ctx:
|
|
||||||
:return:
|
|
||||||
"""
|
|
||||||
if ctx.guild.voice_client is not None:
|
if ctx.guild.voice_client is not None:
|
||||||
await ctx.guild.voice_client.disconnect(force=False)
|
await ctx.guild.voice_client.disconnect(force=False)
|
||||||
await ctx.channel.send(f"Left voice channel")
|
await ctx.channel.send(f"Left voice channel")
|
||||||
@ -85,10 +64,6 @@ class TTSCore(commands.Cog, Observ.Observer):
|
|||||||
if voice_client is None:
|
if voice_client is None:
|
||||||
voice_client: discord.VoiceClient = await user_voice_state.channel.connect()
|
voice_client: discord.VoiceClient = await user_voice_state.channel.connect()
|
||||||
|
|
||||||
if user_voice_state.channel.id != voice_client.channel.id:
|
|
||||||
await message.channel.send('We are in different voice channels')
|
|
||||||
return
|
|
||||||
|
|
||||||
speaker: Speakers = self.speakers_adapter.get_speaker(message.guild.id, message.author.id)
|
speaker: Speakers = self.speakers_adapter.get_speaker(message.guild.id, message.author.id)
|
||||||
|
|
||||||
# check if message will fail on synthesis
|
# check if message will fail on synthesis
|
||||||
@ -126,21 +101,14 @@ class TTSCore(commands.Cog, Observ.Observer):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def queue_player(self, message: discord.Message):
|
def queue_player(self, message: discord.Message):
|
||||||
for sound_source in self.tts_queues[message.guild.id]:
|
|
||||||
if len(self.tts_queues[message.guild.id]) == 0:
|
|
||||||
return
|
|
||||||
|
|
||||||
voice_client: Optional[discord.VoiceClient] = message.guild.voice_client
|
voice_client: Optional[discord.VoiceClient] = message.guild.voice_client
|
||||||
if voice_client is None:
|
if voice_client is None:
|
||||||
# don't play anything and clear queue for whole guild
|
# don't play anything and clear queue for whole guild
|
||||||
break
|
del self.tts_queues[message.guild.id]
|
||||||
|
return
|
||||||
|
|
||||||
try:
|
for sound_source in self.tts_queues[message.guild.id]:
|
||||||
voice_client.play(sound_source)
|
voice_client.play(sound_source)
|
||||||
|
|
||||||
except discord.errors.ClientException: # Here we expect Not connected to voice
|
|
||||||
break
|
|
||||||
|
|
||||||
while voice_client.is_playing():
|
while voice_client.is_playing():
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user