Reakcje ladacznicy, poprawka na mention w reset the clock

This commit is contained in:
2023-06-10 15:58:24 +02:00
committed by migatu
parent 5505022dbb
commit 579a3f2a52
+66 -35
View File
@@ -43,7 +43,7 @@ if platform == "linux" or platform == "linux2":
settings_file = "/home/pi/Conjurer/settings.json" settings_file = "/home/pi/Conjurer/settings.json"
netrc_file = "/home/pi/.netrc" netrc_file = "/home/pi/.netrc"
logstore = "/home/pi/RetroPie/logs/" logstore = "/home/pi/RetroPie/logs/"
accident_log = "/home/pi/accident_log.json" accident_log = "/home/pi/Conjurer/accident_log.json"
elif platform == "win32": elif platform == "win32":
logfile = "discord.log" logfile = "discord.log"
@@ -144,16 +144,16 @@ async def on_message(message):
if ("Conjurer Śpij Słodko Aniołku" in message.content) and vykidailo: if ("Conjurer Śpij Słodko Aniołku" in message.content) and vykidailo:
exit() exit()
#kanal bez bota # kanal bez bota
if message.channel.id == 1095985579147141202: if message.channel.id == 1095985579147141202:
return return
#wentylacja # wentylacja
if message.channel.id == 1083804024173764739: if message.channel.id == 1083804024173764739:
return return
#legendy # legendy
if message.channel.id == 1084448332841230388: if message.channel.id == 1084448332841230388:
return return
#interrogation booth # interrogation booth
if message.channel.id == 1111625221171052595: if message.channel.id == 1111625221171052595:
return return
if isinstance(message.channel, discord.DMChannel): if isinstance(message.channel, discord.DMChannel):
@@ -163,7 +163,7 @@ async def on_message(message):
channel = message.channel channel = message.channel
await client.process_commands(message) await client.process_commands(message)
#TODO: wpiac jego reakcje we framework chatu GPT # TODO: wpiac jego reakcje we framework chatu GPT
message.content = message.content.lower() message.content = message.content.lower()
tdelta = datetime.now() - master_timeout tdelta = datetime.now() - master_timeout
@@ -176,12 +176,11 @@ async def on_message(message):
if tdelta > INITIAL_TIME_WAIT: if tdelta > INITIAL_TIME_WAIT:
for word in word_reactions: for word in word_reactions:
if re.search(".*" + word + "[\s*,$]*", message.content): if re.search(".*" + word + "[\s*,$]*", message.content):
tdelta = datetime.now() - word_reactions[word][2] tdelta = datetime.now() - word_reactions[word][2]
tdelta = tdelta.total_seconds() tdelta = tdelta.total_seconds()
reaction = word_reactions[word][3] reaction = word_reactions[word][3]
if tdelta > word_reactions[word][1]: if tdelta > word_reactions[word][1]:
#TODO: to zrobic reactiony # TODO: to zrobic reactiony
logger.info("Ping z procedury reakcji") logger.info("Ping z procedury reakcji")
if reaction: if reaction:
emoji = client.get_emoji(word_reactions[word][0]) emoji = client.get_emoji(word_reactions[word][0])
@@ -344,19 +343,27 @@ async def check():
if voiceClient.is_connected(): if voiceClient.is_connected():
global MUZYKA global MUZYKA
while MUZYKA["playing"] and voiceClient.is_connected(): while MUZYKA["playing"] and voiceClient.is_connected():
if voiceClient and not voiceClient.is_playing() and not voiceClient.is_paused(): if (
voiceClient
and not voiceClient.is_playing()
and not voiceClient.is_paused()
):
await play(MUZYKA["ctx"], MUZYKA["requestor"]) await play(MUZYKA["ctx"], MUZYKA["requestor"])
await asyncio.sleep(0.1) await asyncio.sleep(0.1)
if os.path.getsize(logfile) > 600000: if os.path.getsize(logfile) > 600000:
shutil.copyfile(logfile,"{}discord{}.log".format(logstore, datetime.now())) shutil.copyfile(logfile, "{}discord{}.log".format(logstore, datetime.now()))
logger.info("Log rollover") logger.info("Log rollover")
handler.doRollover() handler.doRollover()
if os.path.getsize(memory_five_muzyka) > 300000: if os.path.getsize(memory_five_muzyka) > 300000:
channel = client.get_channel(1062047571557744721) 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....*") 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(): with channel.typing():
path_newfile = "{}{}{}.json".format(logstore, memory_five_muzyka[:-4],datetime.now()) path_newfile = "{}{}{}.json".format(
logstore, memory_five_muzyka[:-4], datetime.now()
)
with open(memory_five_muzyka, "r+") as file: with open(memory_five_muzyka, "r+") as file:
with open(path_newfile, "x") as new_file: with open(path_newfile, "x") as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
@@ -369,10 +376,16 @@ async def check():
new_file.seek(0) new_file.seek(0)
json.dump(new_data, file, indent=4) json.dump(new_data, file, indent=4)
json.dump(file_data, new_file, indent=4) json.dump(file_data, new_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!") await channel.send(
if os.path.getsize(memory_five_siara)> 300000: "*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!"
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....*") 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(memory_five_siara, "r+") as file:
with open(path_newfile, "x") as new_file: with open(path_newfile, "x") as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
@@ -385,7 +398,9 @@ async def check():
# convert back to json. # convert back to json.
json.dump(new_data, file, indent=4) json.dump(new_data, file, indent=4)
json.dump(file_data, new_file, indent=4) json.dump(file_data, new_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 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) await asyncio.sleep(60)
@@ -654,12 +669,11 @@ async def wyszukaj(ctx, how_many=0):
itr += 1 itr += 1
else: else:
logger.info("Wiele plików do zagrania") logger.info("Wiele plików do zagrania")
search_weight.sort(key = lambda x: x[0],reverse=True) search_weight.sort(key=lambda x: x[0], reverse=True)
return_list.extend(search_weight[:int(how_many)]) return_list.extend(search_weight[: int(how_many)])
return return_list return return_list
async def max_weight(list): async def max_weight(list):
max_weight = 0 max_weight = 0
for iter in list: for iter in list:
@@ -1001,34 +1015,42 @@ async def przytul(ctx, arg=None):
async def get_image_stable_diffusion(ctx, arg=None): async def get_image_stable_diffusion(ctx, arg=None):
pass pass
@client.command() @client.command()
async def fabryczka(ctx, arg=None): async def fabryczka(ctx, arg=None):
await ctx.message.reply(historia_fabryczki) await ctx.message.reply(historia_fabryczki)
@client.command() @client.command()
async def chata_hammera(ctx, arg=None): async def chata_hammera(ctx, arg=None):
with open("accident_log.json", "r+") as new_file: with open(accident_log, "r+") as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
file_data = json.load(new_file) file_data = json.load(new_file)
opis = file_data[-1][0] opis = file_data[-1][0]
czas = datetime.strptime(file_data[-1][1],'%Y-%m-%d %H:%M:%S.%f') czas = datetime.strptime(file_data[-1][1], "%Y-%m-%d %H:%M:%S.%f")
await ctx.send("Komenda mierząca Eldritch Absinht Horror Hammertimespacecontinuum. Od ostatniego incydentu w chacie Hammera minęło {}. Incydent to: {}".format(datetime.now()-czas,opis)) await ctx.send(
@client.command() "Komenda mierząca incydenty w Eldritch AbsinthHammerTimeSpaceContinuum.\n Od ostatniego incydentu w chacie Hammera minęło {}. Incydent to: {}".format(
datetime.now() - czas, opis
)
)
@client.command()
async def historia_incydentow_u_hammera(ctx, arg=None): async def historia_incydentow_u_hammera(ctx, arg=None):
with open("accident_log.json", "r+") as new_file: with open(accident_log, "r+") as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
file_data = json.load(new_file) file_data = json.load(new_file)
return_data = "Historia zarejestrownych incydentów u Hammera:\n" return_data = "Komenda mierząca incydenty w Eldritch AbsinthHammerTimeSpaceContinuum.\n Historia zarejestrownych incydentów u Hammera:\n"
index = 1 index = 1
for data in file_data: for data in file_data:
opis = data[0] opis = data[0]
czas = datetime.strptime(data[1],'%Y-%m-%d %H:%M:%S.%f') czas = datetime.strptime(data[1], "%Y-%m-%d %H:%M:%S.%f")
add_data = "{}. Opis: {} Data: {}".format(index,opis,czas) add_data = "{}. Opis: {} Data: {}".format(index, opis, czas)
return_data= return_data+ add_data + "\n" return_data = return_data + add_data + "\n"
index+=1 index += 1
await ctx.send(return_data) await ctx.send(return_data)
@client.command() @client.command()
async def reset_the_clock(ctx, arg=None): async def reset_the_clock(ctx, arg=None):
hammer = False hammer = False
@@ -1036,19 +1058,28 @@ async def reset_the_clock(ctx, arg=None):
if role.name == "Bartender": if role.name == "Bartender":
hammer = True hammer = True
if hammer: if hammer:
with open("accident_log.json", "r+") as new_file: with open(accident_log, "r+") as new_file:
# First we load existing data into a dict. # First we load existing data into a dict.
file_data = json.load(new_file) file_data = json.load(new_file)
czas = datetime.strptime(file_data[-1][1],'%Y-%m-%d %H:%M:%S.%f') czas = datetime.strptime(file_data[-1][1], "%Y-%m-%d %H:%M:%S.%f")
opis = ctx.message.content[16:] opis = ctx.message.content[16:]
accident= accident = [opis, "{}".format(datetime.now())] accident = accident = [opis, "{}".format(datetime.now())]
file_data.append(accident) file_data.append(accident)
new_file.seek(0) new_file.seek(0)
# convert back to json. # convert back to json.
json.dump(file_data, new_file, indent=4) json.dump(file_data, new_file, indent=4)
await ctx.send("RESET THE CLOCK. Od ostatniego incydentu w chacie Hammera minęło {}. No ale teraz odpierdolił: {}".format(czas, opis)) await ctx.send(
"Komenda mierząca incydenty w Eldritch AbsinthHammerTimeSpaceContinuum.\n RESET THE CLOCK. Od ostatniego incydentu w chacie Hammera minęło {}. No ale teraz się odpierdoliło: {}".format(
czas, opis
)
)
else: else:
await ctx.send("Gdzie z łapami do zegara? {} coś albo się komuś stało albo zaraz się stanie jak będzie zegar tykał....".format(client.get_user(346956223645614080))) await ctx.send(
"Komenda mierząca incydenty w Eldritch AbsinthHammerTimeSpaceContinuum.\n Gdzie z łapami do zegara? {} coś albo się komuś stało albo zaraz się stanie jak będzie zegar tykał....".format(
client.get_user(346956223645614080).mention
)
)
# *================================== Run # *================================== Run
client.run(TOKEN) client.run(TOKEN)