You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using a bot based on pycord during long conversations on discord. Sometimes (it occur very rarely tho) a nacl.exceptions.CryptoError is raised, and i have no way to handle it other than monkey patch
Reproduction Steps
Well it occur so rarely, it's hard to reproduce...
It happens often after the bot is being listening for a long time.
Minimal Reproducible Code
importdiscordfromdiscord.extimportcommands
...
classSTTSink(discord.sinks.WaveSink):
def__init__(self, discussion: Discussion, get_name: Callable, **kwargs):
self.discussion=discussionself.get_name=get_namesuper().__init__(**kwargs)
defwrite(self, data, user):
user=self.get_name(user)
self.discussion.audio_sample(user, data)
classSTTManager:
def__init__(self, vc: discord.VoiceClient, guild: discord.Guild):
self.guild=guildself.vc=vcself.transcription=Discussion()
self.sink=STTSink(discussion=self.transcription, get_name=self.get_name)
asyncdefon_finish(self, sink: discord.sinks, channel: discord.TextChannel, *args): # Our voice client already passes these in.ifsink.vc.recording: # If we're not recording, we're stopping the decoder.awaitsink.vc.stop_recording()
awaitsink.vc.disconnect() # Disconnect from the voice channel.print("Disconnected from voice channel.")
#await channel.send(f"Merci pour l'invitation !")defstart(self):
self.vc.start_recording(
self.sink,
self.on_finish,
self.vc.channel
)
self.transcription.start()
defstop(self):
print("Stopping recording...")
ifself.vc.recording:
self.vc.stop_recording()
else:
self.vc.decoder.stop()
print("Stopped recording.")
self.transcription.stop()
TOKEN=open("token.txt", "r").read().strip()
intents=discord.Intents.default()
# Privileged message content intentintents.message_content=True# Guild membersintents.members=Trueprint("loading bot...")
bot=commands.Bot(intents=intents, command_prefix="/")
connections= {}
@bot.eventasyncdefon_ready():
print("Bot is ready")
@bot.command()asyncdefstart(ctx: discord.ext.commands.Context):
voice=ctx.author.voice# Check if user is in a voice channelifnotvoice:
# Reply to the user with a messagereturnawaitctx.reply("Tu n'es pas dans un channel vocal !")
vc=awaitvoice.channel.connect()
manager=STTManager(vc, ctx.guild)
connections.update({ctx.guild.id: manager})
try:
manager.start()
exceptTranscriptionNotAvailableError:
manager.stop()
awaitvc.disconnect()
returnawaitctx.reply("Transcription not available")
awaitctx.reply(f"Starting transcription")
@bot.command()asyncdefstop(ctx):
ifctx.guild.idinconnections: # Check if the guild is in the cache.manager=connections[ctx.guild.id]
manager.stop()
delconnections[ctx.guild.id] # Remove the guild from the cache.else:
awaitctx.reply("Je ne suis pas en train d'enregistrer ici") # Respond with this if we aren't recording.if__name__=="__main__":
bot.run(TOKEN)
Expected Results
That it doesn't crash
Actual Results
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 814, in recv_audio
self.unpack_audio(data)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 696, in unpack_audio
data = RawData(data, self)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/sinks/core.py", line 112, in init
self.decrypted_data = getattr(self.client, f"decrypt{self.client.mode}")(
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 611, in _decrypt_xsalsa20_poly1305_lite
return self.strip_header_ext(box.decrypt(bytes(data), bytes(nonce)))
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/secret.py", line 149, in decrypt
plaintext = nacl.bindings.crypto_secretbox_open(
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/bindings/crypto_secretbox.py", line 79, in crypto_secretbox_open
ensure(
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/exceptions.py", line 88, in ensure
raise raising(*args)
nacl.exceptions.CryptoError: Decryption failed. Ciphertext failed verification
I am getting this too with voice chat bot when it tries to speak. It is happening quite a lot when it opens the text-to-speech generated .wav file and tries to broadcast it to voice chat. It doesn't happen every single time but it happens often, maybe one in 20 times.
` File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/lib/python3.9/site-packages/discord/voice_client.py", line 863, in recv_audio
self.unpack_audio(data)
File "/home/user/.local/lib/python3.9/site-packages/discord/voice_client.py", line 740, in unpack_audio
data = RawData(data, self)
File "/home/user/.local/lib/python3.9/site-packages/discord/sinks/core.py", line 113, in init
self.decrypted_data = getattr(self.client, f"decrypt{self.client.mode}")(
File "/home/user/.local/lib/python3.9/site-packages/discord/voice_client.py", line 611, in _decrypt_xsalsa20_poly1305_lite
return self.strip_header_ext(box.decrypt(bytes(data), bytes(nonce)))
File "/home/user/.local/lib/python3.9/site-packages/nacl/secret.py", line 149, in decrypt
plaintext = nacl.bindings.crypto_secretbox_open(
File "/home/user/.local/lib/python3.9/site-packages/nacl/bindings/crypto_secretbox.py", line 79, in crypto_secretbox_open
ensure(
File "/home/user/.local/lib/python3.9/site-packages/nacl/exceptions.py", line 88, in ensure
raise raising(*args)
Summary
I'm using a bot based on pycord during long conversations on discord. Sometimes (it occur very rarely tho) a nacl.exceptions.CryptoError is raised, and i have no way to handle it other than monkey patch
Reproduction Steps
Well it occur so rarely, it's hard to reproduce...
It happens often after the bot is being listening for a long time.
Minimal Reproducible Code
Expected Results
That it doesn't crash
Actual Results
Exception in thread Thread-4:
Traceback (most recent call last):
File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 814, in recv_audio
self.unpack_audio(data)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 696, in unpack_audio
data = RawData(data, self)
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/sinks/core.py", line 112, in init
self.decrypted_data = getattr(self.client, f"decrypt{self.client.mode}")(
File "/home/ubuntu/.local/lib/python3.9/site-packages/discord/voice_client.py", line 611, in _decrypt_xsalsa20_poly1305_lite
return self.strip_header_ext(box.decrypt(bytes(data), bytes(nonce)))
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/secret.py", line 149, in decrypt
plaintext = nacl.bindings.crypto_secretbox_open(
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/bindings/crypto_secretbox.py", line 79, in crypto_secretbox_open
ensure(
File "/home/ubuntu/.local/lib/python3.9/site-packages/nacl/exceptions.py", line 88, in ensure
raise raising(*args)
nacl.exceptions.CryptoError: Decryption failed. Ciphertext failed verification
Intents
intents = discord.Intents.default() # Privileged message content intent intents.message_content = True # Guild members intents.members = True
System Information
Checklist
Additional Context
No response
The text was updated successfully, but these errors were encountered: