Esempio n. 1
0
  def handleUserData(self, input, internal=0 ):
    """
    Handles input in the context of this session specifically.

    @param input: the user data
    @type  input: string

    @param internal: whether the command came from interally.
        we won't spam hooks and may at some point prevent
        output for internal stuff too.  1 if internal, 0 if not.
    @type  internal: boolean
    """
    # this is the point of much recursion.  everything is registered
    # as a filter and recurses accordingly.
    spamargs = {"session": self, "internal": internal, 
                "verbatim": exported.get_config("verbatim", self), 
                "data": input, "dataadj": input}
    spamargs = exported.filter_mapper_hook_spam("user_filter_hook", spamargs)

    if spamargs == None:
      return
    else:
      input = spamargs["dataadj"]

    # after this point we don't do any more recursion.  so it's
    # safe to unescape things and such.
    input = input.replace("\\;", ";")
    input = input.replace("\\$", "$")
    input = input.replace("\\%", "%")

    # just regular data to the mud
    self.writeSocket(input + "\n")
Esempio n. 2
0
    def handleMudData(self, input):
        """
    Handles input coming from the mud.

    @param input: the data coming from the mud
    @type  input: string
    """
        # this sort of handles ansi color codes that get broken
        # mid-transmission when mud data is chunked and sent across
        # the network.
        if self._colorbuffer:
            input = self._colorbuffer + input
            self._colorbuffer = ''

        index = input.rfind(ESC)
        if index != -1 and input.find("m", index) == -1:
            self._colorbuffer = input[index:]
            input = input[:index]

        # we add the new input to the databuffer
        self.addToDataBuffer(input)

        # we split the input into a series of lines and operate on
        # those
        inputlines = input.splitlines(1)

        for i in range(0, len(inputlines)):
            mem = inputlines[i]
            # call the pre-filter hook
            spamargs = {"session": self, "data": mem, "dataadj": mem}

            spamargs = exported.filter_mapper_hook_spam(
                "mud_filter_hook", spamargs)
            if spamargs != None:
                mem = spamargs["dataadj"]
            else:
                mem = ""

            inputlines[i] = mem

        exported.write_mud_data("".join(inputlines), self)
Esempio n. 3
0
  def handleMudData(self, input):
    """
    Handles input coming from the mud.

    @param input: the data coming from the mud
    @type  input: string
    """
    # this sort of handles ansi color codes that get broken 
    # mid-transmission when mud data is chunked and sent across
    # the network.
    if self._colorbuffer:
      input = self._colorbuffer + input
      self._colorbuffer = ''

    index = input.rfind(ESC)
    if index != -1 and input.find("m", index) == -1:
      self._colorbuffer = input[index:]
      input = input[:index]

    # we add the new input to the databuffer
    self.addToDataBuffer(input)

    # we split the input into a series of lines and operate on
    # those
    inputlines = input.splitlines(1)

    for i in range(0, len(inputlines)):
      mem = inputlines[i]
      # call the pre-filter hook
      spamargs = {"session": self, "data": mem, "dataadj": mem}

      spamargs = exported.filter_mapper_hook_spam("mud_filter_hook", spamargs)
      if spamargs != None:
        mem = spamargs["dataadj"]
      else:
        mem = ""

      inputlines[i] = mem

    exported.write_mud_data("".join(inputlines), self)
Esempio n. 4
0
    def handleUserData(self, input, internal=0):
        """
    Handles input in the context of this session specifically.

    @param input: the user data
    @type  input: string

    @param internal: whether the command came from interally.
        we won't spam hooks and may at some point prevent
        output for internal stuff too.  1 if internal, 0 if not.
    @type  internal: boolean
    """
        # this is the point of much recursion.  everything is registered
        # as a filter and recurses accordingly.
        spamargs = {
            "session": self,
            "internal": internal,
            "verbatim": exported.get_config("verbatim", self),
            "data": input,
            "dataadj": input
        }
        spamargs = exported.filter_mapper_hook_spam("user_filter_hook",
                                                    spamargs)

        if spamargs == None:
            return
        else:
            input = spamargs["dataadj"]

        # after this point we don't do any more recursion.  so it's
        # safe to unescape things and such.
        input = input.replace("\\;", ";")
        input = input.replace("\\$", "$")
        input = input.replace("\\%", "%")

        # just regular data to the mud
        self.writeSocket(input + "\n")