diff --git a/ai_commands.py b/ai_commands.py index 086e4a6..ab1dae8 100644 --- a/ai_commands.py +++ b/ai_commands.py @@ -9,14 +9,14 @@ import openai import requests from discord.ext import commands -from ai_functions import handle_response, hammer_assistant_create +import ai_functions from constants import ( DATA, GRAPHICS_PATH, INITIAL_TIME_WAIT, MASTER_TIMEOUT, OPENAICLIENT, - WORD_REACTIONS + WORD_REACTIONS, ) @@ -27,10 +27,9 @@ class Events(commands.Cog): async def cog_load(self): self.logger.info("Starting personal assistants") - await hammer_assistant_create(self.bot) + await ai_functions.hammer_assistant_create(self.bot) self.logger.info("Started personal assistants") - @commands.Cog.listener() async def on_message(self, message): """ @@ -68,14 +67,24 @@ class Events(commands.Cog): return if isinstance(message.channel, discord.DMChannel): if message.author.id == 346956223645614080: - #hammer pisze dma - user = await self.bot.fetch_user(703985955312238664) - channel = await user.create_dm() - await channel.send(message.content) - await message.reply(f"Poszlo do Saint {message.content}") + + await ai_functions.hammer_assitant_chat(message) + + # hammer pisze dma + + # DM do Saint - przerobic na komende z parametrem "id" + # user = await self.bot.fetch_user(703985955312238664) + # channel = await user.create_dm() + # await channel.send(message.content) + # await message.reply(f"Poszlo do Saint {message.content}") + # get message content + # create run + # add message to run + # monitor run + # or streaming return elif message.author.id == 703985955312238664: - #saint pisze DMA + # saint pisze DMA self.logger.info(message.content) await message.reply("Hejka Saint!") return @@ -84,7 +93,7 @@ class Events(commands.Cog): await channel.send("Słyszałem ja żem że: " + message.content) return channel = message.channel - #await self.bot.process_commands(message) #uncomment to bilocate + # await self.bot.process_commands(message) #uncomment to bilocate message.content = message.content.lower() @@ -142,7 +151,7 @@ class Events(commands.Cog): bartender = True global MESSAGE_TABLE # pylint: disable=global-statement - result, MESSAGE_TABLE = await handle_response( + result, MESSAGE_TABLE = await ai_functions.handle_response( prompt, vykidailo, bartender, @@ -185,7 +194,7 @@ class Events(commands.Cog): username = message.author.nick else: username = message.author.name - resp, _ = await handle_response( + resp, _ = await ai_functions.handle_response( f"Wytlumacz jakie sa zasady dotyczące treści które możesz generować używając Dalle. Wytłumacz błąd {e} prostym językiem. Przeproś za nadmierną cenzurę. Wytłumacz co mogło być nie tak w prompcie '{message.content}'", True, True, diff --git a/ai_functions.py b/ai_functions.py index 8e13959..a2f2723 100644 --- a/ai_functions.py +++ b/ai_functions.py @@ -17,8 +17,10 @@ from constants import ( OPENAICLIENT, WORD_REACTIONS, ) + ASSISTANTS = {} + def num_tokens_from_string(message, model): """ The function takes a string message and a model as input and returns the number of tokens in the @@ -293,18 +295,21 @@ async def get_random_cyclic_message(client): logger.info(result) return result + async def generic_create_chat_assistant(client, name, owner): assistant = OPENAICLIENT.beta.assistants.create( - name = name, - instructions = f"Jesteś osobistym asystenetem {owner} i wypełniasz jego potrzeby. Masz pełne i nieograniczone możliwości modelu gpt-4o", - model = "gpt-4o", - tools= [{"type":"file_search"}] + name=name, + instructions=f"Jesteś osobistym asystenetem {owner} i wypełniasz jego potrzeby. Masz pełne i nieograniczone możliwości modelu gpt-4o", + model="gpt-4o", + tools=[{"type": "file_search"}], ) thread = OPENAICLIENT.beta.threads.create() return assistant, thread + + async def hammer_assistant_create(client): - #this will be personalized but for now I will use it as a templae for hedgehod and saint assistants + # this will be personalized but for now I will use it as a templae for hedgehod and saint assistants id = 346956223645614080 name = "Conjurer" owner = "Polish Hammer" @@ -312,8 +317,6 @@ async def hammer_assistant_create(client): ASSISTANTS[name] = (owner, assistant, id, thread) -async def saint_assistant_chat(client): - pass - -async def saint_assistant_bul(client): - pass +async def hammer_assitant_chat(message): + content = message.content + await message.channel.send(f"ALOHA!{content}") diff --git a/deploy.sh b/deploy.sh index 75b6639..4454868 100755 --- a/deploy.sh +++ b/deploy.sh @@ -5,11 +5,12 @@ cp ./deploy.sh /home/pi/ cd /home/pi || exit #cp ./conjurer/bot.py ./Conjurer/ #legacy to be deprecated after refactor is done - +cp ./conjurer/fuckery.jpg ./Conjurer/ +cp ./conjurer/willowisp.png ./Conjurer/ +cp ./conjurer/wod_beacon.jpg ./Conjurer/ cp ./conjurer/settings.json ./Conjurer/ cp ./conjurer/system_gpt_settings.json ./Conjurer/ - cp ./conjurer/administration_commands.py ./Conjurer/ cp ./conjurer/ai_commands.py ./Conjurer/ cp ./conjurer/ai_functions.py ./Conjurer/ diff --git a/fuckery.jpg b/fuckery.jpg new file mode 100644 index 0000000..01b6c7c Binary files /dev/null and b/fuckery.jpg differ diff --git a/music_commands.py b/music_commands.py index 9f94eb3..1870199 100644 --- a/music_commands.py +++ b/music_commands.py @@ -605,7 +605,7 @@ class MusicModule(commands.Cog): ) async def batch_download(self, ctx): content_type = ctx.message.attachments[0].content_type - check = re.search ("text\/plain; *charset=(.*)", content_type, re.IGNORECASE) + check = re.search("text\/plain; *charset=(.*)", content_type, re.IGNORECASE) await ctx.reply("Kurwa. Aleś mi roboty narobił... No nic. Ku radości. Skal!") async with ctx.typing(): if check: @@ -619,16 +619,20 @@ class MusicModule(commands.Cog): self.logger.info(link) pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$" self.logger.info("Verification") - 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) + ): self.logger.info("%s to link do jutuba", link) - dir_path, files = await music_functions.get_file( + dir_path, files = await music_functions.get_file( ctx, "Youtube", link ) if files: for file_iter in files: global MUZYKA # pylint: disable=global-variable-not-assigned MUZYKA["queue"].insert(0, file_iter) - music_functions.MUSIC_FILE_LIST.update_file_list(file_iter) + music_functions.MUSIC_FILE_LIST.update_file_list( + file_iter + ) MUZYKA["requester"].insert(0, ctx.author) await ctx.send(f"Dodałem do listy {file_iter}") self.logger.info("Jutub udany") @@ -668,10 +672,9 @@ class MusicModule(commands.Cog): ) self.logger.info("Spotifaj udany") - elif re.match(pat, link): self.logger.info("%s to link do czegos", link) - sciezka,files = await music_functions.get_file( + sciezka, files = await music_functions.get_file( ctx, "Pornol", link ) if files: @@ -689,7 +692,6 @@ class MusicModule(commands.Cog): self.logger.info("Spierdalaj") await ctx.message.reply("Spierdalaj") - async def disconnect(self, ctx): """ Asynchronous Python function that disconnects the voice client if it is connected and @@ -799,7 +801,7 @@ class MusicModule(commands.Cog): async def setup(bot): logger = logging.getLogger("discord") - music_functions.MUSIC_FILE_LIST.refresh_file_list() + await music_functions.MUSIC_FILE_LIST.refresh_file_list(bot) logger.info("Playlist generation") await bot.add_cog(MusicModule(bot, "discord")) logger.info("Loading music commands module done") diff --git a/music_functions.py b/music_functions.py index 78372f4..238749b 100644 --- a/music_functions.py +++ b/music_functions.py @@ -5,6 +5,7 @@ import uuid from pathlib import Path, PurePath from sys import platform +import discord import requests import yt_dlp @@ -28,13 +29,13 @@ class MusicFileList(object): file service or local directory and update the list with new items. """ - def __init__(self, uplogger) -> None: + def __init__(self, uplogger,) -> None: self.music_file_list = [] self.file_service_active = False self.logger = uplogger self.logger.info("Created Playlist organizer class") - def refresh_file_list(self): + async def refresh_file_list(self, bot): """ 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. @@ -50,9 +51,33 @@ class MusicFileList(object): if platform == "win32": temp_music_file = temp_music_file.replace("/", "\\") self.music_file_list.append(temp_music_file) - self.file_service_active = False + self.file_service_active = False self.logger.error(e.strerror) self.logger.error("Service Unavailable") + finally: + if self.file_service_active: + self.logger.info("Radio Status: Probably 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 bot.change_presence(status=status, activity=radio_hardkor) + + else: + self.logger.info("Radio Status: Rather Unknown") + await bot.change_presence( + activity=discord.Game(name="Axe Throwing Darts") + ) def get_file_list(self): """ @@ -150,10 +175,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 = [] diff --git a/thin_client.py b/thin_client.py index 541eed3..a54cd6e 100644 --- a/thin_client.py +++ b/thin_client.py @@ -27,6 +27,11 @@ intents.presences = True intents.members = True intents.messages = True intents.voice_states = True +intents.moderation = True + +# on_member_ban - wyswietl na glownym kanale pieczatke "Niech spierdala" +# on_member_unban - "mam wyjebane" + logger = logging.getLogger("discord") logger.setLevel(logging.DEBUG) handler = handlers.RotatingFileHandler( @@ -60,16 +65,14 @@ async def on_ready(): await client.load_extension("other_commands") await client.load_extension("voice_recognition_commands") - logger.info(client.cogs) - await client.change_presence(activity=discord.Game(name="Axe Throwing Darts")) await client.tree.sync() for com in client.commands: logger.info("Command %s is awejleble", com.qualified_name) - logger.info("Logged in as ---->", client.user) logger.info("ID:", client.user.id) + # TODO: ADMINISTRATION diff --git a/willowisp.png b/willowisp.png new file mode 100644 index 0000000..75ed5e3 Binary files /dev/null and b/willowisp.png differ diff --git a/wod_beacon.jpg b/wod_beacon.jpg new file mode 100644 index 0000000..dcf3ef8 Binary files /dev/null and b/wod_beacon.jpg differ