#This is the main input processor for connections.

_imports = ["lib_login", "commandlib_user", "commandlib_admin"]
_parents = ["avatar_telnet"]
_version = 1

def _Sys_Create(self, client):
  self.handler = None
  self.account = None
  self.passwordTries = 0
  self.newAccountArgs = {}
  self.commandModules = []

def _Sys_Destroy(self):
  pass

def OnConnect(self):
  ExAsType(self, "avatar_telnet", "OnConnect")
  self.Send(lib_login.welcome)
  self.Send(lib_login.nameRequest)
  self.handler = (lib_login, "NameEntry")

def _Sys_ReceiveCommand(self, command):
  #We need to remove special characters, namely the ANSI escape and our internal control characters.
  #This avatar just passes commands on to the handler.
  self.handler[0][self.handler[1]](self, command)

def ExportCommands(self):
  commands = []
  for commandModule in self.commandModules:
    commands.extend(commandModule.exportCommands)
  return commands