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()
|
||||
|
||||
|
Reference in New Issue
Block a user