From 9cec4f1f14777dcccb6cb95f6d57ec9984a7d99c Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 4 Oct 2026 20:11:05 +0200 Subject: [PATCH] fix: set accepted user agent for APInex STT --- bot.py | 1 + tests/test_voice_stt.py | 1 + 2 files changed, 2 insertions(+) diff --git a/bot.py b/bot.py index d166532..42947fd 100644 --- a/bot.py +++ b/bot.py @@ -52,6 +52,7 @@ async def transcribe_audio(audio: bytes, content_type: str, api_key: str) -> str "Authorization": f"Bearer {api_key}", "Content-Type": content_type, "Accept": "application/json", + "User-Agent": "Mozilla/5.0 (compatible; SocialPostWriterBot/1.0)", } async with aiohttp.ClientSession(timeout=timeout) as session: async with session.post(APINEX_STT_URL, data=audio, headers=headers) as response: diff --git a/tests/test_voice_stt.py b/tests/test_voice_stt.py index a43019e..b762040 100644 --- a/tests/test_voice_stt.py +++ b/tests/test_voice_stt.py @@ -61,6 +61,7 @@ class VoiceSttTests(unittest.IsolatedAsyncioTestCase): self.assertEqual(kwargs["data"], b"ogg-data") self.assertEqual(kwargs["headers"]["Content-Type"], "audio/ogg") self.assertEqual(kwargs["headers"]["Authorization"], "Bearer not-logged") + self.assertIn("Mozilla/5.0", kwargs["headers"]["User-Agent"]) async def test_transcribe_raises_on_api_error(self): fake_session = FakeClientSession(FakeResponse(401, {}))