167 lines
4.2 KiB
Python
167 lines
4.2 KiB
Python
# AGPL 3 or any later version
|
|
# (C) J.Y.Amihud ( Blender Dumbass )
|
|
|
|
import random
|
|
|
|
clr = {
|
|
"norm":"\033[00m", # Reset to normal
|
|
"bold":"\033[01m", # Bold Text
|
|
"ital":"\033[03m", # Italic Text
|
|
"undr":"\033[04m", # Underlined
|
|
"blnk":"\033[05m", # Blinking
|
|
|
|
# Text
|
|
"tdbl":"\033[30m", # Dark Black
|
|
"tdrd":"\033[31m", # Dark Red
|
|
"tdgr":"\033[32m", # Dark Green
|
|
"tdyl":"\033[33m", # Dark Yellow
|
|
"tdbu":"\033[34m", # Dark Blue
|
|
"tdma":"\033[35m", # Dark Magenta
|
|
"tdcy":"\033[36m", # Dark Cyan
|
|
"tdwh":"\033[37m", # Dark White
|
|
|
|
"tbbl":"\033[90m", # Bright Black
|
|
"tbrd":"\033[91m", # Bright Red
|
|
"tbgr":"\033[92m", # Bright Green
|
|
"tbyl":"\033[93m", # Bright Yellow
|
|
"tbbu":"\033[94m", # Bright Blue
|
|
"tbma":"\033[95m", # Bright Magenta
|
|
"tbcy":"\033[96m", # Bright Cyan
|
|
"tbwh":"\033[97m", # Bright White
|
|
# Background
|
|
"bdbl":"\033[40m", # Dark Black
|
|
"bdrd":"\033[41m", # Dark Red
|
|
"bdgr":"\033[42m", # Dark Green
|
|
"bdyl":"\033[43m", # Dark Yellow
|
|
"bdbu":"\033[44m", # Dark Blue
|
|
"bdma":"\033[45m", # Dark Magenta
|
|
"bdcy":"\033[46m", # Dark Cyan
|
|
"bdwh":"\033[47m", # Dark White
|
|
|
|
"bbbl":"\033[100m", # Bright Black
|
|
"bbrd":"\033[101m", # Bright Red
|
|
"bbgr":"\033[102m", # Bright Green
|
|
"bbyl":"\033[103m", # Bright Yellow
|
|
"bbbu":"\033[104m", # Bright Blue
|
|
"bbma":"\033[105m", # Bright Magenta
|
|
"bbcy":"\033[106m", # Bright Cyan
|
|
"bbwh":"\033[108m" # Bright White
|
|
}
|
|
|
|
def Simplify(text, extrasimple=True):
|
|
|
|
good = "QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuiopasdfghjklzxcvbnm.1234567890-_:* "
|
|
|
|
if extrasimple == "file":
|
|
good = "QWERTYUIOPLKJHGFDSAZXCVBNMqwertyuiopasdfghjklzxcvbnm.1234567890-_"
|
|
|
|
elif extrasimple:
|
|
good = "qwertyuiopasdfghjklzxcvbnm.1234567890-_:"
|
|
text = text.lower()
|
|
|
|
ntext = ""
|
|
for i in text:
|
|
if i in good:
|
|
ntext = ntext + i
|
|
else:
|
|
ntext = ntext + "_"
|
|
|
|
return ntext
|
|
|
|
def Safe(text):
|
|
return text.replace("<", "<").replace(">", ">")
|
|
|
|
def RandString(n=50):
|
|
# this will make a random string
|
|
s = ""
|
|
good = "QWERTYUIOPASDFGHJKLZXCVBNM1234567890"
|
|
|
|
for i in range(n):
|
|
s = s + random.choice(good)
|
|
|
|
return s
|
|
|
|
|
|
IDColors = {}
|
|
|
|
def consoleForm(obj):
|
|
|
|
from modules.Render import accounts
|
|
|
|
# Username preview
|
|
username = ""
|
|
Accounts = accounts()
|
|
for account in Accounts:
|
|
if obj in Accounts[account].get("sessions"):
|
|
username = account
|
|
break
|
|
|
|
|
|
|
|
# Function that prints a pretty object info about
|
|
|
|
if not obj: obj = " ANONYMOUS "
|
|
|
|
ID = obj
|
|
|
|
if not username:
|
|
NAME = obj[-14:]
|
|
else:
|
|
NAME = username[:15].upper()
|
|
|
|
c = IDcolor(ID)
|
|
|
|
return c + " " + NAME + " " + clr["norm"]
|
|
|
|
def IDcolor(ID):
|
|
|
|
# Coloring
|
|
if ID not in IDColors:
|
|
r = random.random()
|
|
g = random.random()
|
|
b = random.random()
|
|
|
|
ct = clr["tbwh"]
|
|
if max(r, g, b ) > 0.9 or sum((r, g, b))/3 > 0.5:
|
|
ct = clr["tdbl"]
|
|
|
|
c = clr["bold"] + "\033[48;2;"+str(int(r*256))+";"+str(int(g*256))+";"+str(int(b*256))+"m"+ct
|
|
IDColors[ID] = c
|
|
c = IDColors[ID]
|
|
return c
|
|
|
|
|
|
# Licenses for stuff
|
|
Licenses = {
|
|
"cc0":{
|
|
"name":"CC0 Public Domain",
|
|
"link":"https://creativecommons.org/publicdomain/zero/1.0/"
|
|
},
|
|
"cc-by":{
|
|
"name":"Creative Commons Attribution",
|
|
"link":"https://creativecommons.org/licenses/by/4.0/"
|
|
},
|
|
"cc-by-sa":{
|
|
"name":"Creative Commons Attribution Share-Alike",
|
|
"link":"https://creativecommons.org/licenses/by-sa/4.0/"
|
|
},
|
|
"gpl3":{
|
|
"name":"GNU General Public License Version 3",
|
|
"link":"https://www.gnu.org/licenses/gpl.html"
|
|
},
|
|
"lgpl3":{
|
|
"name":"GNU Lesser General Public License Version 3",
|
|
"link":"https://www.gnu.org/licenses/lgpl.html"
|
|
},
|
|
"agpl":{
|
|
"name":"GNU Affero General Public License Version 3",
|
|
"link":"https://www.gnu.org/licenses/agpl.html"
|
|
},
|
|
"gpl3-or-later":{
|
|
"name":"GNU General Public License Version 3 or any later version",
|
|
"link":"https://www.gnu.org/licenses/"
|
|
}
|
|
|
|
|
|
|
|
}
|