change content from en_US to zh_TW
This commit is contained in:
142
bot.py
142
bot.py
@ -59,8 +59,7 @@ def notify_me(bot, update):
|
||||
if update.message.chat.type == 'private':
|
||||
send_async(bot,
|
||||
chat_id,
|
||||
text=_("Send this command in a group to be notified "
|
||||
"when a new game is started there."))
|
||||
text=_("在群組中傳送這個指令以讓我在這個群組開始遊戲時私訊你"))
|
||||
else:
|
||||
try:
|
||||
gm.remind_dict[chat_id].add(update.message.from_user.id)
|
||||
@ -82,7 +81,7 @@ def new_game(bot, update):
|
||||
for user in gm.remind_dict[update.message.chat_id]:
|
||||
send_async(bot,
|
||||
user,
|
||||
text=_("A new game has been started in {title}").format(
|
||||
text=_("新遊戲已經在 {title} 中開始!").format(
|
||||
title=update.message.chat.title))
|
||||
|
||||
del gm.remind_dict[update.message.chat_id]
|
||||
@ -90,8 +89,7 @@ def new_game(bot, update):
|
||||
game = gm.new_game(update.message.chat)
|
||||
game.owner = update.message.from_user
|
||||
send_async(bot, chat_id,
|
||||
text=_("Created a new game! Join the game with /join "
|
||||
"and start the game with /start"))
|
||||
text=_("已經開始新的遊戲! 用 /join 加入並用 /start 開始遊戲"))
|
||||
|
||||
if botan:
|
||||
botan.track(update.message, 'New games')
|
||||
@ -110,29 +108,26 @@ def join_game(bot, update):
|
||||
gm.join_game(update.message.from_user, chat)
|
||||
|
||||
except LobbyClosedError:
|
||||
send_async(bot, chat.id, text=_("The lobby is closed"))
|
||||
send_async(bot, chat.id, text=_("這場遊戲不開放其他人加入"))
|
||||
|
||||
except NoGameInChatError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("No game is running at the moment. "
|
||||
"Create a new game with /new"),
|
||||
text=_("目前沒有進行中的遊戲,輸入 /new 開始新的遊戲"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except AlreadyJoinedError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("You already joined the game. Start the game "
|
||||
"with /start"),
|
||||
text=_("您已加入本局遊戲,輸入 /start 來開始遊戲"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except DeckEmptyError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("There are not enough cards left in the deck for "
|
||||
"new players to join."),
|
||||
text=_("已經沒牌讓新玩家加入了"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("Joined the game"),
|
||||
text=_("已加入遊戲"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
|
||||
@ -145,8 +140,7 @@ def leave_game(bot, update):
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
|
||||
if player is None:
|
||||
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||
"this group."),
|
||||
send_async(bot, chat.id, text=_("你目前沒有在此聊天室中遊玩"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
|
||||
@ -157,17 +151,16 @@ def leave_game(bot, update):
|
||||
gm.leave_game(user, chat)
|
||||
|
||||
except NoGameInChatError:
|
||||
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||
"this group."),
|
||||
send_async(bot, chat.id, text=_("你目前沒有在此聊天室中遊玩"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except NotEnoughPlayersError:
|
||||
gm.end_game(chat, user)
|
||||
send_async(bot, chat.id, text=__("Game ended!", multi=game.translate))
|
||||
send_async(bot, chat.id, text=__("遊戲結束!", multi=game.translate))
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=__("Okay. Next Player: {name}",
|
||||
text=__("輪到:{name}",
|
||||
multi=game.translate).format(
|
||||
name=display_name(game.current_player.user)),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
@ -186,23 +179,22 @@ def select_game(bot, update):
|
||||
else:
|
||||
send_async(bot,
|
||||
update.callback_query.message.chat_id,
|
||||
text=_("Game not found."))
|
||||
text=_("找不到這場遊戲"))
|
||||
return
|
||||
|
||||
@run_async
|
||||
def selected(bot):
|
||||
back = [[InlineKeyboardButton(text=_("Back to last group"),
|
||||
back = [[InlineKeyboardButton(text=_("回到上一個群組"),
|
||||
switch_inline_query='')]]
|
||||
bot.answerCallbackQuery(update.callback_query.id,
|
||||
text=_("Please switch to the group you selected!"),
|
||||
text=_("請切換到你選擇的群組"),
|
||||
show_alert=False,
|
||||
timeout=TIMEOUT)
|
||||
|
||||
bot.editMessageText(chat_id=update.callback_query.message.chat_id,
|
||||
message_id=update.callback_query.message.message_id,
|
||||
text=_("Selected group: {group}\n"
|
||||
"<b>Make sure that you switch to the correct "
|
||||
"group!</b>").format(
|
||||
text=_("已選擇的群組: {group}\n"
|
||||
"<b>請確認你已經切換到目前遊玩中的群組!</b>").format(
|
||||
group=gm.userid_current[user_id].game.chat.title),
|
||||
reply_markup=InlineKeyboardMarkup(back),
|
||||
parse_mode=ParseMode.HTML,
|
||||
@ -227,10 +219,10 @@ def status_update(bot, update):
|
||||
pass
|
||||
except NotEnoughPlayersError:
|
||||
gm.end_game(chat, user)
|
||||
send_async(bot, chat.id, text=__("Game ended!",
|
||||
send_async(bot, chat.id, text=__("遊戲結束!",
|
||||
multi=game.translate))
|
||||
else:
|
||||
send_async(bot, chat.id, text=__("Removing {name} from the game",
|
||||
send_async(bot, chat.id, text=__("將 {name} 從遊戲中踢除",
|
||||
multi=game.translate)
|
||||
.format(name=display_name(user)))
|
||||
|
||||
@ -247,26 +239,23 @@ def start_game(bot, update, args):
|
||||
game = gm.chatid_games[chat.id][-1]
|
||||
except (KeyError, IndexError):
|
||||
send_async(bot, chat.id,
|
||||
text=_("There is no game running in this chat. Create "
|
||||
"a new one with /new"))
|
||||
text=_("此聊天室目前沒有遊戲進行中,使用 /new 開始新遊戲"))
|
||||
return
|
||||
|
||||
if game.started:
|
||||
send_async(bot, chat.id, text=_("The game has already started"))
|
||||
send_async(bot, chat.id, text=_("遊戲已經開始了!"))
|
||||
|
||||
elif len(game.players) < 2:
|
||||
send_async(bot, chat.id,
|
||||
text=_("At least two players must /join the game "
|
||||
"before you can start it"))
|
||||
text=_("至少要有兩個人 /join 才能開始遊戲"))
|
||||
|
||||
else:
|
||||
game.play_card(game.last_card)
|
||||
game.started = True
|
||||
|
||||
first_message = (
|
||||
__("First player: {name}\n"
|
||||
"Use /close to stop people from joining the game.\n"
|
||||
"Enable multi-translations with /enable_translations",
|
||||
__("由 {name} 開始出牌\n"
|
||||
"輸入 /close 以防止新玩家加入此局遊戲",
|
||||
multi=game.translate)
|
||||
.format(name=display_name(game.current_player.user)))
|
||||
|
||||
@ -300,7 +289,7 @@ def start_game(bot, update, args):
|
||||
)
|
||||
|
||||
send_async(bot, update.message.chat_id,
|
||||
text=_('Please select the group you want to play in.'),
|
||||
text=_("請選擇你要玩的群組"),
|
||||
reply_markup=InlineKeyboardMarkup(groups))
|
||||
|
||||
else:
|
||||
@ -316,20 +305,19 @@ def close_game(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("There is no running game in this chat."))
|
||||
text=_("此聊天室沒有正在進行的遊戲"))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.open = False
|
||||
send_async(bot, chat.id, text=_("Closed the lobby. "
|
||||
"No more players can join this game."))
|
||||
send_async(bot, chat.id, text=_("已禁止其他人加入這場遊戲"))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("Only the game creator ({name}) can do that.")
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -344,19 +332,18 @@ def open_game(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("There is no running game in this chat."))
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.open = True
|
||||
send_async(bot, chat.id, text=_("Opened the lobby. "
|
||||
"New players may /join the game."))
|
||||
send_async(bot, chat.id, text=_("已開放其他人加入,現在可以 /join 本局遊戲"))
|
||||
return
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -371,20 +358,20 @@ def enable_translations(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("There is no running game in this chat."))
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.translate = True
|
||||
send_async(bot, chat.id, text=_("Enabled multi-translations. "
|
||||
send_async(bot, chat.id, text=_("開啟翻譯(待移除)"
|
||||
"Disable with /disable_translations"))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -399,21 +386,20 @@ def disable_translations(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("There is no running game in this chat."))
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.translate = False
|
||||
send_async(bot, chat.id, text=_("Disabled multi-translations. "
|
||||
"Enable them again with "
|
||||
send_async(bot, chat.id, text=_("關閉翻譯(待移除)"
|
||||
"/enable_translations"))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -429,7 +415,7 @@ def skip_player(bot, update):
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
if not player:
|
||||
send_async(bot, chat.id,
|
||||
text=_("You are not playing in a game in this chat."))
|
||||
text=_("你目前沒有在此聊天室中遊玩"))
|
||||
return
|
||||
|
||||
game = player.game
|
||||
@ -443,8 +429,8 @@ def skip_player(bot, update):
|
||||
if delta < skipped_player.waiting_time:
|
||||
n = skipped_player.waiting_time - delta
|
||||
send_async(bot, chat.id,
|
||||
text=_("Please wait {time} second",
|
||||
"Please wait {time} seconds",
|
||||
text=_("請等待 {time} 秒",
|
||||
"請等待 {time} 秒",
|
||||
n)
|
||||
.format(time=n),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
@ -459,12 +445,10 @@ def skip_player(bot, update):
|
||||
|
||||
n = skipped_player.waiting_time
|
||||
send_async(bot, chat.id,
|
||||
text=__("Waiting time to skip this player has "
|
||||
"been reduced to {time} second.\n"
|
||||
"Next player: {name}",
|
||||
"Waiting time to skip this player has "
|
||||
"been reduced to {time} seconds.\n"
|
||||
"Next player: {name}",
|
||||
text=__("此玩家等待時間已經縮短為 {time} 秒\n"
|
||||
"輪到:{name}",
|
||||
"此玩家等待時間已經縮短為 {time} 秒\n"
|
||||
"輪到:{name}",
|
||||
n,
|
||||
multi=game.translate)
|
||||
.format(time=n,
|
||||
@ -475,17 +459,15 @@ def skip_player(bot, update):
|
||||
try:
|
||||
gm.leave_game(skipped_player.user, chat)
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name1} was skipped four times in a row "
|
||||
"and has been removed from the game.\n"
|
||||
"Next player: {name2}", multi=game.translate)
|
||||
text=__("{name1} 被跳過 4 次,已從此局遊戲中移除\n"
|
||||
"輪到:{name2}", multi=game.translate)
|
||||
.format(name1=display_name(skipped_player.user),
|
||||
name2=display_name(next_player.user)))
|
||||
|
||||
except NotEnoughPlayersError:
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} was skipped four times in a row "
|
||||
"and has been removed from the game.\n"
|
||||
"The game ended.", multi=game.translate)
|
||||
text=__("{name} 被跳過 4 次,已從此局遊戲中移除\n"
|
||||
"遊戲結束!", multi=game.translate)
|
||||
.format(name=display_name(skipped_player.user)))
|
||||
|
||||
gm.end_game(chat.id, skipped_player.user)
|
||||
@ -548,7 +530,7 @@ def reply_to_query(bot, update):
|
||||
result.id += ':%d' % player.anti_cheat
|
||||
|
||||
if players and game and len(players) > 1:
|
||||
switch = _('Current game: {game}').format(game=game.chat.title)
|
||||
switch = _('目前遊戲:{group}').format(game=game.chat.title)
|
||||
|
||||
answer_async(bot, update.inline_query.id, results, cache_time=0,
|
||||
switch_pm_text=switch, switch_pm_parameter='select')
|
||||
@ -582,7 +564,7 @@ def process_result(bot, update):
|
||||
return
|
||||
elif int(anti_cheat) != last_anti_cheat:
|
||||
send_async(bot, chat.id,
|
||||
text=__("Cheat attempt by {name}", multi=game.translate)
|
||||
text=__("{name} 提出了作弊嫌疑", multi=game.translate)
|
||||
.format(name=display_name(player.user)))
|
||||
return
|
||||
elif result_id == 'call_bluff':
|
||||
@ -601,7 +583,7 @@ def process_result(bot, update):
|
||||
|
||||
if game in gm.chatid_games.get(chat.id, list()):
|
||||
send_async(bot, chat.id,
|
||||
text=__("Next player: {name}", multi=game.translate)
|
||||
text=__("輪到:{name}", multi=game.translate)
|
||||
.format(name=display_name(game.current_player.user)))
|
||||
|
||||
|
||||
@ -612,8 +594,7 @@ def reset_waiting_time(bot, player):
|
||||
if player.waiting_time < 90:
|
||||
player.waiting_time = 90
|
||||
send_async(bot, chat.id,
|
||||
text=__("Waiting time for {name} has been reset to 90 "
|
||||
"seconds", multi=player.game.translate)
|
||||
text=__("{name} 的等待時間已重置為 90 秒", multi=player.game.translate)
|
||||
.format(name=display_name(player.user)))
|
||||
|
||||
|
||||
@ -633,14 +614,14 @@ def do_play_card(bot, player, result_id):
|
||||
us.cards_played += 1
|
||||
|
||||
if game.choosing_color:
|
||||
send_async(bot, chat.id, text=_("Please choose a color"))
|
||||
send_async(bot, chat.id, text=_("請選擇一個顏色"))
|
||||
|
||||
if len(player.cards) == 1:
|
||||
send_async(bot, chat.id, text="UNO!")
|
||||
|
||||
if len(player.cards) == 0:
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} won!", multi=game.translate)
|
||||
text=__("{name} 贏了!", multi=game.translate)
|
||||
.format(name=user.first_name))
|
||||
|
||||
if us.stats:
|
||||
@ -655,7 +636,7 @@ def do_play_card(bot, player, result_id):
|
||||
gm.leave_game(user, chat)
|
||||
except NotEnoughPlayersError:
|
||||
send_async(bot, chat.id,
|
||||
text=__("Game ended!", multi=game.translate))
|
||||
text=__("遊戲結束!", multi=game.translate))
|
||||
|
||||
us2 = UserSetting.get(id=game.current_player.user.id)
|
||||
if us2 and us2.stats:
|
||||
@ -678,8 +659,7 @@ def do_draw(bot, player):
|
||||
player.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("There are no more cards in the deck.",
|
||||
multi=game.translate))
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
|
||||
if (game.last_card.value == c.DRAW_TWO or
|
||||
game.last_card.special == c.DRAW_FOUR) and \
|
||||
@ -694,7 +674,7 @@ def do_call_bluff(bot, player):
|
||||
|
||||
if player.prev.bluffing:
|
||||
send_async(bot, chat.id,
|
||||
text=__("Bluff called! Giving 4 cards to {name}",
|
||||
text=__("作弊已確認!作為懲罰,給予 {name} 4 張牌",
|
||||
multi=game.translate)
|
||||
.format(name=player.prev.user.first_name))
|
||||
|
||||
@ -702,13 +682,12 @@ def do_call_bluff(bot, player):
|
||||
player.prev.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("There are no more cards in the deck.",
|
||||
multi=game.translate))
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
|
||||
else:
|
||||
game.draw_counter += 2
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name1} didn't bluff! Giving 6 cards to {name2}",
|
||||
text=__("{name1} 沒有作弊!作為懲罰,給予 {name2} 六張牌",
|
||||
multi=game.translate)
|
||||
.format(name1=player.prev.user.first_name,
|
||||
name2=player.user.first_name))
|
||||
@ -716,8 +695,7 @@ def do_call_bluff(bot, player):
|
||||
player.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("There are no more cards in the deck.",
|
||||
multi=game.translate))
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
|
||||
game.turn()
|
||||
|
||||
|
36
results.py
36
results.py
@ -36,7 +36,7 @@ def add_choose_color(results, game):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
id=color,
|
||||
title=_("Choose Color"),
|
||||
title=_("選擇顏色"),
|
||||
description=display_color(color),
|
||||
input_message_content=
|
||||
InputTextMessageContent(display_color_group(color, game))
|
||||
@ -50,8 +50,8 @@ def add_other_cards(player, results, game):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"hand",
|
||||
title=_("Card (tap for game state):",
|
||||
"Cards (tap for game state):",
|
||||
title=_("你的手牌(點一下以獲得遊戲狀態):",
|
||||
"你的手牌(點一下以獲得遊戲狀態):",
|
||||
len(player.cards)),
|
||||
description=', '.join([repr(card) for card in player.cards]),
|
||||
input_message_content=game_info(game)
|
||||
@ -61,8 +61,8 @@ def add_other_cards(player, results, game):
|
||||
|
||||
def player_list(game):
|
||||
"""Generate list of player strings"""
|
||||
return [_("{name} ({number} card)",
|
||||
"{name} ({number} cards)",
|
||||
return [_("{name}(有 {number} 張牌)",
|
||||
"{name}(有 {number} 張牌)",
|
||||
len(player.cards))
|
||||
.format(name=player.user.first_name, number=len(player.cards))
|
||||
for player in game.players]
|
||||
@ -73,11 +73,9 @@ def add_no_game(results):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"nogame",
|
||||
title=_("You are not playing"),
|
||||
title=_("你沒有在遊戲中"),
|
||||
input_message_content=
|
||||
InputTextMessageContent(_('Not playing right now. Use /new to '
|
||||
'start a game or /join to join the '
|
||||
'current game in this group'))
|
||||
InputTextMessageContent(_('你目前沒有在遊玩,使用 /new@unobot 開始新的遊戲或使用 /join@unobot 加入目前的遊戲'))
|
||||
)
|
||||
)
|
||||
|
||||
@ -87,9 +85,9 @@ def add_not_started(results):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"nogame",
|
||||
title=_("The game wasn't started yet"),
|
||||
title=_("遊戲尚未開始"),
|
||||
input_message_content=
|
||||
InputTextMessageContent(_('Start the game with /start'))
|
||||
InputTextMessageContent(_('使用 /start 開始遊戲'))
|
||||
)
|
||||
)
|
||||
|
||||
@ -102,8 +100,8 @@ def add_draw(player, results):
|
||||
Sticker(
|
||||
"draw", sticker_file_id=c.STICKERS['option_draw'],
|
||||
input_message_content=
|
||||
InputTextMessageContent(__('Drawing {number} card',
|
||||
'Drawing {number} cards', n,
|
||||
InputTextMessageContent(__('抽 {number} 張牌',
|
||||
'抽 {number} 張牌', n,
|
||||
multi=player.game.translate)
|
||||
.format(number=n))
|
||||
)
|
||||
@ -128,7 +126,7 @@ def add_pass(results, game):
|
||||
Sticker(
|
||||
"pass", sticker_file_id=c.STICKERS['option_pass'],
|
||||
input_message_content=InputTextMessageContent(
|
||||
__('Pass', multi=game.translate)
|
||||
__('Pass!下一位', multi=game.translate)
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -141,7 +139,7 @@ def add_call_bluff(results, game):
|
||||
"call_bluff",
|
||||
sticker_file_id=c.STICKERS['option_bluff'],
|
||||
input_message_content=
|
||||
InputTextMessageContent(__("I'm calling your bluff!",
|
||||
InputTextMessageContent(__("你作弊,一定還有其他牌可以出!",
|
||||
multi=game.translate))
|
||||
)
|
||||
)
|
||||
@ -164,13 +162,13 @@ def add_card(game, card, results, can_play):
|
||||
def game_info(game):
|
||||
players = player_list(game)
|
||||
return InputTextMessageContent(
|
||||
_("Current player: {name}")
|
||||
_("目前玩家:{name}")
|
||||
.format(name=display_name(game.current_player.user)) +
|
||||
"\n" +
|
||||
_("Last card: {card}").format(card=repr(game.last_card)) +
|
||||
_("最後的牌:{card}").format(card=repr(game.last_card)) +
|
||||
"\n" +
|
||||
_("Player: {player_list}",
|
||||
"Players: {player_list}",
|
||||
_("玩家列表:{player_list}",
|
||||
"玩家列表:{player_list}",
|
||||
len(players))
|
||||
.format(player_list=" -> ".join(players))
|
||||
)
|
19
settings.py
19
settings.py
@ -34,8 +34,7 @@ def show_settings(bot, update):
|
||||
|
||||
if update.message.chat.type != 'private':
|
||||
send_async(bot, chat.id,
|
||||
text=_("Please edit your settings in a private chat with "
|
||||
"the bot."))
|
||||
text=_("請私訊我來修改你的設定"))
|
||||
return
|
||||
|
||||
us = UserSetting.get(id=update.message.from_user.id)
|
||||
@ -44,12 +43,12 @@ def show_settings(bot, update):
|
||||
us = UserSetting(id=update.message.from_user.id)
|
||||
|
||||
if not us.stats:
|
||||
stats = Emoji.BAR_CHART + ' ' + _("Enable statistics")
|
||||
stats = Emoji.BAR_CHART + ' ' + _("啟用統計資料")
|
||||
else:
|
||||
stats = Emoji.CROSS_MARK + ' ' + _("Delete all statistics")
|
||||
stats = Emoji.CROSS_MARK + ' ' + _("刪除所有統計資料")
|
||||
|
||||
kb = [[stats], [Emoji.EARTH_GLOBE_EUROPE_AFRICA + ' ' + _("Language")]]
|
||||
send_async(bot, chat.id, text=Emoji.WRENCH + ' ' + _("Settings"),
|
||||
kb = [[stats], [Emoji.EARTH_GLOBE_EUROPE_AFRICA + ' ' + _("語言")]]
|
||||
send_async(bot, chat.id, text=Emoji.WRENCH + ' ' + _("設定"),
|
||||
reply_markup=ReplyKeyboardMarkup(keyboard=kb,
|
||||
one_time_keyboard=True))
|
||||
|
||||
@ -63,13 +62,13 @@ def kb_select(bot, update, groups):
|
||||
if option == Emoji.BAR_CHART:
|
||||
us = UserSetting.get(id=user.id)
|
||||
us.stats = True
|
||||
send_async(bot, chat.id, text=_("Enabled statistics!"))
|
||||
send_async(bot, chat.id, text=_("已啟用統計資料!"))
|
||||
|
||||
elif option == Emoji.EARTH_GLOBE_EUROPE_AFRICA:
|
||||
kb = [[locale + ' - ' + descr]
|
||||
for locale, descr
|
||||
in sorted(available_locales.items())]
|
||||
send_async(bot, chat.id, text=_("Select locale"),
|
||||
send_async(bot, chat.id, text=_("選擇語言"),
|
||||
reply_markup=ReplyKeyboardMarkup(keyboard=kb,
|
||||
one_time_keyboard=True))
|
||||
|
||||
@ -79,7 +78,7 @@ def kb_select(bot, update, groups):
|
||||
us.first_places = 0
|
||||
us.games_played = 0
|
||||
us.cards_played = 0
|
||||
send_async(bot, chat.id, text=_("Deleted and disabled statistics!"))
|
||||
send_async(bot, chat.id, text=_("已停用並刪除統計資料!"))
|
||||
|
||||
|
||||
@user_locale
|
||||
@ -92,7 +91,7 @@ def locale_select(bot, update, groups):
|
||||
us = UserSetting.get(id=user.id)
|
||||
us.lang = option
|
||||
_.push(option)
|
||||
send_async(bot, chat.id, text=_("Set locale!"))
|
||||
send_async(bot, chat.id, text=_("已設定所選擇的語言"))
|
||||
_.pop()
|
||||
|
||||
|
||||
|
@ -25,42 +25,31 @@ from utils import send_async
|
||||
from shared_vars import dispatcher
|
||||
from internationalization import _, user_locale
|
||||
|
||||
help_text = ("Follow these steps:\n\n"
|
||||
"1. Add this bot to a group\n"
|
||||
"2. In the group, start a new game with /new or join an already"
|
||||
" running game with /join\n"
|
||||
"3. After at least two players have joined, start the game with"
|
||||
" /start\n"
|
||||
"4. Type <code>@unobot</code> into your chat box and hit "
|
||||
"<b>space</b>, or click the <code>via @unobot</code> text "
|
||||
"next to messages. You will see your cards (some greyed out), "
|
||||
"any extra options like drawing, and a <b>?</b> to see the "
|
||||
"current game state. The <b>greyed out cards</b> are those you "
|
||||
"<b>can not play</b> at the moment. Tap an option to execute "
|
||||
"the selected action.\n"
|
||||
"Players can join the game at any time. To leave a game, "
|
||||
"use /leave. If a player takes more than 90 seconds to play, "
|
||||
"you can use /skip to skip that player. Use /notify_me to "
|
||||
"receive a private message when a new game is started.\n\n"
|
||||
"<b>Language</b> and other settings: /settings\n"
|
||||
"Other commands (only game creator):\n"
|
||||
"/close - Close lobby\n"
|
||||
"/open - Open lobby\n"
|
||||
"/enable_translations - Translate relevant texts into all "
|
||||
"languages spoken in a game\n"
|
||||
"/disable_translations - Use English for those texts\n\n"
|
||||
"<b>Experimental:</b> Play in multiple groups at the same time. "
|
||||
"Press the <code>Current game: ...</code> button and select the "
|
||||
"group you want to play a card in.\n"
|
||||
"If you enjoy this bot, "
|
||||
"<a href=\"https://telegram.me/storebot?start=mau_mau_bot\">"
|
||||
"rate me</a>, join the "
|
||||
"<a href=\"https://telegram.me/unobotupdates\">update channel</a>"
|
||||
" and buy an UNO card game.")
|
||||
help_text = ("請跟隨以下指示:\n\n"
|
||||
"1. 將這個機器人新增到群組\n"
|
||||
"2. 輸入 /new 開始一個新遊戲或輸入 /join 加入一個運行中的遊戲\n"
|
||||
"3. 當有兩個或以上的玩家加入, 就可以用 /start 開始遊戲\n"
|
||||
"4. 輸入 <code>@unobot</code> 然後按<b>空白鍵</b> 或點一下"
|
||||
"<code>via @unobot</code>。之後你會看見你手上的牌或者其他選項例如 DRAW(抽牌),和"
|
||||
"<b>?</b>看其他玩家狀態。但<b>灰色的牌</b>就是<b>你現在不能使用的牌</b>,選擇其中一個"
|
||||
"選項來執行對應的操作。\n"
|
||||
"玩家可以在任何時間加入,如果想離開,請打 /leave 。如果玩家90秒後都沒有出牌"
|
||||
",你可以用 /skip 跳過他。輸入 /notify_me 以讓我在本群組遊戲開始時私訊你\n"
|
||||
"\n"
|
||||
"<b>語言</b>和其他設定: /settings\n"
|
||||
"遊戲創始人可以用以下的指令:\n"
|
||||
"/close - 令其他人不可以中途加入\n"
|
||||
"/open - 令其他人可以中途加入\n"
|
||||
"<b>試驗功能:</b> 同時在不同的群組中遊玩 請選擇 <code>目前遊戲:...</code>"
|
||||
"然後選擇你想在哪個群組玩。\n"
|
||||
"如果你喜歡這個 bot,你可以選擇買一副 UNO 牌來支持 UNO!")
|
||||
|
||||
source_text = ("This bot is Free Software and licensed under the AGPL. "
|
||||
"The code is available here: \n"
|
||||
"https://github.com/jh0ker/mau_mau_bot")
|
||||
source_text = ("這個 bot 是一個免費的軟體,根據 AGPL 授權 \n"
|
||||
"原始碼可以在這裡找到:\n"
|
||||
"https://github.com/PinLin/mau_mau_bot\n"
|
||||
"I fork from:\n"
|
||||
"https://github.com/jh0ker/mau_mau_bot\n"
|
||||
"Thanks very much!")
|
||||
attributions = ("Attributions:\n"
|
||||
'Draw icon by '
|
||||
'<a href="http://www.faithtoken.com/">Faithtoken</a>\n'
|
||||
@ -99,29 +88,29 @@ def stats(bot, update):
|
||||
us = UserSetting.get(id=user.id)
|
||||
if not us or not us.stats:
|
||||
send_async(bot, update.message.chat_id,
|
||||
text=_("You did not enable statistics. Use /settings in "
|
||||
"a private chat with the bot to enable them."))
|
||||
text=_("您尚未啟用統計資料,請私我 "
|
||||
"<code>/settings</code> 來啟用他"))
|
||||
else:
|
||||
stats_text = list()
|
||||
|
||||
n = us.games_played
|
||||
stats_text.append(
|
||||
_("{number} game played",
|
||||
"{number} games played",
|
||||
_("已遊玩 {number} 個遊戲",
|
||||
"已遊玩 {number} 個遊戲",
|
||||
n).format(number=n)
|
||||
)
|
||||
|
||||
n = us.first_places
|
||||
stats_text.append(
|
||||
_("{number} first place",
|
||||
"{number} first places",
|
||||
_("拿了 {number} 次第一名",
|
||||
"拿了 {number} 次第一名",
|
||||
n).format(number=n)
|
||||
)
|
||||
|
||||
n = us.cards_played
|
||||
stats_text.append(
|
||||
_("{number} card played",
|
||||
"{number} cards played",
|
||||
_("已遊玩 {number} 張牌",
|
||||
"已遊玩 {number} 張牌",
|
||||
n).format(number=n)
|
||||
)
|
||||
|
||||
@ -132,5 +121,5 @@ def stats(bot, update):
|
||||
def register():
|
||||
dispatcher.add_handler(CommandHandler('help', help))
|
||||
dispatcher.add_handler(CommandHandler('source', source))
|
||||
dispatcher.add_handler(CommandHandler('news', news))
|
||||
# dispatcher.add_handler(CommandHandler('news', news))
|
||||
dispatcher.add_handler(CommandHandler('stats', stats))
|
||||
|
16
utils.py
16
utils.py
@ -51,28 +51,28 @@ def display_name(user):
|
||||
def display_color(color):
|
||||
""" Convert a color code to actual color name """
|
||||
if color == "r":
|
||||
return _("{emoji} Red").format(emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
return _("{emoji} 紅色").format(emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
if color == "b":
|
||||
return _("{emoji} Blue").format(emoji=Emoji.BLUE_HEART)
|
||||
return _("{emoji} 藍色").format(emoji=Emoji.BLUE_HEART)
|
||||
if color == "g":
|
||||
return _("{emoji} Green").format(emoji=Emoji.GREEN_HEART)
|
||||
return _("{emoji} 綠色").format(emoji=Emoji.GREEN_HEART)
|
||||
if color == "y":
|
||||
return _("{emoji} Yellow").format(emoji=Emoji.YELLOW_HEART)
|
||||
return _("{emoji} 黃色").format(emoji=Emoji.YELLOW_HEART)
|
||||
|
||||
|
||||
def display_color_group(color, game):
|
||||
""" Convert a color code to actual color name """
|
||||
if color == "r":
|
||||
return __("{emoji} Red", game.translate).format(
|
||||
return __("{emoji} 紅色", game.translate).format(
|
||||
emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
if color == "b":
|
||||
return __("{emoji} Blue", game.translate).format(
|
||||
return __("{emoji} 藍色", game.translate).format(
|
||||
emoji=Emoji.BLUE_HEART)
|
||||
if color == "g":
|
||||
return __("{emoji} Green", game.translate).format(
|
||||
return __("{emoji} 綠色", game.translate).format(
|
||||
emoji=Emoji.GREEN_HEART)
|
||||
if color == "y":
|
||||
return __("{emoji} Yellow", game.translate).format(
|
||||
return __("{emoji} 黃色", game.translate).format(
|
||||
emoji=Emoji.YELLOW_HEART)
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user