Package: play-lichess
play-lichessPython module for creating match links on Lichess that two players can joinNote: Until version 0.1.3, the requests were done synchronously usingrequests. Starting with version 1.0.0, all requests are done asynchronously usingaiohttp.📥 Installationpip install play-lichess🧑‍💻 UsageStart a real-time matchfromplay_lichessimportRealTimeMatchasyncdefcreate_match():match=awaitRealTimeMatch.create()print(match.challenge_id)# e.g. 'f1S4BBYW'print(match.challenge_url)# e.g. 'https://lichess.org/f1S4BBYW'print(match.status)# 'created'print(match.variant)# Variant.STANDARDprint(match.rated)# Falseprint(match.speed)# TimeMode.BLITZprint(match.time_control.show)# '5+0'print(match.color)# Color.RANDOMprint(match.url_white)# e.g. 'https://lichess.org/f1S4BBYW?color=white'print(match.url_black)# e.g. 'https://lichess.org/f1S4BBYW?color=black'print(match.name)# Noneasyncio.run(create_match())# import asyncio to call async functions outside event loopStart a correspondence matchfromplay_lichessimportCorrespondenceMatchasyncdefcorrespondence_match():match=awaitCorrespondenceMatch.create()print(match.challenge_id)# e.g. 'KGO4ICDn'print(match.challenge_url)# e.g. 'https://lichess.org/KGO4ICDn'print(match.status)# 'created'print(match.variant)# Variant.STANDARDprint(match.rated)# Falseprint(match.speed)# TimeMode.CORRESPONDENCEprint(match.time_control.type)# TimeControlType.CORRESPONDENCEprint(match.time_control.days_per_turn)# 1print(match.color)# Color.RANDOMprint(match.url_white)# e.g. 'https://lichess.org/KGO4ICDn?color=white'print(match.url_black)# e.g. 'https://lichess.org/KGO4ICDn?color=black'print(match.name)# NoneStart an unlimited time matchfromplay_lichessimportUnlimitedMatchasyncdefunlimited_correspondence_match():match=awaitUnlimitedMatch.create()print(match.challenge_id)# e.g. 'JLA868mV'print(match.challenge_url)# e.g. 'https://lichess.org/JLA868mV'print(match.status)# 'created'print(match.variant)# Variant.STANDARDprint(match.rated)# Falseprint(match.speed)# TimeMode.CORRESPONDENCEprint(match.time_control.type)# TimeControlType.UNLIMITEDprint(match.color)# Color.RANDOMprint(match.url_white)# e.g. 'https://lichess.org/JLA868mV?color=white'print(match.url_black)# e.g. 'https://lichess.org/JLA868mV?color=black'print(match.name)# NoneSpecify game optionsfromplay_lichessimportRealTimeMatch,Variantasyncdefcreate_match_options():match:RealTimeMatch=awaitRealTimeMatch.create(rated=False,clock_limit=180,clock_increment=0,variant=Variant.ANTICHESS,name="Test match",)print(match.challenge_id)# e.g. 'cuZGwbcO'print(match.challenge_url)# e.g. 'https://lichess.org/cuZGwbcO'print(match.status)# 'created'print(match.variant)# Variant.ANTICHESSprint(match.rated)# Falseprint(match.speed)# TimeMode.BLITZprint(match.time_control.show)# '3+0'print(match.color)# Color.RANDOMprint(match.url_white)# e.g. 'https://lichess.org/cuZGwbcO?color=white'print(match.url_black)# e.g. 'https://lichess.org/cuZGwbcO?color=black'print(match.name)# 'Test match'Alternate syntaxfromplay_lichessimportMatchasyncdefcreate_any_match():# real-timematch1=awaitMatch.create(clock_limit=180,clock_increment=0)# unlimited timematch2=awaitMatch.create(clock_limit=None,clock_increment=None)# correspondencematch3=awaitMatch.create(days=1,clock_limit=None,clock_increment=None)🔧 OptionsReal-timeArgumentTypeDefaultDescriptionratedboolFalseWhether the match is rated or not.clock_limitint300The time limit in seconds.clock_incrementint0The time increment in seconds.variantVariantSTANDARDThe variant of the match (STANDARD, CHESS960, etc.)fenstrStart positionThe FEN string of the starting position.namestrNoneThe name of the match displayed when joining.CorrespondenceArgumentTypeDefaultDescriptionratedboolFalseWhether the match is rated or not.daysint1The number of days for each player.variantVariantSTANDARDThe variant of the match (STANDARD, CHESS960, etc.)fenstrStart positionThe FEN string of the starting position.namestrNoneThe name of the match displayed when joining.UnlimitedArgumentTypeDefaultDescriptionvariantVariantSTANDARDThe variant of the match (STANDARD, CHESS960, etc.)fenstrStart positionThe FEN string of the starting position.namestrNoneThe name of the match displayed when joining.VariantsVariants are defined in theVariantenum and include:Variant.STANDARD(default)Variant.CRAZYHOUSEVariant.CHESS960Variant.KING_OF_THE_HILLVariant.THREE_CHECKVariant.ANTICHESSVariant.ATOMICVariant.HORDEVariant.RACING_KINGS🧰 DevelopmentTo run tests (pytest/tox)# Install toxpipinstall-Utox# Run teststoxTo lint (pyright)# Install pyrightpipinstall-Upyright# Run pyrightpyright