def create_client(host, nickname, password=None, **kwargs): """ Create quite simple default client""" cl = Client(host, nickname, **kwargs) cl.add_handler(handlers.ping_handler, 'PING') # for keepalives cl.add_handler(handlers.JoinHandler(TEST_CHANNEL, rejoinmsg='%s sucks')) cl.add_handler(handlers.ReplyWhenQuoted("I'm busy!")) cl.add_handler(handlers.nick_in_use_handler, replycode.ERR_NICKNAMEINUSE) if password: cl.add_handler(handlers.AuthHandler(nickname, password)) cl.add_handler(handlers.IRCShutdownHandler()) return cl
bot._sabotage.set(False) # Now check if a bot is expecting a message, and pass it along. for bot in g.bots: if bot.channel != channel: continue name = 'process_' + msg.params[1].upper() if name == 'process_COMMENT': pass elif hasattr(bot, name): process = getattr(bot, name) process(msg.params) elif bot.expecting: bot.expecting(msg.params) if __name__ == '__main__': server = 'localhost' if len(sys.argv) > 1: server = sys.argv[1] irc = Client(server, 'aigamedev', port=6667, local_hostname='localhost') h = ResistanceCompetitionHandler() irc.add_handler(h) try: irc.start() irc.join() except KeyboardInterrupt: h.upcoming.put(([], None))
self.client.send("No input required at this stage.") if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--server', type=str, required=False, default='irc.aigamedev.com', help = "IRC server name to connect to hosting running games.") parser.add_argument('--port', type=int, required=False, default=6667, help = "Port of the IRC server to connect to.") parser.add_argument('--name', type=str, required=False, default='aigamedev', help = "Name of the IRC client that connects to the server.") args = parser.parse_args() irc = Client(args.server, args.name, port=args.port, local_hostname='localhost') OnlineRound.client = irc h = ResistanceCompetitionHandler() irc.add_handler(h) try: irc.start() irc.join() except KeyboardInterrupt: h.upcoming.put(([], None)) # COMPETITION # - Check current games for players disconnecting and invalidate them. # - Mark bots that timed out and punish them for it -- or notify channel. # - For speed, use a constant set of bot channels rather than game channels. # - For speed, run multiple games with the same bots, different configurations.