mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 13:34:40 +00:00
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:
+22
-13
@@ -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,
|
||||
|
||||
+13
-10
@@ -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}")
|
||||
|
||||
@@ -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/
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
+10
-8
@@ -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")
|
||||
|
||||
+31
-5
@@ -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 = []
|
||||
|
||||
+6
-3
@@ -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
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Reference in New Issue
Block a user