Added fediverse support! Any fediverse user can play Mastodon Chess!

This commit is contained in:
spla 2020-11-28 20:12:36 +01:00
pare 5c7849342c
commit 794beece51
S'han modificat 4 arxius amb 32 adicions i 8 eliminacions

Veure arxiu

@ -12,6 +12,7 @@ send_error: error al enviar les anotacions :-(
game_number_anotations: les anotacions de la partida n. game_number_anotations: les anotacions de la partida n.
anotations_sent: enviades amb èxit! anotations_sent: enviades amb èxit!
game_no_exists: la partida n. game_no_exists: la partida n.
cant_send_to_fediverse_account: per ara no és possible :-(
it_not_exists: no existeix... it_not_exists: no existeix...
game_already_started: ja tenies iniciada una partida! game_already_started: ja tenies iniciada una partida!
wait_other_player: espera l'altre jugador wait_other_player: espera l'altre jugador

Veure arxiu

@ -12,6 +12,7 @@ send_error: sending anotations error :-(
game_number_anotations: the anotations of game n. game_number_anotations: the anotations of game n.
anotations_sent: succesfully sent! anotations_sent: succesfully sent!
game_no_exists: the game n. game_no_exists: the game n.
cant_send_to_fediverse_account: not possible yet :-(
it_not_exists: don't exists... it_not_exists: don't exists...
game_already_started: you already started a game! game_already_started: you already started a game!
wait_other_player: wait for the second player wait_other_player: wait for the second player

Veure arxiu

@ -12,6 +12,7 @@ send_error: error al enviar las anotaciones :-(
game_number_anotations: las anotaciones de la partida n. game_number_anotations: las anotaciones de la partida n.
anotations_sent: enviades con éxito! anotations_sent: enviades con éxito!
game_no_exists: la partida n. game_no_exists: la partida n.
cant_send_to_fediverse_account: por ahora no es posible :-(
it_not_exists: no existe... it_not_exists: no existe...
game_already_started: ja tenias iniciada una partida! game_already_started: ja tenias iniciada una partida!
wait_other_player: espera al otro jugador wait_other_player: espera al otro jugador

Veure arxiu

@ -612,7 +612,13 @@ def get_email_address(username):
row = cur.fetchone() row = cur.fetchone()
username_email = row[0] if row != None:
username_email = row[0]
else:
username_email = None
cur.close() cur.close()
@ -636,6 +642,10 @@ def send_anotation(game_id):
username_email = get_email_address(username) username_email = get_email_address(username)
if username_email == None:
return (emailed, game_id, game_found)
# Create message object instance # Create message object instance
msg = MIMEMultipart() msg = MIMEMultipart()
@ -1042,12 +1052,13 @@ def load_strings1(bot_lang):
game_no_exists = get_parameter("game_no_exists", language_filepath) game_no_exists = get_parameter("game_no_exists", language_filepath)
it_not_exists = get_parameter("it_not_exists", language_filepath) it_not_exists = get_parameter("it_not_exists", language_filepath)
game_already_started = get_parameter("game_already_started", language_filepath) game_already_started = get_parameter("game_already_started", language_filepath)
cant_send_to_fediverse_account = get_parameter("cant_send_to_fediverse_account", language_filepath)
wait_other_player = get_parameter("wait_other_player", language_filepath) wait_other_player = get_parameter("wait_other_player", language_filepath)
is_not_legal_move = get_parameter("is_not_legal_move", language_filepath) is_not_legal_move = get_parameter("is_not_legal_move", language_filepath)
check_done = get_parameter("check_done", language_filepath) check_done = get_parameter("check_done", language_filepath)
check_mate = get_parameter("check_mate", language_filepath) check_mate = get_parameter("check_mate", language_filepath)
return (game_number_anotations, anotations_sent, game_no_exists, it_not_exists, game_already_started, wait_other_player, is_not_legal_move, check_done, check_mate) return (game_number_anotations, anotations_sent, game_no_exists, cant_send_to_fediverse_account, it_not_exists, game_already_started, wait_other_player, is_not_legal_move, check_done, check_mate)
def load_strings2(bot_lang): def load_strings2(bot_lang):
@ -1235,7 +1246,7 @@ if __name__ == '__main__':
search_end, search_move, search_new, search_games, search_send, new_game_started, playing_with, your_turn, game_name, chess_hashtag, send_error = load_strings(bot_lang) search_end, search_move, search_new, search_games, search_send, new_game_started, playing_with, your_turn, game_name, chess_hashtag, send_error = load_strings(bot_lang)
game_number_anotations, anotations_sent, game_no_exists, it_not_exists, game_already_started, wait_other_player, is_not_legal_move, check_done, check_mate = load_strings1(bot_lang) game_number_anotations, anotations_sent, game_no_exists, cant_send_to_fediverse_account, it_not_exists, game_already_started, wait_other_player, is_not_legal_move, check_done, check_mate = load_strings1(bot_lang)
check_mate_movements, the_winner_is, well_done, winned_games, wins_of_many, lost_piece, not_legal_move_str, player_leave_game = load_strings2(bot_lang) check_mate_movements, the_winner_is, well_done, winned_games, wins_of_many, lost_piece, not_legal_move_str, player_leave_game = load_strings2(bot_lang)
@ -1266,21 +1277,25 @@ if __name__ == '__main__':
username, domain = get_user_domain(account_id) username, domain = get_user_domain(account_id)
if domain != None:
username = username + '@' + domain
status_id = status_id_lst[i] status_id = status_id_lst[i]
replied = check_replies(status_id) replied = check_replies(status_id)
if replied == True or domain != None: if replied == True: #or domain != None:
i += 1 i += 1
continue continue
if domain != None: #if domain != None:
update_replies(username, status_id) #update_replies(username, status_id)
i += 1 #i += 1
# listen them or not # listen them or not
@ -1384,7 +1399,13 @@ if __name__ == '__main__':
elif emailed == False and game_found == False: elif emailed == False and game_found == False:
toot_text = '@'+username + ' ' + game_no_exists + str(game_id) + ' ' + it_not_exists if domain != None:
toot_text = '@'+username + ' ' + cant_send_to_fediverse_account
else:
toot_text = '@'+username + ' ' + game_no_exists + str(game_id) + ' ' + it_not_exists
mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility) mastodon.status_post(toot_text, in_reply_to_id=status_id,visibility=visibility)