diff --git a/basiclogo.svg b/basiclogo.svg index 982fadbd..836f19a5 100644 --- a/basiclogo.svg +++ b/basiclogo.svg @@ -86,6 +86,6 @@ y="0" style="text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#783f04;fill-opacity:1;" />{}REPLACEME diff --git a/bot.py b/bot.py index 21ba2e72..c99361a2 100644 --- a/bot.py +++ b/bot.py @@ -478,19 +478,21 @@ def getrygimage(): telegram.sendmessage("Puoi mettere solo due lettere.") else: # FIXME: percorsi assoluti - directory = "/var/www/html/rygimages/{}.png" - infile = open("/royal/bot/basiclogo.svg", "r") - print(infile.read()) - indata = infile.read().format(cmd[1]).encode("utf-8") - print(indata.decode("utf-8")) + directory = "/var/www/html/rygimages/{}.png".format(cmd[1]) + infile = open("basiclogo.svg", "rb") + # FIXME: possibile exploit qui + indata = infile.read().replace(b"REPLACEME", cmd[1].encode("utf-8")) infile.close() try: - outfile = open(directory.format(cmd[1]), "x") + outfile = open(directory, "x") + outfile.write("") outfile.close() - except Exception: + except FileExistsError: pass - outfile = open(directory.format(cmd[1]), "wb") - cairosvg.svg2png(bytestring=indata, write_to=outfile) + outfile = open(directory, "wb") + outdata = cairosvg.svg2png(bytestring=indata) + print(outdata) + outfile.write(outdata) outfile.close() telegram.sendmessage("[Scarica](http://royal.steffo.me/rygimages/{}.png)" " la tua immagine del profilo Royal Games!".format(cmd[1]), @@ -671,8 +673,10 @@ while True: else: print("@" + username + " bloccato.") except Exception as e: - telegram.sendmessage(chr(9762) + " *Errore critico:\n*" - "{0}\n\n" - "Secondo me, è colpa dello stagista.".format(repr(e)), -2141322) - print("\033[1mERRORE CRITICO:\n" - "{0}\033[0m".format(repr(e))) + if __debug__: + raise + else: + telegram.sendmessage(chr(9762) + " *Errore critico:\n*" + "{0}\n\n" + "Secondo me, è colpa dello stagista.".format(repr(e)), -2141322) + print("\033[1mERRORE CRITICO:\n{0}\033[0m".format(repr(e))) diff --git a/sm b/sm index b3beb7f7..ce3275c9 160000 --- a/sm +++ b/sm @@ -1 +1 @@ -Subproject commit b3beb7f76214d6a8fa5d5954da762a4165442d4a +Subproject commit ce3275c9b51ee7e7bb18020ae93d498a54cd7466