You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
964 B
Python

import main
from utils.logging.log import warn
from utils.logging.send import incorrectUsage, sendFailure, sendInfo, sendSuccess
def parseCommand(addr, authed, data):
# call command modules with: (addr, authed, data, spl, success, failure, info, incUsage, length)
spl = data.split()
if addr in main.connections.keys():
obj = main.connections[addr]
else:
warn("Got connection object with no instance in the address pool")
return
success = lambda data: sendSuccess(addr, data) # noqa: E731
failure = lambda data: sendFailure(addr, data) # noqa: E731
info = lambda data: sendInfo(addr, data) # noqa: E731
incUsage = lambda mode: incorrectUsage(addr, mode) # noqa: E731
length = len(spl)
if spl[0] in main.CommandMap.keys():
main.CommandMap[spl[0]](
addr, authed, data, obj, spl, success, failure, info, incUsage, length
)
return
incUsage(None)
return