From d2e5a34b8735a14aba2976a4379c8793ff6c6905 Mon Sep 17 00:00:00 2001 From: Polish Hammer Date: Thu, 8 Jun 2023 14:06:25 +0200 Subject: [PATCH] Mala poprawka na rozmiar plikow pamieci --- bot.py | 51 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) diff --git a/bot.py b/bot.py index a12c10f..b90df48 100644 --- a/bot.py +++ b/bot.py @@ -147,7 +147,12 @@ async def on_message(message): #wentylacja if message.channel.id == 1083804024173764739: return - + #legendy + if message.channel.id == 1084448332841230388: + return + #interrogation booth + if message.channel.id == 1111625221171052595: + return if isinstance(message.channel, discord.DMChannel): channel = client.get_channel(1064888712565100614) await channel.send("Słyszałem ja żem że: " + message.content) @@ -155,7 +160,7 @@ async def on_message(message): channel = message.channel await client.process_commands(message) - # wpiac jego reakcje we framework chatu GPT + #TODO: wpiac jego reakcje we framework chatu GPT message.content = message.content.lower() tdelta = datetime.now() - master_timeout @@ -168,13 +173,12 @@ async def on_message(message): if tdelta > INITIAL_TIME_WAIT: for word in word_reactions: if re.search(".*" + word + "[\s*,$]*", message.content): - # if word in message.content: tdelta = datetime.now() - word_reactions[word][2] tdelta = tdelta.total_seconds() reaction = word_reactions[word][3] if tdelta > word_reactions[word][1]: - # to zrobic reactiony + #TODO: to zrobic reactiony logger.info("Ping z procedury reakcji") if reaction: emoji = client.get_emoji(word_reactions[word][0]) @@ -336,14 +340,47 @@ async def check(): voiceClient = client.voice_clients[0] if voiceClient.is_connected(): global MUZYKA - while MUZYKA["playing"]: - await asyncio.sleep(10) - if not voiceClient.is_playing() and not voiceClient.is_paused(): + while MUZYKA["playing"] and voiceClient.is_connected(): + if voiceClient and not voiceClient.is_playing() and not voiceClient.is_paused(): await play(MUZYKA["ctx"], MUZYKA["requestor"]) + await asyncio.sleep(0.1) if os.path.getsize(logfile) > 600000: shutil.copyfile(logfile,"{}discord{}.log".format(logstore, datetime.now())) logger.info("Log rollover") handler.doRollover() + + if os.path.getsize(memory_five_muzyka) > 300000: + channel = client.get_channel(1062047571557744721) + await channel.send("*Conjurer porządkuje bar, wypala szklanki do czysta miotaczem płomieni ze swojej zbroi i ogólnie wygląda na zajętego....*") + with channel.typing(): + path_newfile = "{}{}{}.json".format(logstore, memory_five_muzyka[:-4],datetime.now()) + with open(memory_five_muzyka, "r+") as file: + with open(path_newfile, "x") as new_file: + # First we load existing data into a dict. + file_data = json.load(file) + new_data = [] + new_data.append(file_data[0]) + new_data.extend(file_data[:-20]) + file.seek(0) + # convert back to json. + json.dump(file_data, file, indent=4) + json.dump(file_data, file, indent=4) + await channel.send("*Przeciąga się za barem* No dobra - porobione to można dalej pi... *Zauważa spojrzenie Hammera* ...sać powieści o naszym wspaniałym barze SZEFIE!") + if os.path.getsize(memory_five_siara)> 300000: + path_newfile = "{}{}{}.json".format(logstore, memory_five_siara[:-4],datetime.now()) + await channel.send("*Conjurer porządkuje bar, ścina lekkim laserem pulsacyjnym powierzchnie baru o grubości kilku mikronów i ogólnie wygląda na zajętego....*") + with open(memory_five_siara, "r+") as file: + with open(path_newfile, "x") as new_file: + # First we load existing data into a dict. + file_data = json.load(file) + new_data = [] + new_data.append(file_data[0]) + new_data.extend(file_data[:-20]) + file.seek(0) + # convert back to json. + json.dump(file_data, file, indent=4) + json.dump(file_data, file, indent=4) + await channel.send("*Przeciąga się za barem* No dobra - porobione to można dalej pi... *Zauważa spojrzenie Hammera* eprzyć o głupotach z klientami... Szefie... *Bierze 'ukradkowy' łyk z piersiówki*") await asyncio.sleep(60)