fix: duck on audio packets only, remove unmute-based ducking
Instant ducking is purely packet-based now -- _instant_duck() fires on _on_sound_received, not on user state changes. Removes the USERUPDATED callback that preemptively ducked on unmute.
This commit is contained in:
@@ -20,7 +20,6 @@ from pymumble_py3.constants import (
|
||||
PYMUMBLE_CLBK_DISCONNECTED,
|
||||
PYMUMBLE_CLBK_SOUNDRECEIVED,
|
||||
PYMUMBLE_CLBK_TEXTMESSAGERECEIVED,
|
||||
PYMUMBLE_CLBK_USERUPDATED,
|
||||
)
|
||||
|
||||
from derp.bot import _TokenBucket
|
||||
@@ -218,10 +217,6 @@ class MumbleBot:
|
||||
PYMUMBLE_CLBK_SOUNDRECEIVED,
|
||||
self._on_sound_received,
|
||||
)
|
||||
self._mumble.callbacks.set_callback(
|
||||
PYMUMBLE_CLBK_USERUPDATED,
|
||||
self._on_user_updated,
|
||||
)
|
||||
self._mumble.set_receive_sound(self._receive_sound)
|
||||
self._mumble.start()
|
||||
self._mumble.is_ready()
|
||||
@@ -326,26 +321,6 @@ class MumbleBot:
|
||||
except Exception:
|
||||
log.exception("mumble: sound listener error")
|
||||
|
||||
def _on_user_updated(self, user, actions) -> None:
|
||||
"""Callback from pymumble thread: user state changed.
|
||||
|
||||
When a non-bot user unmutes, update ``_voice_ts`` and snap duck
|
||||
volume to floor immediately.
|
||||
"""
|
||||
if "self_mute" not in actions:
|
||||
return
|
||||
name = user["name"] if isinstance(user, dict) else None
|
||||
bots = getattr(self.registry, "_bots", {})
|
||||
if name and name in bots:
|
||||
return
|
||||
# Only care about unmute (self_mute going False)
|
||||
if user.get("self_mute", True):
|
||||
return
|
||||
log.info("mumble: %s unmuted, preemptive duck", name or "?")
|
||||
self._last_voice_ts = time.monotonic()
|
||||
self.registry._voice_ts = self._last_voice_ts
|
||||
self._instant_duck()
|
||||
|
||||
def _on_text_message(self, message) -> None:
|
||||
"""Callback from pymumble thread: text message received.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user