diff --git a/plugins/read/read.py b/plugins/read/read.py index 5355e53d759412b44158ce35bee6784a4ad83e28..d4ca1cf5651c7f508573d13809f95d369b62245c 100644 --- a/plugins/read/read.py +++ b/plugins/read/read.py @@ -34,19 +34,11 @@ def read(bot, context, args): 'per': 4, 'spd': config.SPEED }) - - tmpdir = tempfile.mkdtemp() - audiopath = os.path.join(tmpdir, "audio.mp3") - + if not isinstance(voice, dict): - with open(audiopath, "wb") as file: - file.write(voice) + result = str(base64.encodebytes(voice).decode().replace("\n", "")) + bot.send(context, "[CQ:record,file=base64://{}]".format(result)) else: bot.send(context, "转换语音失败,请检查是否含有非法字符") - return - - result = "" - with open(audiopath, "rb") as file: - result = base64.encodebytes(file.read()).decode().replace("\n", "") - bot.send(context, "[CQ:record,file=base64://{}]".format(result)) + threading.Thread(target=handle).start()