diff --git a/mastochess.py b/mastochess.py index 2ebbdfa..72ac1e1 100644 --- a/mastochess.py +++ b/mastochess.py @@ -381,46 +381,6 @@ def check_games(): conn.close() -def get_status_url(toot_id): - - toot_id = str(toot_id.id) - - try: - - conn = None - - conn = psycopg2.connect(database = mastodon_db, user = mastodon_db_user, password = "", host = "/var/run/postgresql", port = "5432") - - cur = conn.cursor() - - select_query = "select uri from statuses where id=(%s)" - - cur.execute(select_query, (toot_id,)) - - row = cur.fetchone() - - if row != None: - - toot_url = row[0] - - else: - - toot_url = '' - - cur.close() - - return toot_url - - except (Exception, psycopg2.DatabaseError) as error: - - sys.exit(error) - - finally: - - if conn is not None: - - conn.close() - def new_game(toot_url): try: @@ -953,7 +913,7 @@ if __name__ == '__main__': toot_id = mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility, media_ids={image_id}) - toot_url = get_status_url(toot_id) + toot_url = toot_id.uri new_game(toot_url) @@ -979,7 +939,7 @@ if __name__ == '__main__': toot_text += '\n' - toot_text += "@"+white_user + ": et toca a tu" + "\n" + toot_text += "@"+white_user + ": el teu torn" + "\n" toot_text += '\n' @@ -1055,7 +1015,7 @@ if __name__ == '__main__': if board.is_check() == True: - toot_text = "@"+username + " t'ha fet escac!" + toot_text = "@"+playing_user + ": " + "@"+username + " t'ha fet escac!" if username == white_user: @@ -1069,7 +1029,9 @@ if __name__ == '__main__': if board.is_game_over() == True: - toot_text += "\nEscac i mat! \nEl guanyador és: " + "@"+username + '\n' + game_moves = board.ply() + + toot_text += "\nEscac i mat! (en " + str(game_moves) + " moviments)" + "\n\nEl guanyador és: " + "@"+username + '\n' toot_text += "\n@"+playing_user + ": ben jugat!" + "\n" @@ -1119,7 +1081,7 @@ if __name__ == '__main__': toot_id = mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility, media_ids={image_id}) - toot_url = get_status_url(toot_id) + toot_url = toot_id.uri board_game = board.fen() @@ -1234,8 +1196,6 @@ if __name__ == '__main__': mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility) - update_replies(status_id, username, now) - else: toot_text = "@"+username + " cap partida en joc" + "\n"