Merge branch 'glados' of gitea.planet-casio.com:devs/PCv5 into dev

This commit is contained in:
Darks 2020-11-11 13:47:24 +01:00
commit 63baae9683
Signed by: Darks
GPG Key ID: 7515644268BE1433
2 changed files with 42 additions and 0 deletions

39
app/utils/glados.py Normal file
View File

@ -0,0 +1,39 @@
import socket
from config import V5Config
BOLD = "\x02"
ITALIC = "\x1d"
UNDERLINE = "\x1f"
STRIKETHROUGH = "\x1e"
NO_COLOR = "\x03"
WHITE = "\x0300"
BLACK = "\x0301"
BLUE = "\x0302"
GREEN = "\x0303"
RED = "\x0304"
BROWN = "\x0305"
MAGENTA = "\x0306"
ORANGE = "\x0307"
YELLOW = "\x0308"
LIGHT_GREEN = "\x0309"
CYAN = "\x0310"
LIGHT_CYAN = "\x0311"
LIGHT_BLUE = "\x0312"
PINK = "\x0313"
GREY = "\x0314"
LIGHT_GREY = "\x0315"
def say(msg, channels = ["#general"]):
""" GLaDOS will say <msg> on <channels>
Channel #* means all channels where GLaDOS listens to
Raw messages follow this partern:
#channel1 #channel2: message"""
sock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
msg = ":".join([" ".join(channels), msg])
sock.sendto(msg.encode(),(V5Config.GLADOS_HOST, V5Config.GLADOS_PORT))
def new_topic(topic):
""" Example wrapper for glados.say """
say(f"Le topic {BOLD}{topic.title}{BOLD} a été créé")

View File

@ -47,6 +47,9 @@ class DefaultConfig(object):
ENABLE_EMAIL_CONFIRMATION = True
# Send emails
SEND_MAILS = True
# GLaDOS configuration
GLADOS_HOST = "127.0.0.1"
GLADOS_PORT = 5555
class V5Config(LocalConfig, DefaultConfig):
# Values put here cannot be overidden with local_config