def main(): parser = optparse() (options, args) = parser.parse_args() if len(args) != 3: parser.print_help() return logging.basicConfig(level=options.debug or logging.INFO, format="[%(asctime)s] %(message)s") servers, nickname, tmp_channel = args channel = [] for chan in tmp_channel.split(','): if not is_channel(chan): channel.append('#' + chan) else: channel.append(chan) server_list = [] listen = None # regex from http://stackoverflow.com/a/16710842 for addr in re.findall(r'(?:[^\s,"]|"(?:\\.|[^"])*")+', servers): host, port, password = parse_host_port_password(addr) if port == -1: parser.error('server argument got an invalid port number') else: server_list.append((host, port or 6667, password)) if options.listen: host, port, password = parse_host_port_password(options.listen, 'port') if port == -1: parser.error('--listen got an invalid port number') else: listen = (host or '', port) if options.script: script = [options.script] + options.args else: script = [] pycat = PyCat(server_list, nickname, options.realname or nickname, channel, listen, script, options.deop, options.opfirst) try: pycat.start() except KeyboardInterrupt: pass pycat.stop()
def main(): parser = optparse() (options, args) = parser.parse_args() if len(args) != 3: parser.print_help() return logging.basicConfig(level=options.debug or logging.INFO, format="[%(asctime)s] %(message)s") servers, nickname, channel = args if not is_channel(channel): channel = '#' + channel server_list = [] listen = None for addr in servers.split(','): host, port = parse_host_port(addr) if port == -1: parser.error('server argument got an invalid port number') else: server_list.append((host, port or 6667)) if options.listen: host, port = parse_host_port(options.listen, 'port') if port == -1: parser.error('--listen got an invalid port number') else: listen = (host or '', port) if options.script: script = [options.script] + options.args else: script = [] pycat = PyCat(server_list, nickname, options.realname or nickname, channel, listen, script, options.deop, options.opfirst) try: pycat.start() except KeyboardInterrupt: pass pycat.stop()
def _on_mode(self, c, e): """[Internal]""" modes = parse_channel_modes(" ".join(e.arguments())) t = e.target() self.log.info(t + ' set mode to ' + t) if is_channel(t): ch = self.channels[t] for mode in modes: if mode[0] == "+": f = ch.set_mode else: f = ch.clear_mode f(mode[1], mode[2]) else: # Mode on self... XXX pass
def on_welcome(self, server, ev): print("Welcomed") if ircbot.is_channel(self.target): server.join(self.target)
def on_welcome(self, server, ev): print("Welcomed") for t in self.targets: if ircbot.is_channel(t): server.join(t)