1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

New ryg image generator

This commit is contained in:
Steffo 2017-01-19 20:52:53 +01:00
parent 35bd5f561a
commit f76e2cd683

12
bot.py
View file

@ -11,6 +11,7 @@ import discord
import subprocess import subprocess
import sm.steammatch as steammatch import sm.steammatch as steammatch
import db import db
import cairosvg
# Elenco di username dei membri della RYG # Elenco di username dei membri della RYG
royalgames = json.loads(filemanager.readfile("db.json")) royalgames = json.loads(filemanager.readfile("db.json"))
@ -471,8 +472,15 @@ def lolfree():
def getrygimage(): def getrygimage():
# Ricevi il link alla tua immagine del profilo Royal Games. # Ricevi il link alla tua immagine del profilo Royal Games.
print("@" + username + ": /getrygimage") print("@" + username + ": /getrygimage")
telegram.sendmessage("[Scarica](https://dl.dropboxusercontent.com/u/23313381/Logo/Personali/{tag}.png)" if len(cmd[1]) > 2:
" la tua immagine del profilo Royal Games!".format(tag=royalgames[username.lower()]['icon']), telegram.sendmessage("Puoi mettere solo due lettere.")
else:
directory = "/var/www/html/rygimages/{}.png"
infile = b"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?> <svg xmlns:dc=\"http://purl.org/dc/elements/1.1/\"xmlns:cc=\"http://creativecommons.org/ns#\"xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"xmlns:svg=\"http://www.w3.org/2000/svg\"xmlns=\"http://www.w3.org/2000/svg\"id=\"svg3693\"stroke-miterlimit=\"10\"stroke-linecap=\"square\"stroke=\"none\"fill=\"none\"viewBox=\"0.0 0.0 720.0 720.0\"version=\"1.1\"> <metadata id=\"metadata3699\"> <rdf:RDF> <cc:Work rdf:about=\"\"> <dc:format>image/svg+xml</dc:format> <dc:type rdf:resource=\"http://purl.org/dc/dcmitype/StillImage\" /> <dc:title></dc:title> </cc:Work> </rdf:RDF> </metadata> <defs id=\"defs3697\" /> <clipPath id=\"p.0\"> <path id=\"path3680\"clip-rule=\"nonzero\"d=\"m0 0l720.0 0l0 720.0l-720.0 0l0 -720.0z\" /> </clipPath> <g id=\"g3691\"clip-path=\"url(#p.0)\"> <path id=\"path3683\"fill-rule=\"nonzero\"d=\"m0 0l720.0 0l0 720.0l-720.0 0z\"fill=\"#ff7f00\" /> <path id=\"path3685\"fill-rule=\"nonzero\"d=\"m-1.0624952 275.66144l275.5697 0.0019226074l85.15396 -274.5596l85.15396 274.5596l275.5697 -0.0019226074l-222.94168 169.68524l85.1575 274.5584l-222.93948 -169.68835l-222.93948 169.68835l85.15747 -274.5584z\"fill=\"#ffff00\" /> <path id=\"path3687\"fill-rule=\"nonzero\"d=\"m-0.72440946 141.05511l721.44885 0l0 437.88977l-721.44885 0z\"fill-opacity=\"0.0\"fill=\"#000000\" /> <flowRoot style=\"fill:black;fill-opacity:1;stroke:none;font-family:sans-serif;font-style:normal;font-weight:normal;font-size:40px;line-height:25px;letter-spacing:0px;word-spacing:0px\"id=\"flowRoot3701\"xml:space=\"preserve\"><flowRegion id=\"flowRegion3703\"><rect y=\"187.54491\"x=\"37.724552\"height=\"351.37726\"width=\"589.58081\"id=\"rect3705\" /></flowRegion><flowPara id=\"flowPara3707\"></flowPara></flowRoot> <flowRoot style=\"font-style:normal;font-weight:normal;font-size:40px;line-height:25px;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none\"id=\"flowRoot3709\"xml:space=\"preserve\"><flowRegion id=\"flowRegion3711\"><rect y=\"0\"x=\"0\"height=\"720\"width=\"720\"id=\"rect3713\" /></flowRegion><flowPara id=\"flowPara3715\" /></flowRoot> <flowRoot transform=\"matrix(18.416206,0,0,18.416206,-6272.7758,103.20272)\"style=\"font-style:normal;font-weight:normal;font-size:40px;line-height:25px;font-family:sans-serif;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#783f04;fill-opacity:1;stroke:none;\"id=\"flowRoot3717\"xml:space=\"preserve\"><flowRegion style=\"text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#783f04;fill-opacity:1;\"id=\"flowRegion3719\"><rect style=\"text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#783f04;fill-opacity:1;\"y=\"0\"x=\"0\"height=\"720\"width=\"720\"id=\"rect3721\" /></flowRegion><flowPara style=\"font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;font-size:28.96000099px;font-family:Ubuntu;-inkscape-font-specification:'Ubuntu Medium';fill:#783f04;fill-opacity:1;\"id=\"flowPara3723\">%s<flowPara></flowRoot> </g> </svg>" % cmd[1]
outfile = open(directory.format(cmd[1]), "wb")
cairosvg.svg2png(bytestring=infile, write_to=outfile)
telegram.sendmessage("[Scarica](http://royal.steffo.me/rygimages/{}.png)"
" la tua immagine del profilo Royal Games!".format(cmd[1]),
sentin, source) sentin, source)