فهرست منبع

add typing notification

subDesTagesMitExtraKaese 2 سال پیش
والد
کامیت
b76ef013c1
1فایلهای تغییر یافته به همراه3 افزوده شده و 3 حذف شده
  1. 3 3
      main.py

+ 3 - 3
main.py

@@ -27,19 +27,19 @@ bot = botlib.Bot(creds, config)
 
 @bot.listener.on_custom_event(nio.RoomMessageAudio)
 async def on_audio_message(room, event):
-  print(event.sender, event.body, event.url)
+  print(room.machine_name, event.sender, event.body, event.url)
   match = botlib.MessageMatch(room, event, bot)
   if match.is_not_from_this_bot():
-    bot.async_client.room_typing(room, )
+    await bot.async_client.room_typing(room.machine_name, True, timeout=120000)
     url = urlparse(event.url)
     response = await bot.async_client.download(server_name=url.netloc, media_id=url.path[1:])
     print(response)
     with tempfile.NamedTemporaryFile("w+b") as file:
       file.write(response.body)
       file.flush()
-      print(file.name)
       result = model.transcribe(file.name)
 
+    await bot.async_client.room_typing(room.machine_name, False)
     await bot.api.send_text_message(
       room_id=room.room_id,
       message=f"Transcription of {response.filename}: {result['text']}",