mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Improvements
This commit is contained in:
@@ -1535,6 +1535,7 @@ async def get_image_stable_diffusion(ctx):
|
|||||||
guild=discord.Object(id=664789470779932693),
|
guild=discord.Object(id=664789470779932693),
|
||||||
)
|
)
|
||||||
# trunk-ignore(pylint/R0912)
|
# trunk-ignore(pylint/R0912)
|
||||||
|
# trunk-ignore(pylint/R0915)
|
||||||
async def zagraj_muzyke_mego_ludu(ctx):
|
async def zagraj_muzyke_mego_ludu(ctx):
|
||||||
"""
|
"""
|
||||||
Play completeley random playlist based on messaging history.
|
Play completeley random playlist based on messaging history.
|
||||||
@@ -1546,17 +1547,22 @@ async def zagraj_muzyke_mego_ludu(ctx):
|
|||||||
"""
|
"""
|
||||||
stats = {}
|
stats = {}
|
||||||
if ctx:
|
if ctx:
|
||||||
|
logger.info("Zagraj muzyke mego ludu: wywolane")
|
||||||
stat_iter = get_stats(ctx, MUZYKA_MOJEGO_LUDU_HISTORIA)
|
stat_iter = get_stats(ctx, MUZYKA_MOJEGO_LUDU_HISTORIA)
|
||||||
async for name, how_many in stat_iter:
|
async for name, how_many in stat_iter:
|
||||||
if len(name) > 3:
|
if len(name) > 3:
|
||||||
stats[name] = how_many
|
stats[name] = how_many
|
||||||
|
|
||||||
sorted_stats = sorted(stats.items(), key=lambda x: x[1])
|
sorted_stats = sorted(stats.items(), key=lambda x: x[1])
|
||||||
|
logger.info("Zagraj muzyke mego ludu:zebrano statystyki")
|
||||||
key_words = []
|
key_words = []
|
||||||
for stat in sorted_stats:
|
for stat in sorted_stats:
|
||||||
key_words.append(stat[0])
|
key_words.append(stat[0])
|
||||||
logger.info(sorted_stats[:30])
|
logger.info(sorted_stats[:MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE])
|
||||||
logger.info(key_words[:30])
|
logger.info(key_words[:MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE])
|
||||||
|
logger.info(sorted_stats[-MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE:])
|
||||||
|
logger.info(key_words[-MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE:])
|
||||||
|
|
||||||
final_key_words = key_words[:MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE]
|
final_key_words = key_words[:MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE]
|
||||||
final_key_words.extend(key_words[-MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE:])
|
final_key_words.extend(key_words[-MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE:])
|
||||||
reply = "Wygenerowana plejlista:\n"
|
reply = "Wygenerowana plejlista:\n"
|
||||||
@@ -1564,12 +1570,13 @@ async def zagraj_muzyke_mego_ludu(ctx):
|
|||||||
logger.info("Zaczynam szukać timestamp %s", datetime.now())
|
logger.info("Zaczynam szukać timestamp %s", datetime.now())
|
||||||
search_time_glob = datetime.now()
|
search_time_glob = datetime.now()
|
||||||
file = await wyszukaj(ctx=ctx, how_many=MUZYKA_MOJEGO_LUDU_PLAJLISTA, slowa_kluczowe=final_key_words)
|
file = await wyszukaj(ctx=ctx, how_many=MUZYKA_MOJEGO_LUDU_PLAJLISTA, slowa_kluczowe=final_key_words)
|
||||||
|
logger.info("Zagraj muzyke mego ludu:wygenerowano plejliste")
|
||||||
|
logger.info(file)
|
||||||
logger.info(
|
logger.info(
|
||||||
"Koniec szukania(timestamp %s zajęło %s",
|
"Koniec szukania(timestamp %s zajęło %s",
|
||||||
datetime.now(),
|
datetime.now(),
|
||||||
datetime.now() - search_time_glob,
|
datetime.now() - search_time_glob,
|
||||||
)
|
)
|
||||||
logger.info(file)
|
|
||||||
index = 1
|
index = 1
|
||||||
if file:
|
if file:
|
||||||
for plik in file:
|
for plik in file:
|
||||||
@@ -1629,12 +1636,22 @@ async def parametry_muzyki_mego_ludu(ctx, ile_historii=1500, ile_slow_kluczowych
|
|||||||
|
|
||||||
if ctx:
|
if ctx:
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
global MUZYKA_MOJEGO_LUDU_HISTORIA # pylint: disable=global-statement
|
if ':' in ile_historii:
|
||||||
MUZYKA_MOJEGO_LUDU_HISTORIA = ile_historii
|
_, _, ile_historii = ile_historii.partition(':')
|
||||||
global MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE # pylint: disable=global-statement
|
if ':' in ile_slow_kluczowych:
|
||||||
MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = ile_slow_kluczowych
|
_, _, ile_slow_kluczowych = ile_slow_kluczowych.partition(':')
|
||||||
global MUZYKA_MOJEGO_LUDU_PLAJLISTA # pylint: disable=global-statement
|
if ':' in jak_dluga_plejlista:
|
||||||
MUZYKA_MOJEGO_LUDU_PLAJLISTA = jak_dluga_plejlista
|
_, _, jak_dluga_plejlista = jak_dluga_plejlista.partition(':')
|
||||||
|
try:
|
||||||
|
global MUZYKA_MOJEGO_LUDU_HISTORIA # pylint: disable=global-statement
|
||||||
|
MUZYKA_MOJEGO_LUDU_HISTORIA = ile_historii
|
||||||
|
global MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE # pylint: disable=global-statement
|
||||||
|
MUZYKA_MOJEGO_LUDU_SLOWA_KLUCZOWE = ile_slow_kluczowych
|
||||||
|
global MUZYKA_MOJEGO_LUDU_PLAJLISTA # pylint: disable=global-statement
|
||||||
|
MUZYKA_MOJEGO_LUDU_PLAJLISTA = jak_dluga_plejlista
|
||||||
|
except discord.ext.commands.errors.BadArgument as exce:
|
||||||
|
ctx.send("Spierdalaj")
|
||||||
|
logger.info(exce)
|
||||||
|
|
||||||
|
|
||||||
# *================================== Run
|
# *================================== Run
|
||||||
|
|||||||
Reference in New Issue
Block a user