From 0f49cb89a3be3e36f9ba6143b1c85f95eccbb27b Mon Sep 17 00:00:00 2001 From: Migatu Date: Wed, 19 Jun 2024 17:46:38 +0200 Subject: [PATCH] Radio restart serverside --- .trunk/configs/.shellcheckrc | 7 ++++++ .trunk/trunk.yaml | 26 ++++++++++++---------- bot.py | 32 ++++++++++++++++++++++++++++ conjurer_musician/radio_conjurer.liq | 7 ++++++ 4 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 .trunk/configs/.shellcheckrc diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 0000000..8c7b1ad --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index 4a7abcb..1a92937 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -2,34 +2,38 @@ # To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml version: 0.1 cli: - version: 1.20.1 + version: 1.22.2 # Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) plugins: sources: - id: trunk - ref: v1.4.5 + ref: v1.6.0 uri: https://github.com/trunk-io/plugins # Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) runtimes: enabled: + - go@1.21.0 - node@18.12.1 - python@3.10.8 # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) lint: enabled: - - actionlint@1.6.27 - - bandit@1.7.8 - - black@24.3.0 + - shellcheck@0.10.0 + - shfmt@3.6.0 + - taplo@0.8.1 + - actionlint@1.7.1 + - bandit@1.7.9 + - black@24.4.2 - codespell - - checkov@3.2.48 + - checkov@3.2.139 - git-diff-check - isort@5.13.2 - pylint - - markdownlint@0.39.0 - - prettier@3.2.5 - - ruff@0.3.4 - - trivy@0.50.1 - - trufflehog@3.71.0 + - markdownlint@0.41.0 + - prettier@3.3.2 + - ruff@0.4.9 + - trivy@0.52.2 + - trufflehog@3.78.1 - yamllint@1.35.1 actions: disabled: diff --git a/bot.py b/bot.py index 1789781..ab8aea5 100644 --- a/bot.py +++ b/bot.py @@ -19,6 +19,7 @@ import shutil import sys import threading import uuid +import subprocessS from datetime import datetime from logging import handlers from pathlib import Path, PurePath @@ -1345,6 +1346,37 @@ async def max_weight(lista): # *=========================================== Define Commands +@client.hybrid_command( + name="skip_track", + description="Przeskocz kawałek w radiu", + guild=discord.Object(id=664789470779932693), +) +async def skip_track(ctx): + with ctx.typing(): + allowed = False + for role in ctx.author.roles: + if role.name == "Thane": + allowed = True + if not allowed: + await ctx.send("Łapy precz od radia") + + +@client.hybrid_command( + name="zrestartuj_radio", + description="Komenda ktora uruchamia radio ponownie jakby się zawiesiło", + guild=discord.Object(id=664789470779932693), +) +async def zrestartuj_radio(ctx): + with ctx.typing(): + allowed = False + for role in ctx.author.roles: + if role.name == "Thane": + allowed = True + if not allowed: + await ctx.send("Łapy precz od radia") + else: + subprocess.call(['sh', './restart_radio.sh']) + @client.hybrid_command( name="dej_co_ze_spotifaja", diff --git a/conjurer_musician/radio_conjurer.liq b/conjurer_musician/radio_conjurer.liq index dbd8695..68a1dfb 100644 --- a/conjurer_musician/radio_conjurer.liq +++ b/conjurer_musician/radio_conjurer.liq @@ -102,6 +102,13 @@ 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(_): + radio.skip() + http.response(data="Skipped") +end +harbor.http.register.simple(port=54321, "/skip", http_skip) + + # Function to process the request queue and skip the current track if requested def check_skip() if p() then