Radio restart serverside

This commit is contained in:
2024-06-19 17:46:38 +02:00
parent 8a99ee7c99
commit 0f49cb89a3
4 changed files with 61 additions and 11 deletions
+7
View File
@@ -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
+15 -11
View File
@@ -2,34 +2,38 @@
# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml # To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml
version: 0.1 version: 0.1
cli: cli:
version: 1.20.1 version: 1.22.2
# Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins) # Trunk provides extensibility via plugins. (https://docs.trunk.io/plugins)
plugins: plugins:
sources: sources:
- id: trunk - id: trunk
ref: v1.4.5 ref: v1.6.0
uri: https://github.com/trunk-io/plugins uri: https://github.com/trunk-io/plugins
# Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes) # Many linters and tools depend on runtimes - configure them here. (https://docs.trunk.io/runtimes)
runtimes: runtimes:
enabled: enabled:
- go@1.21.0
- node@18.12.1 - node@18.12.1
- python@3.10.8 - python@3.10.8
# This is the section where you manage your linters. (https://docs.trunk.io/check/configuration) # This is the section where you manage your linters. (https://docs.trunk.io/check/configuration)
lint: lint:
enabled: enabled:
- actionlint@1.6.27 - shellcheck@0.10.0
- bandit@1.7.8 - shfmt@3.6.0
- black@24.3.0 - taplo@0.8.1
- actionlint@1.7.1
- bandit@1.7.9
- black@24.4.2
- codespell - codespell
- checkov@3.2.48 - checkov@3.2.139
- git-diff-check - git-diff-check
- isort@5.13.2 - isort@5.13.2
- pylint - pylint
- markdownlint@0.39.0 - markdownlint@0.41.0
- prettier@3.2.5 - prettier@3.3.2
- ruff@0.3.4 - ruff@0.4.9
- trivy@0.50.1 - trivy@0.52.2
- trufflehog@3.71.0 - trufflehog@3.78.1
- yamllint@1.35.1 - yamllint@1.35.1
actions: actions:
disabled: disabled:
+32
View File
@@ -19,6 +19,7 @@ import shutil
import sys import sys
import threading import threading
import uuid import uuid
import subprocessS
from datetime import datetime from datetime import datetime
from logging import handlers from logging import handlers
from pathlib import Path, PurePath from pathlib import Path, PurePath
@@ -1345,6 +1346,37 @@ async def max_weight(lista):
# *=========================================== Define Commands # *=========================================== 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( @client.hybrid_command(
name="dej_co_ze_spotifaja", name="dej_co_ze_spotifaja",
+7
View File
@@ -102,6 +102,13 @@ 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(_):
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 # Function to process the request queue and skip the current track if requested
def check_skip() def check_skip()
if p() then if p() then