hgducharme / lichess-bot

A middle-man between your chess engine and lichess.com
GNU General Public License v3.0
1 stars 0 forks source link

Decline/abort games if we're not accepting any games at the moment #11

Open hgducharme opened 1 year ago

hgducharme commented 1 year ago

Log file normally:

2023-02-18 15:54:58,596 [DEBUG] ChallengeStreamWatcher: ChallengeStreamWatcher
2023-02-18 15:54:58,597 [DEBUG] ContinuousWorker: Creating an instance of ChallengeStreamWatcher
2023-02-18 15:54:58,597 [DEBUG] ContinuousWorker: Creating an instance of EventStreamWatcher
2023-02-18 15:54:59,292 [DEBUG] ContinuousWorker: A EventStreamWatcher thread has been started
2023-02-18 15:54:59,293 [DEBUG] ContinuousWorker: A ChallengeStreamWatcher thread has been started
2023-02-18 15:55:14,575 [INFO] ChallengeStreamWatcher: Sending a challenege request to user hgducharme
2023-02-18 15:55:15,275 [DEBUG] EventStreamWatcher: From event stream: {'type': 'challenge', 'challenge': {'id': 'SV0lgdph', 'url': 'https://lichess.org/SV0lgdph', 'status': 'created', 'challenger': {'id': 'stockai', 'name': 'stockAI', 'title': 'BOT', 'rating': 2000, 'provisional': True, 'online': True}, 'destUser': {'id': 'hgducharme', 'name': 'hgducharme', 'title': None, 'rating': 867, 'online': True}, 'variant': {'key': 'standard', 'name': 'Standard', 'short': 'Std'}, 'rated': False, 'speed': 'bullet', 'timeControl': {'type': 'clock', 'limit': 60, 'increment': 0, 'show': '1+0'}, 'color': 'random', 'finalColor': 'white', 'perf': {'icon': '\ue047', 'name': 'Bullet'}}, 'compat': {'bot': True, 'board': False}}
2023-02-18 15:55:15,277 [INFO] ChallengeStreamWatcher: Response from challenge request to hgducharme: <Response [200]>
2023-02-18 15:55:17,486 [DEBUG] EventStreamWatcher: From event stream: {'type': 'gameStart', 'game': {'fullId': 'SV0lgdphuXLO', 'gameId': 'SV0lgdph', 'fen': 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', 'color': 'white', 'lastMove': '', 'source': 'friend', 'variant': {'key': 'standard', 'name': 'Standard'}, 'speed': 'bullet', 'perf': 'bullet', 'rated': False, 'hasMoved': False, 'opponent': {'id': 'hgducharme', 'username': 'hgducharme', 'rating': 867}, 'isMyTurn': True, 'secondsLeft': 60, 'compat': {'bot': True, 'board': False}, 'id': 'SV0lgdph'}}
2023-02-18 15:55:17,487 [INFO] EventStreamWatcher: Starting a new game.
2023-02-18 15:55:17,487 [DEBUG] ContinuousWorker: Creating an instance of ChessGame
2023-02-18 15:55:17,495 [DEBUG] ContinuousWorker: A ChessGame thread has been started

Log file if our GameManager.accepting_games flag is set to false:

2023-02-18 15:54:58,596 [DEBUG] ChallengeStreamWatcher: ChallengeStreamWatcher
2023-02-18 15:54:58,597 [DEBUG] ContinuousWorker: Creating an instance of ChallengeStreamWatcher
2023-02-18 15:54:58,597 [DEBUG] ContinuousWorker: Creating an instance of EventStreamWatcher
2023-02-18 15:54:59,292 [DEBUG] ContinuousWorker: A EventStreamWatcher thread has been started
2023-02-18 15:54:59,293 [DEBUG] ContinuousWorker: A ChallengeStreamWatcher thread has been started
2023-02-18 15:55:14,575 [INFO] ChallengeStreamWatcher: Sending a challenege request to user hgducharme
2023-02-18 15:55:15,275 [DEBUG] EventStreamWatcher: From event stream: {'type': 'challenge', 'challenge': {'id': 'SV0lgdph', 'url': 'https://lichess.org/SV0lgdph', 'status': 'created', 'challenger': {'id': 'stockai', 'name': 'stockAI', 'title': 'BOT', 'rating': 2000, 'provisional': True, 'online': True}, 'destUser': {'id': 'hgducharme', 'name': 'hgducharme', 'title': None, 'rating': 867, 'online': True}, 'variant': {'key': 'standard', 'name': 'Standard', 'short': 'Std'}, 'rated': False, 'speed': 'bullet', 'timeControl': {'type': 'clock', 'limit': 60, 'increment': 0, 'show': '1+0'}, 'color': 'random', 'finalColor': 'white', 'perf': {'icon': '\ue047', 'name': 'Bullet'}}, 'compat': {'bot': True, 'board': False}}
2023-02-18 15:55:15,277 [INFO] ChallengeStreamWatcher: Response from challenge request to hgducharme: <Response [200]>
2023-02-18 15:55:17,486 [DEBUG] EventStreamWatcher: From event stream: {'type': 'gameStart', 'game': {'fullId': 'SV0lgdphuXLO', 'gameId': 'SV0lgdph', 'fen': 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1', 'color': 'white', 'lastMove': '', 'source': 'friend', 'variant': {'key': 'standard', 'name': 'Standard'}, 'speed': 'bullet', 'perf': 'bullet', 'rated': False, 'hasMoved': False, 'opponent': {'id': 'hgducharme', 'username': 'hgducharme', 'rating': 867}, 'isMyTurn': True, 'secondsLeft': 60, 'compat': {'bot': True, 'board': False}, 'id': 'SV0lgdph'}}
2023-02-18 15:55:17,487 [INFO] EventStreamWatcher: Starting a new game.
2023-02-18 15:55:17,487 [DEBUG] ContinuousWorker: GameManager is not accepting games right now. Rejecting game SV0lgdphuXLO
2023-02-18 15:55:17,495 [DEBUG] EventStreamWatcher: Aborting/Declining game SV0lgdphuXLO

Behavior implementation should start inside EventStreamWatcher._dispatch_event_action()