From 1ebd58b8aceae1334ccf652b5878bd725ff976eb Mon Sep 17 00:00:00 2001 From: mtuszowski Date: Fri, 2 Aug 2024 11:43:38 +0200 Subject: [PATCH] UPdate for music tracker --- bot.py | 22 +++++++++++++++++++++- communication_subroutine.py | 12 ++++++------ conjurer_musician/conjurer_musician.py | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/bot.py b/bot.py index 6706ded..1379683 100644 --- a/bot.py +++ b/bot.py @@ -47,6 +47,7 @@ from communication_subroutine import ( OUT_COMM_Q, QueryControl, comm_subroutine, + PREPPED_TRACKS, ) from spotify_dl import spotify from spotify_dl import youtube as youtube_download @@ -2524,6 +2525,25 @@ async def krecimy_pornola(ctx): else: ctx.reply("Jak ładnie szefa poprosisz.") +@client.hybrid_command( + name="co_na_plejliscie_wariacie", + description="Wyswietl kawalki ktore sa na pocztku list radia", + guild=discord.Object(id=664789470779932693), +) +async def co_na_plejliscie_wariacie(ctx): + """ + Download a music number from youtube. + + :param ctx: ctx stands for "context" and is a parameter commonly used in Discord.py commands. It + represents the context in which the command was invoked, including information such as the message, + the channel, the server, and the user who invoked the command. It allows the command to interact + with the Discord API and + """ + await ctx.send("Dej mnie chwilkę") + async with ctx.typing: + logger.info("plejlista") + logger.info(PREPPED_TRACKS) + await ctx.send(f"Didżej Hammer i jego sztuczna inteligencja (||he he||) prezentują - na liście priorytetowej {PREPPED_TRACKS["priority"]}, na liście hitów obecnie czeka kawałek {PREPPED_TRACKS["hit"]}, na liście wszystkich kawałków {PREPPED_TRACKS["all"]} zaś najświeższym zamówieniem od słuchaczy jest {PREPPED_TRACKS["requests"]}. Z kolei jingiel to: {PREPPED_TRACKS["jingles"]}") # *================================== Run if __name__ == "__main__": @@ -2531,7 +2551,7 @@ if __name__ == "__main__": threads = [] logger.info("Starting discord bot: Creating threads") threads.append(threading.Thread(target=client.run, args=(TOKEN,))) - threads.append(threading.Thread(target=comm_subroutine, args=(logger,))) + threads.append(threading.Thread(target=comm_subroutine)) logger.info("Starting discord bot: Starting threads") WRK_CNT = 0 for worker in threads: diff --git a/communication_subroutine.py b/communication_subroutine.py index ef4302b..553fca2 100644 --- a/communication_subroutine.py +++ b/communication_subroutine.py @@ -13,11 +13,11 @@ IN_COMM_Q = Queue() awaiting_q = [] incoming_q = Queue() app = Flask(__name__) -prepped_tracks = { +PREPPED_TRACKS = { "requests" : "", - "hits" : "", + "hit" : "", "all": "", - "prio":"", + "priority":"", "jingles":"" } @@ -45,6 +45,7 @@ def log_radio_tracks(): logger.info(request) record = json.loads(request.data) logger.info(record) + PREPPED_TRACKS[record[0]] = record[1] logger.info("DATA RECEIVED") return jsonify("SUCCESS") @@ -145,7 +146,7 @@ def scan_incoming(): time.sleep(1) -def comm_subroutine(logger): +def comm_subroutine(): """ The `comm_subroutine` function starts multiple threads to run different tasks concurrently. @@ -169,5 +170,4 @@ def comm_subroutine(logger): worker.join() if __name__ == "__main__": - logging_client = logging.getLogger(__name__) - comm_subroutine(logging_client) + comm_subroutine() diff --git a/conjurer_musician/conjurer_musician.py b/conjurer_musician/conjurer_musician.py index 8965df1..aded752 100644 --- a/conjurer_musician/conjurer_musician.py +++ b/conjurer_musician/conjurer_musician.py @@ -126,7 +126,7 @@ def scan_tracks(): logger.info(line) # already has newline result = ["priority", line] elif re.match(".*hit.*", line): - logger.info("priority") + logger.info("hit") logger.info(line) # already has newline result = ["hit", line] elif re.match(".*all_playlist.*", line):