From b2af59512234cc684fc2550d8b08cfabd936d5f9 Mon Sep 17 00:00:00 2001 From: Polish Hammer Date: Thu, 30 Oct 2025 16:59:05 +0100 Subject: [PATCH] Tag: 1.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Intermediate commits (oldest → newest): - fix of permissions - path fix - another approach - test - test2 - Test - Fix - Skip track - fix --- bot.py | 18 ++++++++++++++---- conjurer_musician/pl.config | 14 ++++++++++++++ conjurer_musician/radio_conjurer.liq | 6 +++--- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 conjurer_musician/pl.config diff --git a/bot.py b/bot.py index bcfeb01..e8ba1dc 100644 --- a/bot.py +++ b/bot.py @@ -136,6 +136,9 @@ MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = 15 MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30 FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000" +RADIO_HARBOR_ADDRESS = "http://192.168.1.15:54321" +SKIP_TRACK = "/skip" + GET_MP3 = "/mp3" SEND_MP3 = "/update_mp3" GET_PLAYLIST = "/get_music" @@ -1355,10 +1358,17 @@ async def skip_track(ctx): async with ctx.typing(): allowed = False for role in ctx.author.roles: - if role.name == "Thane": + if role.name in ("Thane","Jarl"): allowed = True if not allowed: await ctx.send("Łapy precz od radia") + else: + coroutine = asyncio.to_thread( + requests.get, + f"{RADIO_HARBOR_ADDRESS}{SKIP_TRACK}", + timeout=360, + ) + _ = await coroutine @client.hybrid_command( @@ -1370,13 +1380,13 @@ async def zrestartuj_radio(ctx): async with ctx.typing(): allowed = False for role in ctx.author.roles: - if role.name == "Thane": + if role.name in ("Thane","Jarl"): allowed = True if not allowed: await ctx.send("Łapy precz od radia") else: - subprocess.call(['sh', './restart_radio.sh']) - + retcode = subprocess.run("/home/pi/Conjurer/restart_radio.sh", shell=False, check = False, capture_output = True) + logger.info("Wynik: %s",retcode) @client.hybrid_command( name="dej_co_ze_spotifaja", diff --git a/conjurer_musician/pl.config b/conjurer_musician/pl.config new file mode 100644 index 0000000..0e2702b --- /dev/null +++ b/conjurer_musician/pl.config @@ -0,0 +1,14 @@ +$dodaj_do_ulubionych 100 nightwish +$dodaj_do_ulubionych 100 amon amarth +$dodaj_do_ulubionych 100 tactical sekt +$dodaj_do_ulubionych 100 lacuna coil +$dodaj_do_ulubionych 100 sefa +$dodaj_do_ulubionych 100 frenchcore +$dodaj_do_ulubionych 100 peacock +$dodaj_do_ulubionych 100 vavamuffin +$dodaj_do_ulubionych 100 abradab +$dodaj_do_ulubionych 100 eluveitie +$dodaj_do_ulubionych 100 youtube + +$dodaj_do_ulubionych 100 elyose +$dodaj_do_ulubionych 1 artisans du chaos diff --git a/conjurer_musician/radio_conjurer.liq b/conjurer_musician/radio_conjurer.liq index 68a1dfb..8db78e4 100644 --- a/conjurer_musician/radio_conjurer.liq +++ b/conjurer_musician/radio_conjurer.liq @@ -102,11 +102,11 @@ radio = fallback(id="switcher2", track_sensitive=false, [s, emergency]) # Set up an interactive control for skipping tracks p = interactive.bool("Skip track", false) -def http_skip(_): +def http_skip(~protocol, ~data, ~headers, uri)= radio.skip() - http.response(data="Skipped") + http.response(code=200,data="Skipped") end -harbor.http.register.simple(port=54321, "/skip", http_skip) +harbor.http.register(port=54321,method="GET","/skip", http_skip) # Function to process the request queue and skip the current track if requested