This commit is contained in:
2023-06-13 18:15:24 +02:00
committed by migatu
parent ddf1c5fdca
commit 5173ed2e52
+66 -62
View File
@@ -122,6 +122,7 @@ for key in word_reactions:
# *=========================================== Create Client
client = commands.Bot(intents=intents, command_prefix="$")
# *=========================================== Define Events
@@ -129,6 +130,8 @@ client = commands.Bot(intents=intents, command_prefix="$")
async def on_ready():
logger.debug(f"{client.user} has connected to Discrod!")
await client.change_presence(activity=discord.Game(name="Axe Throwing Darts"))
await client.tree.sync()
#await tree.sync(guild=discord.Object(id=Your guild id))
await check()
@@ -175,7 +178,7 @@ async def on_message(message):
if tdelta > INITIAL_TIME_WAIT:
for word in word_reactions:
if re.search(".*" + word + "[\s*,$]*", message.content):
if re.search(r"\b" + word + r"\b", message.content):
tdelta = datetime.now() - word_reactions[word][2]
tdelta = tdelta.total_seconds()
reaction = word_reactions[word][3]
@@ -699,8 +702,8 @@ async def max_weight(list):
# *=========================================== Define Commands
@client.command()
#@client.command()
@client.hybrid_command(name = "dej_co_ze_spotifaja", description = "Podaj link do spotify - sciagnie i doda muzyke", guild=discord.Object(id=664789470779932693))
async def dej_co_ze_spotifaja(ctx):
logger.info("Spotifaj")
await ctx.send("Dej mnie chwilkę")
@@ -734,8 +737,8 @@ async def dej_co_ze_spotifaja(ctx):
)
logger.info("Spotifaj udany")
@client.command()
#@client.command()
@client.hybrid_command(name = "dej_co_z_jutuba", description = "Podaj link do youtube - sciagnie i doda muzyke",guild=discord.Object(id=664789470779932693))
async def dej_co_z_jutuba(ctx):
await ctx.send("Dej mnie chwilkę")
logger.info("Jutub")
@@ -758,9 +761,9 @@ async def dej_co_z_jutuba(ctx):
await ctx.send("Dodałem do listy {}".format(file))
logger.info("Jutub udany")
@client.command()
async def update_banlist(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "update_banlist", description = "Jeśli nie wiesz jak użyć tej komendy to nawet nie próbuj",guild=discord.Object(id=664789470779932693))
async def update_banlist(ctx):
async with channel.typing():
allowed = False
for role in ctx.author.roles:
@@ -834,9 +837,9 @@ async def update_banlist(ctx, arg=None):
)
await ctx.send("Zrobione tak czy inaczej")
@client.command()
async def get_image_sadox(ctx, arg=None):
#@client.command()
@client.hybrid_command(nsfw=True, name = "get_image_sadox", description = "Wyświetla losową stronę z losowego komiksu FanSadox. Bardzo NSFW.",guild=discord.Object(id=664789470779932693))
async def get_image_sadox(ctx):
logger.info("Get sadox")
channel = ctx.message.channel
async with channel.typing():
@@ -869,9 +872,9 @@ async def get_image_sadox(ctx, arg=None):
await ctx.send(file=file)
logger.info("Get sadox completed")
@client.command()
async def graj_muzyko(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "graj_muzyko", description = "Włącza muzykę na kanale #nocna-zmiana.",guild=discord.Object(id=664789470779932693))
async def graj_muzyko(ctx):
logger.info("Press play on tape")
async with ctx.typing():
global MUZYKA
@@ -881,9 +884,9 @@ async def graj_muzyko(ctx, arg=None):
await play(ctx=ctx)
logger.info("Press play on tape completed")
@client.command()
async def cisza(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "cisza", description = "Wyłącza muzykę i czyści plejliste.",guild=discord.Object(id=664789470779932693))
async def cisza(ctx):
logger.info("Stop")
global MUZYKA
MUZYKA["playing"] = False
@@ -896,9 +899,9 @@ async def cisza(ctx, arg=None):
MUZYKA["requestor"].pop()
logger.info("Stop completed")
@client.command()
async def dalej(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "dalej", description = "Przerzuca na następny kawałek",guild=discord.Object(id=664789470779932693))
async def dalej(ctx):
logger.info("Next")
voiceClient = client.voice_clients[0]
if voiceClient.is_connected():
@@ -906,18 +909,18 @@ async def dalej(ctx, arg=None):
await play(ctx=ctx)
logger.info("Next completed")
@client.command()
async def daj_mi_chwile(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "daj_mi_chwile", description = "Pauzuje",guild=discord.Object(id=664789470779932693))
async def daj_mi_chwile(ctx):
logger.info("Pause")
voiceClient = client.voice_clients[0]
if voiceClient.is_connected():
voiceClient.pause()
logger.info("Pause completed")
@client.command()
async def graj_dalej(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "graj_dalej", description = "Odpauzowuje",guild=discord.Object(id=664789470779932693))
async def graj_dalej(ctx):
logger.info("Unpause")
voiceClient = client.voice_clients[0]
if voiceClient.is_paused():
@@ -925,13 +928,9 @@ async def graj_dalej(ctx, arg=None):
logger.info("Unpause completed")
@client.command()
async def zagraj_muzyke_mego_ludu(ctx, arg=None):
pass
@client.command()
async def zagraj_mi_kawalek(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "zagraj_mi_kawalek", description = "Wyszukuje w bibliotece muzycznej Hammera kawałek który ma zostać zagrany",guild=discord.Object(id=664789470779932693))
async def zagraj_mi_kawalek(ctx):
async with ctx.typing():
search_time_glob = datetime.now()
logger.info("Zaczynam szukać timestamp {}".format(datetime.now()))
@@ -957,21 +956,21 @@ async def zagraj_mi_kawalek(ctx, arg=None):
if metadata.tag.album:
reply += " z albumu {}".format(metadata.tag.album)
reply += " z prywatnej kolekcji Hammera i na Twoją specjalną rpośbę."
await ctx.reply(reply)
await ctx.send(reply)
else:
await ctx.reply(
await ctx.send(
"Obawiam się że nie mogę nic znaleźć u siebie. Spróbuj komendy '$dej_co_ze_spotifaja' jeśli masz link"
)
@client.command()
async def zrob_mi_plejliste(ctx, *arg):
#@client.command()
@client.hybrid_command(name = "zrob_mi_plejliste", description = "Generuje playliste - param1 - dlugosc, potem slowa wyszukiwania",guild=discord.Object(id=664789470779932693))
async def zrob_mi_plejliste(ctx):
reply = "Wygenerowana plejlista:\n"
async with ctx.typing():
logger.info("Zaczynam szukać timestamp {}".format(datetime.now()))
search_time_glob = datetime.now()
dlugosc_playlisty = arg[0]
dlugosc_playlisty = ctx.message.content.split()[0]
file = await wyszukaj(ctx=ctx, how_many=dlugosc_playlisty)
logger.info(
"Koniec szukania(timestamp {} zajęło {}".format(
@@ -1000,18 +999,18 @@ async def zrob_mi_plejliste(ctx, *arg):
reply += " z prywatnej kolekcji Hammera i na Twoją specjalną rpośbę.\n"
index+=1
if len(reply) > 1800:
await ctx.reply(reply)
await ctx.send(reply)
reply = ""
else:
await ctx.reply(
await ctx.send(
"Obawiam się że nie mogę nic znaleźć u siebie. Spróbuj komendy '$dej_co_ze_spotifaja' jeśli masz link"
)
await ctx.reply(reply)
await ctx.send(reply)
logger.info("Plejlista zrobiona")
@client.command()
async def przytul(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "przytul", description = "Przytul kogoś - daj mention po komendzie :)")
async def przytul(ctx, arg:discord.Member=None):
async with ctx.typing():
nieprzytulac = False
for mention in ctx.message.mentions:
@@ -1026,28 +1025,23 @@ async def przytul(ctx, arg=None):
elif arg:
await ctx.send(
"Już dobrze.... Już dobrze... Ojej.. Biedactwo... :( *W ułamku sekundy {} znajduje sie w duszącym uścisku. Żebra trzeszczą - kilka pęka. Pacnięcia po plecach grożą odbiciem nerek, a głaskanie po głowie powoduje wstrząs mózgu*".format(
arg
arg.mention
)
)
else:
await ctx.message.add_reaction("\U0001fac2")
await ctx.send(
"Kogo mam przytulić? *Wyłamuje kostki i przeciąga się - jego 200 kilowa sylwetka złożona z samych mięśni świadczy o tym że jest gotowy*"
)
@client.command()
async def get_image_stable_diffusion(ctx, arg=None):
pass
#@client.command()
@client.hybrid_command(name = "fabryczka", description = "Historia fabryczki")
async def fabryczka(ctx):
await ctx.send(historia_fabryczki)
@client.command()
async def fabryczka(ctx, arg=None):
await ctx.message.reply(historia_fabryczki)
@client.command()
async def chata_hammera(ctx, arg=None):
#@client.command()
@client.hybrid_command(name = "chata_hammera", description = "Czas od ostatniego incydentu w AbsinthHammerTimeSpaceContinuum")
async def chata_hammera(ctx):
with open(accident_log, "r+") as new_file:
# First we load existing data into a dict.
file_data = json.load(new_file)
@@ -1060,8 +1054,9 @@ async def chata_hammera(ctx, arg=None):
)
@client.command()
async def historia_incydentow_u_hammera(ctx, arg=None):
@client.hybrid_command(name = "historia_incydentow_u_hammera", description = "Wyswietla liste incydentów które miały miejsce w AbsinthHammerTimeSpaceContinuum.")
#@client.command()
async def historia_incydentow_u_hammera(ctx):
with open(accident_log, "r+") as new_file:
# First we load existing data into a dict.
file_data = json.load(new_file)
@@ -1076,8 +1071,9 @@ async def historia_incydentow_u_hammera(ctx, arg=None):
await ctx.send(return_data)
@client.command()
async def reset_the_clock(ctx, arg=None):
@client.hybrid_command(name = "reset_the_clock", description = "Resetowanie zegara - dostępne wyłącznie dla Hammera", guild=discord.Object(id=664789470779932693))
#@client.command()
async def reset_the_clock(ctx):
hammer = False
for role in ctx.message.author.roles:
if role.name == "Bartender":
@@ -1105,6 +1101,14 @@ async def reset_the_clock(ctx, arg=None):
)
)
#@client.command()
async def get_image_stable_diffusion(ctx):
pass
#@client.command()
#@client.hybrid_command()
async def zagraj_muzyke_mego_ludu(ctx):
pass
# *================================== Run
client.run(TOKEN)