Update torchlight_changes_unloze/torchlight3/Torchlight/Commands.py
This commit is contained in:
parent
5b75c36445
commit
5b20363e01
@ -1619,7 +1619,7 @@ class Stop(BaseCommand):
|
|||||||
|
|
||||||
def __init__(self, torchlight) -> None:
|
def __init__(self, torchlight) -> None:
|
||||||
super().__init__(torchlight)
|
super().__init__(torchlight)
|
||||||
self.Triggers = ["!stop"]
|
self.Triggers = ["!stop", ("!stop(", 6)]
|
||||||
self.Level = 0
|
self.Level = 0
|
||||||
|
|
||||||
async def _func(self, message: List[str], player) -> int:
|
async def _func(self, message: List[str], player) -> int:
|
||||||
@ -1628,12 +1628,25 @@ class Stop(BaseCommand):
|
|||||||
|
|
||||||
tl = self._get_torchlight()
|
tl = self._get_torchlight()
|
||||||
try:
|
try:
|
||||||
tl.AudioManager.Stop(player, message[1] if len(message) > 1 else "")
|
extra = message[1].strip() if len(message) > 1 else ""
|
||||||
tl.SayPrivate(player, "[STOP] Audio stopped")
|
if not extra and len(message) > 0:
|
||||||
|
match = re.match(r"^!stop\((.*?)\)$", message[0], flags=re.IGNORECASE)
|
||||||
|
if match:
|
||||||
|
extra = match.group(1).strip()
|
||||||
|
|
||||||
|
result = tl.AudioManager.Stop(player, extra)
|
||||||
|
|
||||||
|
if not result or result.get("matched", 0) == 0:
|
||||||
|
if extra:
|
||||||
|
tl.SayPrivate(player, f"[STOP] No active audio matched \"{extra}\".")
|
||||||
|
else:
|
||||||
|
tl.SayPrivate(player, "[STOP] No active audio to stop.")
|
||||||
|
elif result.get("stopped", 0) > 0:
|
||||||
|
tl.SayPrivate(player, f"[STOP] Stopped {result['stopped']} audio clip(s).")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.Logger.error(f"Stop command failed: {e}")
|
self.Logger.error(f"Stop command failed: {e}")
|
||||||
tl.SayPrivate(player, f"[STOP] Error: {str(e)}")
|
tl.SayPrivate(player, f"[STOP] Error: {str(e)}")
|
||||||
return True
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class VoteDisable(BaseCommand):
|
class VoteDisable(BaseCommand):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user