Exemplo n.º 1
0
    def send(self,
             line_parsed: IRCLine.ParsedLine,
             immediate: bool = False) -> typing.Optional[IRCLine.SentLine]:
        if not self.send_enabled:
            return None

        line_events = self.events.new_root()

        self.events.on("preprocess.send").on(line_parsed.command).call_unsafe(
            server=self, line=line_parsed, events=line_events)
        self.events.on("preprocess.send").call_unsafe(server=self,
                                                      line=line_parsed,
                                                      events=line_events)

        if line_parsed.valid() or line_parsed.assured():
            line = line_parsed.format()
            line_obj = IRCLine.SentLine(line_events,
                                        datetime.datetime.utcnow(),
                                        self.hostmask(), line_parsed)
            self.socket.send(line_obj, immediate=immediate)

            if immediate:
                self.bot.trigger_write()

            return line_obj
        return None
Exemplo n.º 2
0
    def send(self, line_parsed: IRCLine.ParsedLine):
        if not self.send_enabled:
            return None

        self.events.on("preprocess.send").on(line_parsed.command).call_unsafe(
            server=self, line=line_parsed)

        line = line_parsed.format()
        line_obj = IRCLine.SentLine(datetime.datetime.utcnow(),
                                    self.hostmask(), line_parsed)
        self.socket.send(line_obj)
        return line_obj
Exemplo n.º 3
0
    def send(self, line_parsed: IRCLine.ParsedLine):
        if not self.send_enabled:
            return None

        self.events.on("preprocess.send").on(line_parsed.command
            ).call_unsafe(server=self, line=line_parsed)

        line = line_parsed.format()
        line_stripped = line.split("\n", 1)[0].strip("\r")
        line_obj = IRCLine.SentLine(datetime.datetime.utcnow(), self.hostmask(),
            line_parsed)
        self.socket.send(line_obj)
        return line_obj
Exemplo n.º 4
0
 def _add_line(self, line: IRCLine.ParsedLine):
     line.tags["batch"] = self.id
     self.lines.append(line)
Exemplo n.º 5
0
 def _add_line(self, line: IRCLine.ParsedLine):
     line.tags["batch"] = self.id
     self.lines.append(line)