Work ongoing - rich presence and ai assistant

This commit is contained in:
2024-11-14 19:53:40 +01:00
parent 14b9a50f51
commit b15c2f06b8
5 changed files with 79 additions and 53 deletions
+27 -3
View File
@@ -5,6 +5,7 @@ import uuid
from pathlib import Path, PurePath
from sys import platform
import discord
import requests
import yt_dlp
@@ -34,7 +35,7 @@ class MusicFileList(object):
self.logger = uplogger
self.logger.info("Created Playlist organizer class")
def refresh_file_list(self):
async def refresh_file_list(self):
"""
The `refresh_file_list` function attempts to connect to a file service to retrieve a list of music
files, and if unsuccessful, it populates the list by scanning a local directory for .mp3 files.
@@ -53,6 +54,28 @@ class MusicFileList(object):
self.file_service_active = False
self.logger.error(e.strerror)
self.logger.error("Service Unavailable")
finally:
if self.file_service_active:
status = discord.Status.online
# radio_hardkor = discord.Activity(
# name = "Radio Hammer/Radio Conjurer/Wolne Bałuity Kurwa",
# url = "http://95.175.16.246:666/mp3-stream",
# type = discord.ActivityType.streaming,
# platform = "Liquidsoap+RaspberyPi+RolandSeratoDJ202",
# state = "Where the f*** is the DJ booth?",
# details= "This Is Radio Hardkor based in Wolne Księstwo Bałuty, the best pirate radiostation on both sides of Łódka river",
# buttons= [{"label":"RADIO", "url":"http://95.175.16.246:666/mp3-stream"}],
# assets= {"large_image": "fuckery.jpg", "large_text":"Fuckewry", "small_image":"willowisp.png", "small_text":"Hi!"}
# )
radio_hardkor = discord.Streaming(
name="Radio Hardkor", url="http://95.175.16.246:666/mp3-stream"
)
await self.bot.change_presence(status=status, activity=radio_hardkor)
else:
await self.bot.change_presence(
activity=discord.Game(name="Axe Throwing Darts")
)
def get_file_list(self):
"""
@@ -150,10 +173,11 @@ async def get_file(ctx, source, link):
elif source == "Youtube":
link_ok = False
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
if re.match(pat, link) and (re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)):
if re.match(pat, link) and (
re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)
):
link_ok = True
if link_ok:
dir_path = ""
file_list = []