From f03605e4126f54068fee89ce5da57cfa4f6838c0 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:14:46 +0200 Subject: [PATCH 01/14] feat(myinstants): Add search menu --- config/config.json | 3 +- src/torchlight/CommandHandler.py | 15 +- src/torchlight/Commands.py | 239 +++++++++++++++++-------------- src/torchlight/MyInstants.py | 22 ++- 4 files changed, 156 insertions(+), 123 deletions(-) diff --git a/config/config.json b/config/config.json index 65da9af..18a1a4d 100644 --- a/config/config.json +++ b/config/config.json @@ -416,7 +416,8 @@ "porn", "algorithm", "loud" - ] + ], + "search_cmd": "!mis" }, "description": "Search MyInstants.com and play a random sound (e.g. !mi faah)." }, diff --git a/src/torchlight/CommandHandler.py b/src/torchlight/CommandHandler.py index 3ff1a35..64ad227 100644 --- a/src/torchlight/CommandHandler.py +++ b/src/torchlight/CommandHandler.py @@ -74,13 +74,13 @@ def Reload(self) -> None: # @profile async def HandleCommand(self, line: str, player: Player, from_menu: bool = False) -> int | None: - if from_menu: - message = line.split(sep=" ", maxsplit=2) # 2 because the !search command requires another arg for page - else: - message = line.split(sep=" ", maxsplit=1) + message = line.split(sep=" ", maxsplit=1) + if not message[0].startswith(("!", "#", "_", "$", "@", "%", "^", "&", "*", "-")): + return None - if len(message) < 2: + if not message[1]: message.append("") + message[1] = message[1].strip() if message[1] and self.torchlight.last_url: @@ -89,9 +89,6 @@ async def HandleCommand(self, line: str, player: Player, from_menu: bool = False level = player.admin.level - if not message[0].startswith(("!", "#", "_", "$", "@", "%", "^", "&", "*", "-")): - return None - ret_message: str | None = None ret: int | None = None for command in self.commands: @@ -130,7 +127,7 @@ async def HandleCommand(self, line: str, player: Player, from_menu: bool = False ret = ret_temp else: ret = await command._func(message, player) - if from_menu and command.__class__.__name__ == "VoiceTrigger" and ret: + if from_menu and command.__class__.__name__ in ("VoiceTrigger", "MyInstantsSearch") and ret: self.torchlight.SayChat(f"{{olive}}{player.name}: {{default}}{line}") except Exception as e: diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index 51faeaf..5c0b6c5 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -100,6 +100,46 @@ def check_disabled(self, player: Player) -> bool: return True return False + def get_menu_page_content( + self, + cmd: str, + search: str | None, + res: dict[str, str], + page: int, + max_items: int, + max_pages: int, + ) -> tuple[dict[str, str], int, int]: + start = (page - 1) * max_items if page else 0 + end = len(res) + if end > max: + end = start + max_items + + start = (page - 1) * max_items + end = start + max_items + command_items = dict(list(res.items())[start:end]) + + if not search: + line = cmd + else: + line = f"{cmd} {search}" + + items: dict[str, str] = {} + last_item_info: str = "" + last_item_display: str = "" + if page < max_pages: + last_item_info = f"{line} {page + 1}" + last_item_display = "> Next Page" + items[last_item_info] = last_item_display + if page > 1: + last_item_info = f"{line} {page - 1}" + last_item_display = "> Previous Page" + items[last_item_info] = last_item_display + + if last_item_info and last_item_display: + items[last_item_info] = last_item_display + "\n " + + return {**items, **command_items}, start, end + async def _func(self, message: list[str], player: Player) -> int: self.logger.debug(sys._getframe().f_code.co_name) return 0 @@ -751,52 +791,24 @@ def get_sound_path(self, player: Player, voice_trigger: str, trigger_number: str class Search(BaseCommand): - def get_menu_page_content( - self, - cmd: str, - search: str, - res: dict[str, str], - page: int, - max_items: int, - max_pages: int, - ) -> dict[str, str]: - start = (page - 1) * max_items - end = start + max_items - soundsItems = dict(list(res.items())[start:end]) - - if search == "": - line = cmd - else: - line = f"{cmd} {search}" - - items: dict[str, str] = {} - last_item_info: str = "" - last_item_display: str = "" - if page < max_pages: - last_item_info = f"{line} {page + 1}" - last_item_display = "> Next Page" - items[last_item_info] = last_item_display - if page > 1: - last_item_info = f"{line} {page - 1}" - last_item_display = "> Previous Page" - items[last_item_info] = last_item_display - - if last_item_info and last_item_display: - items[last_item_info] = last_item_display + "\n " - - return {**items, **soundsItems} - async def _func(self, message: list[str], player: Player) -> int: self.logger.debug(sys._getframe().f_code.co_name + " " + str(message)) - voice_trigger = message[1].lower() + # we need to specify the actual page and result if there is any. + page: int = 1 + voice_trigger: str = "" + voice_trigger_parts: list[str] = [] + for part in message: + if part == message[0]: + continue - page = 1 - if voice_trigger.isdigit(): - page = int(voice_trigger) - voice_trigger = "" - if len(message) > 2 and message[2].isdigit(): - page = int(message[2]) + if part.isdigit(): + page = int(part) + + voice_trigger_parts.append(part) + + if voice_trigger_parts: + voice_trigger = " ".join(voice_trigger_parts) res: dict[str, str] = {} @@ -827,20 +839,14 @@ async def _func(self, message: list[str], player: Player) -> int: if page < 1: page = 1 - start = (page - 1) * max if page else 0 - end = actual_count - - if actual_count > max: - end = start + max - - res = self.get_menu_page_content( - cmd=message[0], - search=voice_trigger, - res=res, - page=page, - max_items=max, - max_pages=max_pages, - ) + res, start, end = self.get_menu_page_content( + cmd=message[0], + search=voice_trigger, + res=res, + page=page, + max_items=max, + max_pages=max_pages, + ) title: str | None = None if voice_trigger: @@ -1432,12 +1438,16 @@ async def _func(self, message: list[str], player: Player) -> int: ) return 1 + search_only: bool = False + + command_config = self.get_config() + if "search_cmd" in command_config["parameters"] and message[0] == command_config["parameters"]["search_cmd"]: + search_only = True + search = message[1] if search: search = search.lower() - command_config = self.get_config() - keywords_banned: list[str] = [] if search and "parameters" in command_config and "keywords_banned" in command_config["parameters"]: @@ -1465,55 +1475,72 @@ async def _func(self, message: list[str], player: Player) -> int: if self.torchlight.config["VoiceServer"]["Proxy"]: proxy = self.torchlight.config["VoiceServer"]["Proxy"] - url = await asyncio.to_thread(myinstants_get_random_sound, search, proxy) + urls: dict[str, str] | str | None = None - if url is None: + urls = await asyncio.to_thread(myinstants_get_random_sound, search, proxy, search_only) + + if urls is None: if search: self.torchlight.SayPrivate(player, f"{{darkred}}[MyInstants]{{default}} No sound found for {search}") else: self.torchlight.SayPrivate(player, "{{darkred}}[MyInstants]{{default}} No sounds found") return 1 - audio_clip = self.audio_manager.AudioClip(player, url) - if not audio_clip: - return 1 - - self.torchlight.last_url = url - return audio_clip.Play() - - -class Help(BaseCommand): - def get_menu_page_content( - self, - cmd: str, - res: dict[str, str], - page: int, - max_items: int, - max_pages: int, - ) -> dict[str, str]: - start = (page - 1) * max_items - end = start + max_items - command_items = dict(list(res.items())[start:end]) - - line = cmd + if isinstance(urls, str): + audio_clip = self.audio_manager.AudioClip(player, urls) + if not audio_clip: + return 1 - items: dict[str, str] = {} - last_item_info: str = "" - last_item_display: str = "" - if page < max_pages: - last_item_info = f"{line} {page + 1}" - last_item_display = "> Next Page" - items[last_item_info] = last_item_display - if page > 1: - last_item_info = f"{line} {page - 1}" - last_item_display = "> Previous Page" - items[last_item_info] = last_item_display + self.torchlight.last_url = urls + return audio_clip.Play() + elif isinstance(urls, dict): + urls = {f"{message[0]} {k}": v for k, v in urls.items()} + max = 5 + if "parameters" in command_config and "max_results" in command_config["parameters"]: + max = command_config["parameters"]["max_results"] + + # we need to specify the actual page and result if there is any. + page: int = 1 + search_parts: list[str] = [] + for part in message: + if part == message[0]: + continue + + if part.isdigit(): + page = int(part) + + search_parts.append(part) + + if search_parts: + search = " ".join(search_parts) + + actual_count = len(urls) + max_pages = (actual_count + max - 1) // max + if page > max_pages: + page = max_pages + if page < 1: + page = 1 + + res, start, end = self.get_menu_page_content( + cmd=message[0], + search=search, + res=res, + page=page, + max_items=max, + max_pages=max_pages, + ) - if last_item_info and last_item_display: - items[last_item_info] = last_item_display + "\n " + title = "[Torchlight] [MyInstants] Search results" + (f" for {search}" if search else "") + title += f"\nDisplaying {start + 1}-{min(end, actual_count)} of {actual_count} results." + self.torchlight.CreateMenu( + player=player, + title=title, + options=res, + ) + return 0 - return {**items, **command_items} +class Help(BaseCommand): async def _func(self, message: list[str], player: Player) -> int: self.logger.debug(sys._getframe().f_code.co_name + " " + str(message)) @@ -1570,18 +1597,14 @@ async def _func(self, message: list[str], player: Player) -> int: if page < 1: page = 1 - start = (page - 1) * max if page else 0 - end = actual_count - - if actual_count > max: - end = start + max - res = self.get_menu_page_content( - cmd=message[0], - res=res, - page=page, - max_items=max, - max_pages=max_pages, - ) + res, start, end = self.get_menu_page_content( + cmd=message[0], + search=None, + res=res, + page=page, + max_items=max, + max_pages=max_pages, + ) title = "[Torchlight] Commands List" diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index ea092cd..c44db8a 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -10,7 +10,7 @@ HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"} -def myinstants_get_random_sound(query: str | None, proxy: str | None) -> str | None: +def myinstants_get_random_sound(query: str | None, proxy: str | None, search_only: bool = False) -> dict[str, str] | str | None: if not query: search_url = f"{MYINSTANTS_URL}/en/index/us/" else: @@ -36,17 +36,29 @@ def myinstants_get_random_sound(query: str | None, proxy: str | None) -> str | N soup = BeautifulSoup(r.text, "html.parser") buttons = soup.find_all("button", onclick=True) - mp3_paths = [] + if search_only: + mp3_paths: dict[str, str] = {} + else: + mp3_paths: list[str] = [] for btn in buttons: onclick_value = btn["onclick"] if "play(" in onclick_value: match = re.search(r"play\('(.+?\.mp3)'", onclick_value) if match: - mp3_paths.append(match.group(1)) + if isinstance(mp3_paths, list): + mp3_paths.append(match.group(1)) + elif isinstance(mp3_paths, dict): + name = btn["title"] + name = name.removeprefix("Play ") + mp3_paths[name] = name if not mp3_paths: return None - mp3_url = urljoin(MYINSTANTS_URL, secrets.choice(mp3_paths)) - return mp3_url + if isinstance(mp3_paths, list): + mp3_urls: str = urljoin(MYINSTANTS_URL, secrets.choice(mp3_paths)) + elif isinstance(mp3_paths, dict): + mp3_urls: dict[str, str] = mp3_paths + + return mp3_urls From 6a0af650e4e8987862d91beceb9d41dc59ffddb8 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:15:13 +0200 Subject: [PATCH 02/14] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 419029f..8a5df13 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,6 +16,7 @@ on: branches: - 'main' - 'master' + - 'main-dolly2' pull_request: branches: - master From abd99346906d4dac5830e4475ef5e08a58520605 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:26:12 +0200 Subject: [PATCH 03/14] some fixes --- src/torchlight/CommandHandler.py | 2 +- src/torchlight/Commands.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/torchlight/CommandHandler.py b/src/torchlight/CommandHandler.py index 64ad227..785bbe9 100644 --- a/src/torchlight/CommandHandler.py +++ b/src/torchlight/CommandHandler.py @@ -78,7 +78,7 @@ async def HandleCommand(self, line: str, player: Player, from_menu: bool = False if not message[0].startswith(("!", "#", "_", "$", "@", "%", "^", "&", "*", "-")): return None - if not message[1]: + if len(message) == 1 or not message[1]: message.append("") message[1] = message[1].strip() diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index 5c0b6c5..b7c4a8f 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -111,7 +111,7 @@ def get_menu_page_content( ) -> tuple[dict[str, str], int, int]: start = (page - 1) * max_items if page else 0 end = len(res) - if end > max: + if end > max_items: end = start + max_items start = (page - 1) * max_items @@ -1524,7 +1524,7 @@ async def _func(self, message: list[str], player: Player) -> int: res, start, end = self.get_menu_page_content( cmd=message[0], search=search, - res=res, + res=urls, page=page, max_items=max, max_pages=max_pages, From ccf603653a6dac05b34d846d4cb11f49fa9d4a58 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:42:14 +0200 Subject: [PATCH 04/14] final version hopefully --- src/torchlight/Commands.py | 18 +++++++++++++++--- src/torchlight/MyInstants.py | 1 + 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index b7c4a8f..1e2ea75 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -804,7 +804,8 @@ async def _func(self, message: list[str], player: Player) -> int: if part.isdigit(): page = int(part) - + break + voice_trigger_parts.append(part) if voice_trigger_parts: @@ -1439,7 +1440,6 @@ async def _func(self, message: list[str], player: Player) -> int: return 1 search_only: bool = False - command_config = self.get_config() if "search_cmd" in command_config["parameters"] and message[0] == command_config["parameters"]["search_cmd"]: search_only = True @@ -1494,7 +1494,18 @@ async def _func(self, message: list[str], player: Player) -> int: self.torchlight.last_url = urls return audio_clip.Play() elif isinstance(urls, dict): - urls = {f"{message[0]} {k}": v for k, v in urls.items()} + # get the play cmd + play_cmd: str = "" + for cmd in self.triggers: + if cmd == message[0]: + continue + cmd = play_cmd + break + + if not play_cmd: + return 0 + + urls = {f"{play_cmd} {k}": v for k, v in urls.items()} max = 5 if "parameters" in command_config and "max_results" in command_config["parameters"]: max = command_config["parameters"]["max_results"] @@ -1508,6 +1519,7 @@ async def _func(self, message: list[str], player: Player) -> int: if part.isdigit(): page = int(part) + break search_parts.append(part) diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index c44db8a..bfb58c4 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -51,6 +51,7 @@ def myinstants_get_random_sound(query: str | None, proxy: str | None, search_onl elif isinstance(mp3_paths, dict): name = btn["title"] name = name.removeprefix("Play ") + name = name.removesuffix(" sound") mp3_paths[name] = name if not mp3_paths: From 2af2ee069f8448f1a79cb2a365a9246f6e22104e Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:49:24 +0200 Subject: [PATCH 05/14] a --- src/torchlight/Commands.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index 1e2ea75..3e6c241 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -1499,7 +1499,7 @@ async def _func(self, message: list[str], player: Player) -> int: for cmd in self.triggers: if cmd == message[0]: continue - cmd = play_cmd + play_cmd = cmd break if not play_cmd: From 530b3544eef66d5129eb4d2b720ded8dada38498 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 09:59:16 +0200 Subject: [PATCH 06/14] final version hopefully --- config/config.json | 3 ++- src/torchlight/Commands.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config/config.json b/config/config.json index 18a1a4d..a1c947f 100644 --- a/config/config.json +++ b/config/config.json @@ -417,7 +417,8 @@ "algorithm", "loud" ], - "search_cmd": "!mis" + "search_cmd": "!mis", + "max_results": 10 }, "description": "Search MyInstants.com and play a random sound (e.g. !mi faah)." }, diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index 3e6c241..f45c69d 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -1506,7 +1506,7 @@ async def _func(self, message: list[str], player: Player) -> int: return 0 urls = {f"{play_cmd} {k}": v for k, v in urls.items()} - max = 5 + max = 10 if "parameters" in command_config and "max_results" in command_config["parameters"]: max = command_config["parameters"]["max_results"] @@ -1544,6 +1544,7 @@ async def _func(self, message: list[str], player: Player) -> int: title = "[Torchlight] [MyInstants] Search results" + (f" for {search}" if search else "") title += f"\nDisplaying {start + 1}-{min(end, actual_count)} of {actual_count} results." + title += f"Please wait {int(cooldown)}s before you click on any item." self.torchlight.CreateMenu( player=player, title=title, From 91f786a5f2ec80a869f4cd79b6245ab0d4617146 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:11:15 +0200 Subject: [PATCH 07/14] aa --- src/torchlight/Commands.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index f45c69d..f3c8511 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -811,6 +811,8 @@ async def _func(self, message: list[str], player: Player) -> int: if voice_trigger_parts: voice_trigger = " ".join(voice_trigger_parts) + self.logger.info(f"Voice trigger parts: {voice_trigger_parts}") + res: dict[str, str] = {} for key in self.trigger_manager.voice_triggers.keys(): @@ -1542,9 +1544,9 @@ async def _func(self, message: list[str], player: Player) -> int: max_pages=max_pages, ) - title = "[Torchlight] [MyInstants] Search results" + (f" for {search}" if search else "") + title = "[Torchlight] [MyInstants] Search results" + (f" for {search}." if search else ".") title += f"\nDisplaying {start + 1}-{min(end, actual_count)} of {actual_count} results." - title += f"Please wait {int(cooldown)}s before you click on any item." + title += f"\nPlease wait {int(cooldown)}s before you click on any item." self.torchlight.CreateMenu( player=player, title=title, From 7b3471e10c9060a03b2e51f31996b1ed1c91d27b Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:19:57 +0200 Subject: [PATCH 08/14] ok this is the last version --- src/torchlight/Commands.py | 33 ++++++++++++++------------------- src/torchlight/MyInstants.py | 4 ++++ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index f3c8511..b61595b 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -798,21 +798,17 @@ async def _func(self, message: list[str], player: Player) -> int: page: int = 1 voice_trigger: str = "" voice_trigger_parts: list[str] = [] - for part in message: - if part == message[0]: - continue - - if part.isdigit(): - page = int(part) - break - - voice_trigger_parts.append(part) + if message[1]: + parts = message[1].split(" ") + for part in parts: + if part.isdigit(): + page = int(part) + break + voice_trigger_parts.append(part) if voice_trigger_parts: voice_trigger = " ".join(voice_trigger_parts) - self.logger.info(f"Voice trigger parts: {voice_trigger_parts}") - res: dict[str, str] = {} for key in self.trigger_manager.voice_triggers.keys(): @@ -1515,15 +1511,14 @@ async def _func(self, message: list[str], player: Player) -> int: # we need to specify the actual page and result if there is any. page: int = 1 search_parts: list[str] = [] - for part in message: - if part == message[0]: - continue - - if part.isdigit(): - page = int(part) - break + if message[1]: + parts = message[1].split(" ") + for part in parts: + if part.isdigit(): + page = int(part) + break - search_parts.append(part) + search_parts.append(part) if search_parts: search = " ".join(search_parts) diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index bfb58c4..0fea190 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -52,6 +52,10 @@ def myinstants_get_random_sound(query: str | None, proxy: str | None, search_onl name = btn["title"] name = name.removeprefix("Play ") name = name.removesuffix(" sound") + # for secuirty purpose... + if len(name) > 20: + continue + mp3_paths[name] = name if not mp3_paths: From e74a29ea75d1c969dc68d2d20337f972064a16c8 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:27:15 +0200 Subject: [PATCH 09/14] ok i am sure this is the last --- src/torchlight/Commands.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index b61595b..55d550b 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -1442,9 +1442,22 @@ async def _func(self, message: list[str], player: Player) -> int: if "search_cmd" in command_config["parameters"] and message[0] == command_config["parameters"]["search_cmd"]: search_only = True - search = message[1] - if search: - search = search.lower() + # we need to specify the actual page and result if there is any. + page: int = 1 + search_parts: list[str] = [] + if message[1]: + parts = message[1].split(" ") + for part in parts: + if part.isdigit(): + page = int(part) + break + + search_parts.append(part) + + search: str | None = None + + if search_parts: + search = " ".join(search_parts) keywords_banned: list[str] = [] @@ -1508,21 +1521,6 @@ async def _func(self, message: list[str], player: Player) -> int: if "parameters" in command_config and "max_results" in command_config["parameters"]: max = command_config["parameters"]["max_results"] - # we need to specify the actual page and result if there is any. - page: int = 1 - search_parts: list[str] = [] - if message[1]: - parts = message[1].split(" ") - for part in parts: - if part.isdigit(): - page = int(part) - break - - search_parts.append(part) - - if search_parts: - search = " ".join(search_parts) - actual_count = len(urls) max_pages = (actual_count + max - 1) // max if page > max_pages: From 6cbe8e6a5377321c6629ad3f07c347c7749bb3ba Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:36:02 +0200 Subject: [PATCH 10/14] Update ci.yml --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8a5df13..419029f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,6 @@ on: branches: - 'main' - 'master' - - 'main-dolly2' pull_request: branches: - master From 0fc4e3599d221f933a8480a16a3d6999e85f5d9a Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:39:02 +0200 Subject: [PATCH 11/14] ok ruff --- src/torchlight/MyInstants.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index 0fea190..ce50cb6 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -10,7 +10,11 @@ HEADERS = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"} -def myinstants_get_random_sound(query: str | None, proxy: str | None, search_only: bool = False) -> dict[str, str] | str | None: +def myinstants_get_random_sound( + query: str | None, + proxy: str | None, + search_only: bool = False, + ) -> dict[str, str] | str | None: if not query: search_url = f"{MYINSTANTS_URL}/en/index/us/" else: From aa6dabbee22945bfe101a9997782780334d827a8 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:40:15 +0200 Subject: [PATCH 12/14] ok ruff 2 --- src/torchlight/MyInstants.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index ce50cb6..5c82e1e 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -11,10 +11,10 @@ def myinstants_get_random_sound( - query: str | None, - proxy: str | None, - search_only: bool = False, - ) -> dict[str, str] | str | None: + query: str | None, + proxy: str | None, + search_only: bool = False, +) -> dict[str, str] | str | None: if not query: search_url = f"{MYINSTANTS_URL}/en/index/us/" else: From 4938ba74d2938fafcde83eac347e40373fcfcba8 Mon Sep 17 00:00:00 2001 From: Dolly132 <109222243+Dolly132@users.noreply.github.com> Date: Tue, 24 Mar 2026 10:46:40 +0200 Subject: [PATCH 13/14] mypy hello --- src/torchlight/Commands.py | 2 +- src/torchlight/MyInstants.py | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/torchlight/Commands.py b/src/torchlight/Commands.py index 55d550b..87e0281 100644 --- a/src/torchlight/Commands.py +++ b/src/torchlight/Commands.py @@ -1510,7 +1510,7 @@ async def _func(self, message: list[str], player: Player) -> int: for cmd in self.triggers: if cmd == message[0]: continue - play_cmd = cmd + play_cmd = cast(str, cmd) break if not play_cmd: diff --git a/src/torchlight/MyInstants.py b/src/torchlight/MyInstants.py index 5c82e1e..c4936f1 100644 --- a/src/torchlight/MyInstants.py +++ b/src/torchlight/MyInstants.py @@ -40,10 +40,11 @@ def myinstants_get_random_sound( soup = BeautifulSoup(r.text, "html.parser") buttons = soup.find_all("button", onclick=True) + mp3_paths: dict[str, str] | list[str] if search_only: - mp3_paths: dict[str, str] = {} + mp3_paths = {} else: - mp3_paths: list[str] = [] + mp3_paths = [] for btn in buttons: onclick_value = btn["onclick"] @@ -65,9 +66,10 @@ def myinstants_get_random_sound( if not mp3_paths: return None + mp3_urls: str | dict[str, str] if isinstance(mp3_paths, list): - mp3_urls: str = urljoin(MYINSTANTS_URL, secrets.choice(mp3_paths)) + mp3_urls = urljoin(MYINSTANTS_URL, secrets.choice(mp3_paths)) elif isinstance(mp3_paths, dict): - mp3_urls: dict[str, str] = mp3_paths + mp3_urls = mp3_paths return mp3_urls From a19fbb2d4c7e80a9f80e55c25c6c66a733481cde Mon Sep 17 00:00:00 2001 From: Rushaway Date: Thu, 26 Mar 2026 10:29:43 +0100 Subject: [PATCH 14/14] Bump version to 1.6.0 --- src/torchlight/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/torchlight/__init__.py b/src/torchlight/__init__.py index 0f228f2..e4adfb8 100644 --- a/src/torchlight/__init__.py +++ b/src/torchlight/__init__.py @@ -1 +1 @@ -__version__ = "1.5.1" +__version__ = "1.6.0"