monolith/legacy/utils/logging/send.py

41 lines
803 B
Python
Raw Normal View History

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