2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def sendData(addr, data):
|
2018-03-14 20:13:40 +00:00
|
|
|
main.connections[addr].send(data)
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2019-01-20 19:56:54 +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
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def sendSuccess(addr, data):
|
2019-01-20 19:56:54 +00:00
|
|
|
sendWithPrefix(addr, data, "[y]")
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def sendFailure(addr, data):
|
2019-01-20 19:56:54 +00:00
|
|
|
sendWithPrefix(addr, data, "[n]")
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def sendInfo(addr, data):
|
2019-01-20 19:56:54 +00:00
|
|
|
sendWithPrefix(addr, data, "[i]")
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def sendAll(data):
|
2018-03-14 20:13:40 +00:00
|
|
|
for i in main.connections:
|
2019-01-26 01:57:24 +00:00
|
|
|
if main.connections[i].authed:
|
|
|
|
main.connections[i].send(data)
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2018-02-23 22:05:40 +00:00
|
|
|
def incorrectUsage(addr, mode):
|
2022-07-21 12:40:05 +00:00
|
|
|
if mode is None:
|
2018-02-23 22:05:40 +00:00
|
|
|
sendFailure(addr, "Incorrect usage")
|
|
|
|
return
|
2018-03-14 20:13:40 +00:00
|
|
|
if mode in main.help.keys():
|
|
|
|
sendFailure(addr, "Usage: " + main.help[mode])
|
2018-02-23 22:05:40 +00:00
|
|
|
return
|