Small fixes in the paths

This commit is contained in:
2023-06-22 23:19:59 +02:00
committed by migatu
parent 8aa980ff9c
commit c9d371d941
+33 -37
View File
@@ -24,7 +24,7 @@ from logging import handlers
from pathlib import Path, PurePath
from platform import uname
from sys import platform
from typing import List, TypedDict, Union
from typing import List, TypedDict, Optional
# *==============Imported libraries
import discord
@@ -49,7 +49,7 @@ Music_Config = TypedDict(
"Music_Config",
{
"playing": bool,
"ctx": Union[str, None],
"ctx": Optional[str],
"queue": List[str],
"requestor": List[str],
},
@@ -72,16 +72,18 @@ GRAPHICS_PATH = ""
# *=========================================== Platform Specific Predefines
if platform in ("linux", "linux2"):
if "microsoft-standard" in uname().release:
LOGFILE = "/home/pi/Conjurer/discord.log"
MEMORY_FIVE_SIARA = "/home/pi/Conjurer/pamiec.json"
MEMORY_FIVE_MUZYKA = "/home/pi/Conjurer/pamiec_muzyki.json"
MUSIC_FOLDER = "/home/pi/RetroPie/mp3/"
SETTINGS_FILE = "/home/pi/Conjurer/settings.json"
NETRC_FILE = "/home/pi/netrc"
LOGSTORE = "/home/pi/RetroPie/logs/"
ACCIDENT_LOG = "/home/pi/Conjurer/accident_log.json"
LOGFILE = "/home/mtuszowski/conjurer/discord.log"
MEMORY_FIVE_SIARA = "/home/mtuszowski/conjurer/pamiec.json"
MEMORY_FIVE_MUZYKA = "/home/mtuszowski/conjurer/pamiec_muzyki.json"
MUSIC_FOLDER = "/mnt/g/Muzyka/"
SETTINGS_FILE = "/home/mtuszowski/conjurer/settings.json"
NETRC_FILE = "/home/mtuszowski/.netrc"
LOGSTORE = "/home/mtuszowski/conjurer/logs/"
ACCIDENT_LOG = "/home/mtuszowski/conjurer/accident_log.json"
ENCODING = "utf-8"
GRAPHICS_PATH = "/home/pi/RetroPie/Conjurer_graphics/"
GRAPHICS_PATH = "/home/mtuszowski/conjurer/Conjurer_graphics/"
DIR_PATH_SADOX = "/mnt/c/Users/mtusz/OneDrive/Dokumenty/Fansadox"
else:
LOGFILE = "/home/pi/Conjurer/discord.log"
MEMORY_FIVE_SIARA = "/home/pi/Conjurer/pamiec.json"
@@ -93,6 +95,8 @@ if platform in ("linux", "linux2"):
ACCIDENT_LOG = "/home/pi/Conjurer/accident_log.json"
ENCODING = "utf-8"
GRAPHICS_PATH = "/home/pi/RetroPie/Conjurer_graphics/"
DIR_PATH_SADOX = "/home/pi/RetroPie/Fansadox/"
elif platform == "win32":
LOGFILE = "discord.log"
@@ -103,7 +107,9 @@ elif platform == "win32":
NETRC_FILE = "C:\\Users\\mtusz\\.netrc"
LOGSTORE = "C:\\Users\\mtusz\\OneDrive\\Pulpit\\Conjurer\\logs\\"
ACCIDENT_LOG = "accident_log.json"
ENCODING = "cp1250"
ENCODING = "utf-8"
DIR_PATH_SADOX = "C:\\Users\\mtusz\\OneDrive\\Dokumenty\\Fansadox\\"
# *=========================================== Keys
netrc_mod = netrc.netrc(NETRC_FILE)
@@ -436,7 +442,7 @@ async def play(ctx, zamawial=None, arg=None):
username = ctx.message.author.nick
else:
username = ctx.message.author.name
global MESSAGE_TABLE # pylint: disable=global-statement
global MESSAGE_TABLE # pylint: disable=global-statement
result, MESSAGE_TABLE = await handle_response(
query, vykidailo, bartender, message_table_muzyka, username, True
)
@@ -517,9 +523,7 @@ async def check():
# trunk-ignore(pylint/R0913)
async def handle_response(
prompt, vykidailo, bartender, history, username, music
):
async def handle_response(prompt, vykidailo, bartender, history, username, music):
"""
Handle responses by appending them to a history, use OpenAI to
generate a response, and then append the generated response to the history.
@@ -745,7 +749,7 @@ async def async_iterator_generator(range_of_iterable):
# pylint: disable=pointless-string-statement
# yield the result
yield i
'''
"""
Alternatywna wersja przerobienia fora na asynchroniczny.
# traverse the iterable of awaitables
for item in coros:
@@ -753,7 +757,7 @@ async def async_iterator_generator(range_of_iterable):
result = await item
# report the results
print(result)
'''
"""
# trunk-ignore(pylint/R0914)
@@ -1069,27 +1073,22 @@ async def get_image_sadox(ctx):
logger.info("Get sadox")
channel = ctx.message.channel
async with channel.typing():
dir_path_sadox = ""
# select random file
if platform in ("linux", "linux2"):
dir_path_sadox = "/home/pi/RetroPie/Fansadox/"
elif platform == "win32":
dir_path_sadox = "C:\\Users\\mtusz\\OneDrive\\Dokumenty\\Fansadox\\"
res = []
# Iterate directory
for path in os.listdir(dir_path_sadox):
for path in os.listdir(DIR_PATH_SADOX):
# check if current path is a file
if os.path.isfile(os.path.join(dir_path_sadox, path)):
if os.path.isfile(os.path.join(DIR_PATH_SADOX, path)):
res.append(path)
filename = res[random.randrange(0, len(res) - 1)]
# select random page
file = open(dir_path_sadox + filename, "rb")
file = open(DIR_PATH_SADOX + filename, "rb")
readpdf = PyPDF2.PdfReader(file)
totalpages = len(readpdf.pages)
page = random.randrange(1, totalpages)
# convert page to image
image = pdf2image.convert_from_path(
dir_path_sadox + filename, first_page=page, last_page=page
DIR_PATH_SADOX + filename, first_page=page, last_page=page
)
byte_io_stream = io.BytesIO()
image[0].save(byte_io_stream, "JPEG")
@@ -1321,9 +1320,7 @@ async def zrob_mi_plejliste(ctx):
if metadata.tag.album:
reply += f" z albumu {metadata.tag.album}"
if metadata.tag.title:
reply += (
" z prywatnej kolekcji Hammera i na Twoją specjalną rpośbę.\n"
)
reply += " z prywatnej kolekcji Hammera i na Twoją specjalną rpośbę.\n"
else:
reply += f"{index}. {plik[1]} z prywatnej kolekcji Hammera."
@@ -1343,17 +1340,16 @@ async def zrob_mi_plejliste(ctx):
@client.hybrid_command(
name="przytul", description="Przytul kogoś - daj mention po komendzie :)"
)
async def przytul(ctx, arg: Union[discord.Member, None] = None):
async def przytul(ctx, arg: Optional[discord.Member] = None):
"""
Generate a text about hugging mentioned user.
:param ctx: ctx stands for "context" and is a required parameter in Discord.py commands. It
represents the context in which the command is being executed, including information such as the
message, the channel, the server, and the user who invoked the command
:param arg: The parameter "arg" is a variable that can accept either a discord.Member object or None
as its value. It is an optional parameter, which means that if no value is provided for it when the
function is called, it will default to None
:type arg: Union[discord.Member, None]
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
:param arg: arg is a parameter of the function "przytul" that expects a Discord member object. The
parameter is optional, meaning that if no member object is provided, it will default to None
:type arg: Optional[discord.Member]
"""
async with ctx.typing():
nieprzytulac = False