monolith/legacy/utils/logging/send.py

41 lines
803 B
Python

import main
def sendData(addr, data):
main.connections[addr].send(data)
def sendWithPrefix(addr, data, prefix):
toSend = ""
for i in data.split("\n"):
toSend += prefix + " " + i + "\n"
sendData(addr, toSend)
def sendSuccess(addr, data):
sendWithPrefix(addr, data, "[y]")
def sendFailure(addr, data):
sendWithPrefix(addr, data, "[n]")
def sendInfo(addr, data):
sendWithPrefix(addr, data, "[i]")
def sendAll(data):
for i in main.connections:
if main.connections[i].authed:
main.connections[i].send(data)
return
def incorrectUsage(addr, mode):
if mode is None:
sendFailure(addr, "Incorrect usage")
return
if mode in main.help.keys():
sendFailure(addr, "Usage: " + main.help[mode])
return