Update torchlight_changes_unloze/torchlight3/Torchlight/AudioManager.py

This commit is contained in:
Metroid_Skittles 2026-02-07 15:39:54 +01:00
parent fbd7a5112e
commit 5b75c36445

View File

@ -275,27 +275,40 @@ class AudioManager():
Level = 0
if player.Access:
Level = player.Access["level"]
StopLevel = self.Torchlight().Config["AntiSpam"]["StopLevel"]
ExtraFilter = extra.strip().lower() if isinstance(extra, str) else ""
Result = {"matched": 0, "stopped": 0, "pending": 0}
for AudioClip in self.AudioClips[:]:
if extra and not extra.lower() in AudioClip.Player.Name.lower():
if ExtraFilter and ExtraFilter not in AudioClip.Player.Name.lower():
continue
Result["matched"] += 1
if not Level or (Level < AudioClip.Level and Level < self.Torchlight().Config["AntiSpam"]["StopLevel"]):
# Always allow users to stop their own clip immediately.
requires_votes = player != AudioClip.Player and \
(not Level or (Level < AudioClip.Level and Level < StopLevel))
if requires_votes:
AudioClip.Stops.add(player.UserID)
if len(AudioClip.Stops) >= 3:
AudioClip.Stop()
Result["stopped"] += 1
self.Torchlight().SayPrivate(AudioClip.Player, "Your audio clip was stopped.")
if player != AudioClip.Player:
self.Torchlight().SayPrivate(player, "Stopped \"{0}\"({1}) audio clip.".format(AudioClip.Player.Name, AudioClip.Player.UserID))
else:
Result["pending"] += 1
self.Torchlight().SayPrivate(player, "This audio clip needs {0} more !stop's.".format(3 - len(AudioClip.Stops)))
else:
AudioClip.Stop()
Result["stopped"] += 1
self.Torchlight().SayPrivate(AudioClip.Player, "Your audio clip was stopped.")
if player != AudioClip.Player:
self.Torchlight().SayPrivate(player, "Stopped \"{0}\"({1}) audio clip.".format(AudioClip.Player.Name, AudioClip.Player.UserID))
return Result
def CreateAudioClip(self, player, uri, _type = AudioPlayerFactory.AUDIOPLAYER_FFMPEG):
Level = 0
if player.Access: