Beispiel #1
0
.  //__\
.  )___(   Play on Lichess with a bot
""".lstrip() % __version__


if __name__ == "__main__":
    print(intro())
    logger = logging.basicConfig(level=logging.INFO)
    parser = argparse.ArgumentParser(description='Play on Lichess with a bot')
    parser.add_argument(
        '-u',
        action='store_true',
        help='Add this flag to upgrade your account to a bot account.')
    args = parser.parse_args()
    CONFIG = load_config()
    li = lichess.Lichess(CONFIG["token"], CONFIG["url"], __version__)

    user_profile = li.get_profile()
    username = user_profile["username"]
    is_bot = user_profile.get("title") == "BOT"
    print("Welcome {}!".format(username))

    if args.u is True and is_bot is False:
        is_bot = upgrade_account(li)

    if is_bot:
        engine_factory = partial(engine_wrapper.create_engine, CONFIG)
        start(li, user_profile, engine_factory, CONFIG)
    else:
        print(
            "{} is not a bot account. Please upgrade your it to a bot account!"
Beispiel #2
0
		query="?"+"&".join(querylist)
	querypath="/games/export/{}{}".format(username,query)	
	queryurl = urljoin(li.baseUrl, querypath)
	print(queryurl)
	response = li.session.get(queryurl)
	response.raise_for_status()
	text=response.text
	if not path==None:
		with open(path,"w") as pgnfile:
			pgnfile.write(text)
	return text

PGN_DIR = USERNAME+"_pgn"

create_dir(PGN_DIR)
li = lichess.Lichess(token, CONFIG["url"], __version__)

class HeaderVisitor(chess.pgn.BaseVisitor):
	def __init__(self):
		self.game = chess.pgn.Game()		

		self.variation_stack = [self.game]
		self.starting_comment = ""
		self.in_variation = False

	def visit_header(self, tagname, tagvalue):
		self.game.headers[tagname] = tagvalue

	def result(self):
		return self.game
    .  //__\
    .  )___(   Play on Lichess with a bot
    """

if __name__=="__main__":
    parser = argparse.ArgumentParser(description='Play on Lichess with a bot')
    parser.add_argument('-u', action='store_true', help='Add this flag to upgrade your account to a bot account.')
    parser.add_argument('-v', action='store_true', help='Verbose output. Changes log level from INFO to DEBUG.')
    parser.add_argument('--config', help='Specify a configuration file (defaults to ./config.yml)')
    parser.add_argument('-l', '--logfile', help="Log file to append logs to.", default=None)
    args = parser.parse_args()

    logging.basicConfig(level=logging.DEBUG if args.v else logging.INFO, filename=args.logfile,
                        format="%(asctime)-15s: %(message)s")
    logger.info(intro())
    CONFIG = load_config(args.config or "./config.yml")
    li = lichess.Lichess(CONFIG["token"], CONFIG["url"], "1.1.5")

    user_profile = li.get_profile()
    username = user_profile["username"]
    is_bot = user_profile.get("title") == "BOT"
    logger.info("Welcome {}!".format(username))

    if is_bot is False:
        is_bot = upgrade_account(li)

    if is_bot:
        start(li, user_profile, CONFIG)
    else:
        logger.error("{} is not a bot account. Please upgrade it to a bot account!".format(user_profile["username"]))
Beispiel #4
0
    print("Depth: {}".format(handler.info["depth"]))
    print("nps: {}".format(handler.info["nps"]))
    print("Node: {}".format(handler.info["nodes"]))


if __name__ == "__main__":
    logger = logging.basicConfig(level=logging.INFO)
    parser = argparse.ArgumentParser(description='Play on Lichess with a bot')
    parser.add_argument(
        '-u',
        action='store_true',
        help='Add this flag to upgrade your account to a bot account.')
    args = parser.parse_args()

    config = yaml.load(open("./config.yml"))
    li = lichess.Lichess(config["token"], config["url"])

    user_profile = li.get_profile()

    is_bot = user_profile.get("bot") is not None

    if args.u is True and is_bot is False:
        is_bot = upgrade_account(li)

    if is_bot:
        engine_path = os.path.join(config["engines_dir"], config["engine"])
        weights_path = os.path.join(
            config["engines_dir"],
            config["weights"]) if config["weights"] is not None else None
        max_games = config["max_concurrent_games"]
        start(li, user_profile, engine_path, max_games, weights_path,