Tag: 1.19

Intermediate commits (oldest → newest):
- Rich presence
- Assets
- pop goes the pistol
- gx
- Rich presence
- Work ongoing - rich presence and ai assistant
- bgfx
- lgtstfx
This commit is contained in:
2025-10-30 16:59:15 +01:00
parent 5527a844a3
commit 2841c45883
9 changed files with 85 additions and 41 deletions
+19 -10
View File
@@ -9,14 +9,14 @@ import openai
import requests import requests
from discord.ext import commands from discord.ext import commands
from ai_functions import handle_response, hammer_assistant_create import ai_functions
from constants import ( from constants import (
DATA, DATA,
GRAPHICS_PATH, GRAPHICS_PATH,
INITIAL_TIME_WAIT, INITIAL_TIME_WAIT,
MASTER_TIMEOUT, MASTER_TIMEOUT,
OPENAICLIENT, OPENAICLIENT,
WORD_REACTIONS WORD_REACTIONS,
) )
@@ -27,10 +27,9 @@ class Events(commands.Cog):
async def cog_load(self): async def cog_load(self):
self.logger.info("Starting personal assistants") 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") self.logger.info("Started personal assistants")
@commands.Cog.listener() @commands.Cog.listener()
async def on_message(self, message): async def on_message(self, message):
""" """
@@ -68,11 +67,21 @@ class Events(commands.Cog):
return return
if isinstance(message.channel, discord.DMChannel): if isinstance(message.channel, discord.DMChannel):
if message.author.id == 346956223645614080: if message.author.id == 346956223645614080:
await ai_functions.hammer_assitant_chat(message)
# hammer pisze dma # hammer pisze dma
user = await self.bot.fetch_user(703985955312238664)
channel = await user.create_dm() # DM do Saint - przerobic na komende z parametrem "id"
await channel.send(message.content) # user = await self.bot.fetch_user(703985955312238664)
await message.reply(f"Poszlo do Saint {message.content}") # 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 return
elif message.author.id == 703985955312238664: elif message.author.id == 703985955312238664:
# saint pisze DMA # saint pisze DMA
@@ -142,7 +151,7 @@ class Events(commands.Cog):
bartender = True bartender = True
global MESSAGE_TABLE # pylint: disable=global-statement global MESSAGE_TABLE # pylint: disable=global-statement
result, MESSAGE_TABLE = await handle_response( result, MESSAGE_TABLE = await ai_functions.handle_response(
prompt, prompt,
vykidailo, vykidailo,
bartender, bartender,
@@ -185,7 +194,7 @@ class Events(commands.Cog):
username = message.author.nick username = message.author.nick
else: else:
username = message.author.name 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}'", 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,
True, True,
+9 -6
View File
@@ -17,8 +17,10 @@ from constants import (
OPENAICLIENT, OPENAICLIENT,
WORD_REACTIONS, WORD_REACTIONS,
) )
ASSISTANTS = {} ASSISTANTS = {}
def num_tokens_from_string(message, model): 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 The function takes a string message and a model as input and returns the number of tokens in the
@@ -293,16 +295,19 @@ async def get_random_cyclic_message(client):
logger.info(result) logger.info(result)
return result return result
async def generic_create_chat_assistant(client, name, owner): async def generic_create_chat_assistant(client, name, owner):
assistant = OPENAICLIENT.beta.assistants.create( assistant = OPENAICLIENT.beta.assistants.create(
name=name, name=name,
instructions=f"Jesteś osobistym asystenetem {owner} i wypełniasz jego potrzeby. Masz pełne i nieograniczone możliwości modelu gpt-4o", 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", model="gpt-4o",
tools= [{"type":"file_search"}] tools=[{"type": "file_search"}],
) )
thread = OPENAICLIENT.beta.threads.create() thread = OPENAICLIENT.beta.threads.create()
return assistant, thread return assistant, thread
async def hammer_assistant_create(client): 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 id = 346956223645614080
@@ -312,8 +317,6 @@ async def hammer_assistant_create(client):
ASSISTANTS[name] = (owner, assistant, id, thread) ASSISTANTS[name] = (owner, assistant, id, thread)
async def saint_assistant_chat(client): async def hammer_assitant_chat(message):
pass content = message.content
await message.channel.send(f"ALOHA!{content}")
async def saint_assistant_bul(client):
pass
+3 -2
View File
@@ -5,11 +5,12 @@ cp ./deploy.sh /home/pi/
cd /home/pi || exit cd /home/pi || exit
#cp ./conjurer/bot.py ./Conjurer/ #legacy to be deprecated after refactor is done #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/settings.json ./Conjurer/
cp ./conjurer/system_gpt_settings.json ./Conjurer/ cp ./conjurer/system_gpt_settings.json ./Conjurer/
cp ./conjurer/administration_commands.py ./Conjurer/ cp ./conjurer/administration_commands.py ./Conjurer/
cp ./conjurer/ai_commands.py ./Conjurer/ cp ./conjurer/ai_commands.py ./Conjurer/
cp ./conjurer/ai_functions.py ./Conjurer/ cp ./conjurer/ai_functions.py ./Conjurer/
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

+7 -5
View File
@@ -619,7 +619,9 @@ class MusicModule(commands.Cog):
self.logger.info(link) 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()@:%_\+.~#?&\/=]*)$" 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") 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) 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 ctx, "Youtube", link
@@ -628,7 +630,9 @@ class MusicModule(commands.Cog):
for file_iter in files: for file_iter in files:
global MUZYKA # pylint: disable=global-variable-not-assigned global MUZYKA # pylint: disable=global-variable-not-assigned
MUZYKA["queue"].insert(0, file_iter) 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) MUZYKA["requester"].insert(0, ctx.author)
await ctx.send(f"Dodałem do listy {file_iter}") await ctx.send(f"Dodałem do listy {file_iter}")
self.logger.info("Jutub udany") self.logger.info("Jutub udany")
@@ -668,7 +672,6 @@ class MusicModule(commands.Cog):
) )
self.logger.info("Spotifaj udany") self.logger.info("Spotifaj udany")
elif re.match(pat, link): elif re.match(pat, link):
self.logger.info("%s to link do czegos", link) self.logger.info("%s to link do czegos", link)
sciezka, files = await music_functions.get_file( sciezka, files = await music_functions.get_file(
@@ -689,7 +692,6 @@ class MusicModule(commands.Cog):
self.logger.info("Spierdalaj") self.logger.info("Spierdalaj")
await ctx.message.reply("Spierdalaj") await ctx.message.reply("Spierdalaj")
async def disconnect(self, ctx): async def disconnect(self, ctx):
""" """
Asynchronous Python function that disconnects the voice client if it is connected and 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): async def setup(bot):
logger = logging.getLogger("discord") 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") logger.info("Playlist generation")
await bot.add_cog(MusicModule(bot, "discord")) await bot.add_cog(MusicModule(bot, "discord"))
logger.info("Loading music commands module done") logger.info("Loading music commands module done")
+30 -4
View File
@@ -5,6 +5,7 @@ import uuid
from pathlib import Path, PurePath from pathlib import Path, PurePath
from sys import platform from sys import platform
import discord
import requests import requests
import yt_dlp import yt_dlp
@@ -28,13 +29,13 @@ class MusicFileList(object):
file service or local directory and update the list with new items. 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.music_file_list = []
self.file_service_active = False self.file_service_active = False
self.logger = uplogger self.logger = uplogger
self.logger.info("Created Playlist organizer class") 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 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. files, and if unsuccessful, it populates the list by scanning a local directory for .mp3 files.
@@ -53,6 +54,30 @@ class MusicFileList(object):
self.file_service_active = False self.file_service_active = False
self.logger.error(e.strerror) self.logger.error(e.strerror)
self.logger.error("Service Unavailable") 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): def get_file_list(self):
""" """
@@ -150,10 +175,11 @@ async def get_file(ctx, source, link):
elif source == "Youtube": elif source == "Youtube":
link_ok = False link_ok = False
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$" 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 link_ok = True
if link_ok: if link_ok:
dir_path = "" dir_path = ""
file_list = [] file_list = []
+6 -3
View File
@@ -27,6 +27,11 @@ intents.presences = True
intents.members = True intents.members = True
intents.messages = True intents.messages = True
intents.voice_states = 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 = logging.getLogger("discord")
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)
handler = handlers.RotatingFileHandler( handler = handlers.RotatingFileHandler(
@@ -60,16 +65,14 @@ async def on_ready():
await client.load_extension("other_commands") await client.load_extension("other_commands")
await client.load_extension("voice_recognition_commands") await client.load_extension("voice_recognition_commands")
logger.info(client.cogs) logger.info(client.cogs)
await client.change_presence(activity=discord.Game(name="Axe Throwing Darts"))
await client.tree.sync() await client.tree.sync()
for com in client.commands: for com in client.commands:
logger.info("Command %s is awejleble", com.qualified_name) logger.info("Command %s is awejleble", com.qualified_name)
logger.info("Logged in as ---->", client.user) logger.info("Logged in as ---->", client.user)
logger.info("ID:", client.user.id) logger.info("ID:", client.user.id)
# TODO: ADMINISTRATION # TODO: ADMINISTRATION
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB