diff --git a/README.md b/README.md index a2c0a38..20a9cbc 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ Mastodon Chess (mastochess) uses [python-chess](https://python-chess.readthedocs ### How to play: +To get help: + +@your_bot_username help + To start a game: @your_bot_username new @@ -71,4 +75,5 @@ Within Python Virtual Environment: 25.11.2020 - New feature! Get any game anotations via email (see point 3 above). 27.11.2020 - New feature! Pawn promotion and locales support ( ca & eng ) 28.11.2020 - New feature! Added 'es' locale support -28.11.2020 - New feature! Now any fediverse user can play Mastodon Chess! +28.11.2020 - New feature! Now any fediverse user can play Mastodon Chess! +28.11.2020 - New feature! Added help diff --git a/locales/ca.txt b/locales/ca.txt index 439a2c4..0c1dae6 100644 --- a/locales/ca.txt +++ b/locales/ca.txt @@ -3,6 +3,7 @@ search_move: mou search_new: nova search_games: jocs search_send: envia +search_help: ajuda new_game_started: partida iniciada! Esperant jugador... playing_with: jugues amb your_turn: el teu torn @@ -47,3 +48,11 @@ rook_piece_letter: T queen_piece_letter: D king_piece_letter: R email_subject: Anotacions partida n. +start_or_join_a_new_game: nova (iniciar partida o unirse a una en espera) +move_a_piece: mou e2e3 (per exemple) +leave_a_game: fi (per a deixar la partida en qualsevol moment) +list_games: jocs (mostra un llistat de partides actives) +get_a_game_anotation: envia 1 (1 és el número de la partida. Envia les anotacions de la partida per correu electrònic, només usuaris del servidor local) +show_help: ajuda (mostra aquesta ajuda i, per tant, és l'ajuda de l'ajuda) + + diff --git a/locales/en.txt b/locales/en.txt index 6387db3..f94a778 100644 --- a/locales/en.txt +++ b/locales/en.txt @@ -3,6 +3,7 @@ search_move: move search_new: new search_games: games search_send: send +search_help: help new_game_started: game started! Waiting for the second player... playing_with: you play with your_turn: it's your turn @@ -47,3 +48,11 @@ rook_piece_letter: R queen_piece_letter: Q king_piece_letter: K email_subject: Anotations of game n. +start_or_join_a_new_game: new (start a new game or join a waiting one) +move_a_piece: move e2e3 (in ex.) +leave_a_game: end (to leave the game any time) +list_games: games (show an on going games list) +get_a_game_anotation: send 1 (1 is the game number. It send the game's anotations by email but local users only) +show_help: help (show this help so, it's the help of the help) + + diff --git a/locales/es.txt b/locales/es.txt index 6cbd5b1..0464870 100644 --- a/locales/es.txt +++ b/locales/es.txt @@ -3,6 +3,7 @@ search_move: mueve search_new: nueva search_games: partidas search_send: envia +search_help: ayuda new_game_started: partida iniciada! Esperando jugador... playing_with: juegas con your_turn: tu turno @@ -47,3 +48,11 @@ rook_piece_letter: T queen_piece_letter: D king_piece_letter: R email_subject: Anotaciones partida n. +start_or_join_a_new_game: nueva (empezar una partida o unirse a una en espera) +move_a_piece: mueve e2e3 (por ejemplo) +leave_a_game: fin (para dejar la partida en cualquier momento) +list_games: partidas (muestra un listado de partidas activas) +get_a_game_anotation: envia 1 (1 es el número de la partida. Envia las anotaciones de la partida pedida por correo electrónico pero sólo a usuarios del servidor local) +show_help: ayuda (muestra esta ayuda y, por tanto, es la ayuda de la ayuda) + + diff --git a/mastochess.py b/mastochess.py index 4f7b0cc..bb43bbd 100644 --- a/mastochess.py +++ b/mastochess.py @@ -167,7 +167,7 @@ def get_notification_data(): url_lst = [] - search_text = [search_end, search_move, search_new, search_games, search_send] + search_text = [search_end, search_move, search_new, search_games, search_send, search_help] conn = None @@ -964,6 +964,24 @@ def next_move(playing_user): conn.close() +def toot_help(): + + help_text = '@'+username + ' ' + search_help + ':\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + start_or_join_a_new_game + '\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + move_a_piece + '\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + leave_a_game + '\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + list_games + '\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + get_a_game_anotation + '\n' + help_text += '\n' + help_text += '@'+bot_username + ' ' + show_help + '\n' + + return help_text + def replying(): reply = False @@ -1019,6 +1037,10 @@ def replying(): reply = True + elif query_word == search_help: + + reply = True + else: reply = False @@ -1036,6 +1058,7 @@ def load_strings(bot_lang): search_new = get_parameter("search_new", language_filepath) search_games = get_parameter("search_games", language_filepath) search_send = get_parameter("search_send", language_filepath) + search_help = get_parameter("search_help", language_filepath) new_game_started = get_parameter("new_game_started", language_filepath) playing_with = get_parameter("playing_with", language_filepath) your_turn = get_parameter("your_turn", language_filepath) @@ -1043,7 +1066,7 @@ def load_strings(bot_lang): chess_hashtag = get_parameter("chess_hashtag", language_filepath) send_error = get_parameter("send_error", language_filepath) - return (search_end, search_move, search_new, search_games, search_send, new_game_started, playing_with, your_turn, game_name, chess_hashtag, send_error) + return (search_end, search_move, search_new, search_games, search_send, search_help, new_game_started, playing_with, your_turn, game_name, chess_hashtag, send_error) def load_strings1(bot_lang): @@ -1108,6 +1131,17 @@ def load_strings5(bot_lang): return (pawn_piece_letter, knight_piece_letter, bishop_piece_letter, rook_piece_letter, queen_piece_letter, king_piece_letter, email_subject) +def load_strings6(bot_lang): + + start_or_join_a_new_game = get_parameter("start_or_join_a_new_game", language_filepath) + move_a_piece = get_parameter("move_a_piece", language_filepath) + leave_a_game = get_parameter("leave_a_game", language_filepath) + list_games = get_parameter("list_games", language_filepath) + get_a_game_anotation = get_parameter("get_a_game_anotation", language_filepath) + show_help = get_parameter("show_help", language_filepath) + + return (start_or_join_a_new_game, move_a_piece, leave_a_game, list_games, get_a_game_anotation, show_help) + def mastodon(): # Load secrets from secrets file @@ -1244,7 +1278,7 @@ if __name__ == '__main__': search_send_slicing = 5 send_game_slicing = 6 - 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, search_help, 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, 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) @@ -1256,6 +1290,8 @@ if __name__ == '__main__': pawn_piece_letter, knight_piece_letter, bishop_piece_letter, rook_piece_letter, queen_piece_letter, king_piece_letter, email_subject = load_strings5(bot_lang) + start_or_join_a_new_game, move_a_piece, leave_a_game, list_games, get_a_game_anotation, show_help = load_strings6(bot_lang) + mastodon, mastodon_hostname, bot_username = mastodon() mastodon_db, mastodon_db_user, chess_db, chess_db_user = db_config() @@ -1411,6 +1447,14 @@ if __name__ == '__main__': update_replies(status_id, username, now) + elif query_word == search_help: + + help_text = toot_help() + + mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility) + + update_replies(status_id, username, now) + else: update_replies(status_id, username, now) @@ -1746,6 +1790,14 @@ if __name__ == '__main__': update_replies(status_id, username, now) + elif query_word == search_help: + + help_text = toot_help() + + mastodon.status_post(help_text, in_reply_to_id=status_id,visibility=visibility) + + update_replies(status_id, username, now) + else: if playing_user == None: