mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Skip track
This commit is contained in:
@@ -136,6 +136,9 @@ MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = 15
|
|||||||
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
|
MUZYKA_MOJEGO_LUDU_PLAJLISTA = 30
|
||||||
|
|
||||||
FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000"
|
FILE_SERVICE_ADDRESS = "http://192.168.1.15:5000"
|
||||||
|
RADIO_HARBOR_ADDRESS = "http://192.168.1.15:54321"
|
||||||
|
SKIP_TRACK = "/skip"
|
||||||
|
|
||||||
GET_MP3 = "/mp3"
|
GET_MP3 = "/mp3"
|
||||||
SEND_MP3 = "/update_mp3"
|
SEND_MP3 = "/update_mp3"
|
||||||
GET_PLAYLIST = "/get_music"
|
GET_PLAYLIST = "/get_music"
|
||||||
@@ -1355,10 +1358,17 @@ async def skip_track(ctx):
|
|||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
allowed = False
|
allowed = False
|
||||||
for role in ctx.author.roles:
|
for role in ctx.author.roles:
|
||||||
if role.name == "Thane" or role.name == "Jarl":
|
if role.name in ("Thane","Jarl"):
|
||||||
allowed = True
|
allowed = True
|
||||||
if not allowed:
|
if not allowed:
|
||||||
await ctx.send("Łapy precz od radia")
|
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(
|
@client.hybrid_command(
|
||||||
@@ -1370,13 +1380,13 @@ async def zrestartuj_radio(ctx):
|
|||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
allowed = False
|
allowed = False
|
||||||
for role in ctx.author.roles:
|
for role in ctx.author.roles:
|
||||||
if role.name == "Thane" or role.name == "Jarl":
|
if role.name in ("Thane","Jarl"):
|
||||||
allowed = True
|
allowed = True
|
||||||
if not allowed:
|
if not allowed:
|
||||||
await ctx.send("Łapy precz od radia")
|
await ctx.send("Łapy precz od radia")
|
||||||
else:
|
else:
|
||||||
retcode = subprocess.run("/home/pi/Conjurer/restart_radio.sh", shell=True, capture_output = True)
|
retcode = subprocess.run("/home/pi/Conjurer/restart_radio.sh", shell=False, check = True, capture_output = True)
|
||||||
logger.info(f'Wynik {retcode}')
|
logger.info("Wynik: %s",retcode)
|
||||||
|
|
||||||
@client.hybrid_command(
|
@client.hybrid_command(
|
||||||
name="dej_co_ze_spotifaja",
|
name="dej_co_ze_spotifaja",
|
||||||
|
|||||||
@@ -102,11 +102,11 @@ radio = fallback(id="switcher2", track_sensitive=false, [s, emergency])
|
|||||||
# Set up an interactive control for skipping tracks
|
# Set up an interactive control for skipping tracks
|
||||||
p = interactive.bool("Skip track", false)
|
p = interactive.bool("Skip track", false)
|
||||||
|
|
||||||
def http_skip(_):
|
def http_skip(~protocol, ~data, ~headers, uri)=
|
||||||
radio.skip()
|
radio.skip()
|
||||||
http.response(data="Skipped")
|
http.response(code=200,data="Skipped")
|
||||||
end
|
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
|
# Function to process the request queue and skip the current track if requested
|
||||||
|
|||||||
Reference in New Issue
Block a user