Пример #1
0
    def _listen(self):
        callHook("newServer", self)
        while True:
            line = self.file.readline().replace("\n", "").replace("\r", "")
            if not self._loggedin:
                self._login()
                self._loggedin = True
            if line == "":
                self._callHook("disconnect", None)
                return
            data = Struct()
            data.line = line
            data.con = self
            data.passthough = True
            self._callHook("in_raw", data)
            if not data.passthough: # a module requested to not pass the command
                continue
            data = Struct()
            t = line.split(":")
            data.prefix = t[0]

            t = line[len(data.prefix) + 1:].split(" :")
            data.argline = t[0]
            data.args = data.argline.split()
            if len(t) > 1:
                data.data = line[len(data.argline) + 2:]
            else:
                data.data = None
            data.passthough = True
            self._callHook("in_DATA_" + data.args[1].upper(), data)
            if data.passthough:
                self.user.broadcastToClients(args = data.args, data = data.data, prefix = data.prefix)
Пример #2
0
    def _listen(self):
        callHook("newServer", self)
        while True:
            line = self.file.readline().replace("\n", "").replace("\r", "")
            if not self._loggedin:
                self._login()
                self._loggedin = True
            if line == "":
                self._callHook("disconnect", None)
                return
            data = Struct()
            data.line = line
            data.con = self
            data.passthough = True
            self._callHook("in_raw", data)
            if not data.passthough:  # a module requested to not pass the command
                continue
            data = Struct()
            t = line.split(":")
            data.prefix = t[0]

            t = line[len(data.prefix) + 1:].split(" :")
            data.argline = t[0]
            data.args = data.argline.split()
            if len(t) > 1:
                data.data = line[len(data.argline) + 2:]
            else:
                data.data = None
            data.passthough = True
            self._callHook("in_DATA_" + data.args[1].upper(), data)
            if data.passthough:
                self.user.broadcastToClients(args=data.args,
                                             data=data.data,
                                             prefix=data.prefix)