2018-03-14 20:13:40 +00:00
|
|
|
import main
|
2022-07-21 12:40:05 +00:00
|
|
|
from utils.logging.log import warn
|
2022-07-21 12:40:09 +00:00
|
|
|
from utils.logging.send import incorrectUsage, sendFailure, sendInfo, sendSuccess
|
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 parseCommand(addr, authed, data):
|
2022-07-21 12:39:41 +00:00
|
|
|
# call command modules with: (addr, authed, data, spl, success, failure, info, incUsage, length)
|
2018-02-23 22:05:40 +00:00
|
|
|
spl = data.split()
|
2018-03-14 20:13:40 +00:00
|
|
|
if addr in main.connections.keys():
|
|
|
|
obj = main.connections[addr]
|
2018-02-23 22:05:40 +00:00
|
|
|
else:
|
|
|
|
warn("Got connection object with no instance in the address pool")
|
|
|
|
return
|
|
|
|
|
2022-07-21 12:40:05 +00:00
|
|
|
success = lambda data: sendSuccess(addr, data) # noqa: E731
|
|
|
|
failure = lambda data: sendFailure(addr, data) # noqa: E731
|
|
|
|
info = lambda data: sendInfo(addr, data) # noqa: E731
|
2018-02-23 22:05:40 +00:00
|
|
|
|
2022-07-21 12:40:05 +00:00
|
|
|
incUsage = lambda mode: incorrectUsage(addr, mode) # noqa: E731
|
2018-02-23 22:05:40 +00:00
|
|
|
length = len(spl)
|
2019-01-26 18:58:21 +00:00
|
|
|
if spl[0] in main.CommandMap.keys():
|
2022-07-21 12:40:01 +00:00
|
|
|
main.CommandMap[spl[0]](addr, authed, data, obj, spl, success, failure, info, incUsage, length)
|
2019-01-26 18:58:21 +00:00
|
|
|
return
|
2018-02-23 22:05:40 +00:00
|
|
|
incUsage(None)
|
|
|
|
return
|