From 59728317c798082bee1ce3e8956d907f3f6540a3 Mon Sep 17 00:00:00 2001 From: Mark Powers Date: Sat, 19 Feb 2022 21:12:59 -0600 Subject: Initial commit --- pending_chess.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 pending_chess.py (limited to 'pending_chess.py') diff --git a/pending_chess.py b/pending_chess.py new file mode 100755 index 0000000..0cb1c24 --- /dev/null +++ b/pending_chess.py @@ -0,0 +1,28 @@ +#!/usr/bin/python3 +import chessdotcom +import chess +import datetime + +player = "steveclarney" + +lst = [] +data = chessdotcom.get_player_current_games(player) +for game in data.json["games"]: + white_player = game["white"][33:] + black_player = game["black"][33:] + player_side = "white" if player == white_player else "black" + other_player= white_player if player_side == "black" else black_player + game_type = game["rules"] + due = datetime.datetime.fromtimestamp(game["move_by"]) + if game["turn"] == player_side: + status = "Move by "+str(due) + else: + status = "Waiting..." + board = chess.Board(game["fen"]) + if player_side == "black": + board = board.transform(chess.flip_vertical) + board = board.transform(chess.flip_horizontal) + board_str = str(board.unicode(invert_color=True, empty_square=".")) + lst.append("vs. " + other_player + "\n" + status + "\n" + board_str) + +print(*[''.join(x) for x in zip(*[[x.ljust(29) for x in s.split('\n')] for s in lst])], sep='\n') -- cgit v1.2.3