Esempio n. 1
0
 def mainloop(self):
     return gear.mainloop()
Esempio n. 2
0
            cut = now - flood_seconds
            times = dropwhile(lambda t: t < cut, self.send_times)
            if len(list(times)) >= flood_lines:
                self.flood_active = True
                break

        if defer or self.flood_active:
            self.flood_buffer.append((line, kwds))
            self.flood_active = True
        else:
            self.send_times.append(now)
            line = line[:510]
            self.dump("%s\r\n" % line)
            match = re.match(r"PRIVMSG (?P<target>\S+) :(?P<msg>.*)", line)
            if match:
                self.drive("SEND_MSG", self, match.group("target"), match.group("msg"), kwds)

    def h_tick(self, bot):
        if not self.flood_active:
            return
        lines = self.flood_buffer
        self.flood_buffer = []
        self.flood_active = False
        for line, kwds in lines:
            self.send_line(line, defer=False, **kwds)


if __name__ == "__main__":
    gear = AmeliaBot()
    gear.mainloop()