code: def add_cmd_handler(self, cmd, func):
          
          len_args = len(inspect.getargspec(func)[0])
  
          def add_meta(f):
              def decorator(*args, **kwargs):
                  f(*args, **kwargs)
              decorator.bytes_needed = len_args - 1  # exclude self
              decorator.__name__ = f.__name__
              return decorator
          func = add_meta(func)
          self._command_handlers[cmd] = func
docs: Adds a command handler for a command.