Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
9234e3858f |
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,9 +1,3 @@
|
||||
# macOS
|
||||
.DS_Store
|
||||
|
||||
# Pyenv
|
||||
.python-version
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
@ -7,6 +7,5 @@
|
||||
The following wonderful people contributed directly or indirectly to this project:
|
||||
|
||||
- [imlonghao](https://github.com/imlonghao)
|
||||
- [qubitnerd](https://github.com/qubitnerd)
|
||||
|
||||
Please add yourself here alphabetically when you submit your first pull request.
|
18
README.md
18
README.md
@ -1,20 +1,10 @@
|
||||
# UNO Bot (zh_TW)
|
||||
|
||||
[](./LICENSE)
|
||||
|
||||
forked from [jh0ker/mau_mau_bot](https://github.com/jh0ker/mau_mau_bot)
|
||||
|
||||
Telegram Bot that allows you to play the popular card game UNO via inline queries.
|
||||
# UNO Bot
|
||||
Telegram Bot that allows you to play the popular card game UNO via inline queries. The bot currently runs as [@mau_mau_bot](http://telegram.me/mau_mau_bot)
|
||||
|
||||
To run the bot yourself, you will need:
|
||||
- Python (tested with 3.4 and 3.5)
|
||||
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module version 5.0.0
|
||||
- [Pony ORM](https://ponyorm.com/)
|
||||
- The [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) module version 4.1.1
|
||||
|
||||
## Setup
|
||||
- Get a bot token from [@BotFather](http://telegram.me/BotFather) and place it in `credentials.py`
|
||||
- Use `/setinline` and `/setinlinefeedback` with BotFather for your bot
|
||||
|
||||
Then run the bot with `python3 bot.py`
|
||||
Get a bot token from [@BotFather](http://telegram.me/BotFather), place it in `credentials.py` and run the bot with `python3 bot.py`
|
||||
|
||||
Code documentation is minimal but there
|
||||
|
@ -3,14 +3,8 @@
|
||||
The following awesome people contributed to this project by translating it:
|
||||
|
||||
| Locale | Translators |
|
||||
|--------|----------------------------------------------------------------------|
|
||||
|--------|--------------------------------------------------------|
|
||||
| de_DE | [Jannes Höke](https://github.com/jh0ker) |
|
||||
| es_ES | [Ricardo Valverde Hernández](https://telegram.me/rivh1), Victor, Yuga|
|
||||
| id_ID | [Erwin Guo](https://www.facebook.com/erwinfransiscus) |
|
||||
| it_IT | Carola Mariano, ɳick |
|
||||
| pt_BR | [João Rodrigo Couto de Oliveira](http://twitter.com/JoaoRodrigoJR) |
|
||||
| zh_CN | [imlonghao](https://github.com/imlonghao) |
|
||||
| zh_HK | [Jed Cheng](https://www.facebook.com/profile.php?id=100002258388821) |
|
||||
| zh_TW | [Eugene Lam](https://www.facebook.com/eugenelam1118) |
|
||||
| it_IT | Carola Mariano, nick |
|
||||
|
||||
Please add yourself here alphabetically when you submit your first translation.
|
220
bot.py
220
bot.py
@ -37,36 +37,20 @@ from utils import display_name
|
||||
import card as c
|
||||
from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError,
|
||||
NotEnoughPlayersError, DeckEmptyError)
|
||||
from utils import send_async, answer_async, error, TIMEOUT
|
||||
from utils import _, __, send_async, answer_async, user_locale, game_locales, \
|
||||
error, TIMEOUT
|
||||
from shared_vars import botan, gm, updater, dispatcher
|
||||
from internationalization import _, __, user_locale, game_locales
|
||||
import simple_commands
|
||||
import settings
|
||||
|
||||
import simple_commands, settings
|
||||
from simple_commands import help
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
|
||||
level=logging.INFO)
|
||||
level=logging.DEBUG)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@user_locale
|
||||
def notify_me(bot, update):
|
||||
"""Handler for /notify_me command, pm people for next game"""
|
||||
chat_id = update.message.chat_id
|
||||
if update.message.chat.type == 'private':
|
||||
send_async(bot,
|
||||
chat_id,
|
||||
text=_("在群組中傳送這個指令以讓我在這個群組開始遊戲時私訊你"))
|
||||
else:
|
||||
try:
|
||||
gm.remind_dict[chat_id].add(update.message.from_user.id)
|
||||
except KeyError:
|
||||
gm.remind_dict[chat_id] = {update.message.from_user.id}
|
||||
|
||||
|
||||
@user_locale
|
||||
def new_game(bot, update):
|
||||
"""Handler for the /new command"""
|
||||
@ -76,20 +60,11 @@ def new_game(bot, update):
|
||||
help(bot, update)
|
||||
|
||||
else:
|
||||
|
||||
if update.message.chat_id in gm.remind_dict:
|
||||
for user in gm.remind_dict[update.message.chat_id]:
|
||||
send_async(bot,
|
||||
user,
|
||||
text=_("新遊戲已經在 {title} 中開始!").format(
|
||||
title=update.message.chat.title))
|
||||
|
||||
del gm.remind_dict[update.message.chat_id]
|
||||
|
||||
game = gm.new_game(update.message.chat)
|
||||
game.owner = update.message.from_user
|
||||
send_async(bot, chat_id,
|
||||
text=_("已經開始新的遊戲! 用 /join 加入並用 /start 開始遊戲"))
|
||||
text=_("Created a new game! Join the game with /join "
|
||||
"and start the game with /start"))
|
||||
|
||||
if botan:
|
||||
botan.track(update.message, 'New games')
|
||||
@ -108,26 +83,29 @@ def join_game(bot, update):
|
||||
gm.join_game(update.message.from_user, chat)
|
||||
|
||||
except LobbyClosedError:
|
||||
send_async(bot, chat.id, text=_("這場遊戲不開放其他人加入"))
|
||||
send_async(bot, chat.id, text=_("The lobby is closed"))
|
||||
|
||||
except NoGameInChatError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("目前沒有進行中的遊戲,輸入 /new 開始新的遊戲"),
|
||||
text=_("No game is running at the moment. "
|
||||
"Create a new game with /new"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except AlreadyJoinedError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("您已加入本局遊戲,輸入 /start 來開始遊戲"),
|
||||
text=_("You already joined the game. Start the game "
|
||||
"with /start"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except DeckEmptyError:
|
||||
send_async(bot, chat.id,
|
||||
text=_("已經沒牌讓其他人加入了"),
|
||||
text=_("There are not enough cards left in the deck for "
|
||||
"new players to join."),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("已加入遊戲"),
|
||||
text=_("Joined the game"),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
|
||||
@ -140,7 +118,8 @@ def leave_game(bot, update):
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
|
||||
if player is None:
|
||||
send_async(bot, chat.id, text=_("你目前沒有在此聊天室中遊玩"),
|
||||
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||
"this group."),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
|
||||
@ -151,21 +130,22 @@ def leave_game(bot, update):
|
||||
gm.leave_game(user, chat)
|
||||
|
||||
except NoGameInChatError:
|
||||
send_async(bot, chat.id, text=_("你目前沒有在此聊天室中遊玩"),
|
||||
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||
"this group."),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
except NotEnoughPlayersError:
|
||||
gm.end_game(chat, user)
|
||||
send_async(bot, chat.id, text=__("遊戲結束!", multi=game.translate))
|
||||
send_async(bot, chat.id, text=__("Game ended!", game.translate))
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=__("輪到:{name}",
|
||||
multi=game.translate).format(
|
||||
text=__("Okay. Next Player: {name}", game.translate).format(
|
||||
name=display_name(game.current_player.user)),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
|
||||
@run_async
|
||||
def select_game(bot, update):
|
||||
"""Handler for callback queries to select the current game"""
|
||||
|
||||
@ -177,31 +157,29 @@ def select_game(bot, update):
|
||||
gm.userid_current[user_id] = player
|
||||
break
|
||||
else:
|
||||
send_async(bot,
|
||||
update.callback_query.message.chat_id,
|
||||
text=_("找不到這場遊戲"))
|
||||
bot.sendMessage(update.callback_query.message.chat_id,
|
||||
text=_("Game not found."),
|
||||
timeout=TIMEOUT)
|
||||
return
|
||||
|
||||
@run_async
|
||||
def selected(bot):
|
||||
back = [[InlineKeyboardButton(text=_("回到上一個群組"),
|
||||
back = [[InlineKeyboardButton(text=_("Back to last group"),
|
||||
switch_inline_query='')]]
|
||||
|
||||
bot.answerCallbackQuery(update.callback_query.id,
|
||||
text=_("請切換到你選擇的群組"),
|
||||
text=_("Please switch to the group you selected!"),
|
||||
show_alert=False,
|
||||
timeout=TIMEOUT)
|
||||
|
||||
bot.editMessageText(chat_id=update.callback_query.message.chat_id,
|
||||
message_id=update.callback_query.message.message_id,
|
||||
text=_("已選擇的群組: {group}\n"
|
||||
"<b>請確認你已經切換到目前遊玩中的群組!</b>").format(
|
||||
text=_("Selected group: {group}\n"
|
||||
"<b>Make sure that you switch to the correct "
|
||||
"group!</b>").format(
|
||||
group=gm.userid_current[user_id].game.chat.title),
|
||||
reply_markup=InlineKeyboardMarkup(back),
|
||||
parse_mode=ParseMode.HTML,
|
||||
timeout=TIMEOUT)
|
||||
|
||||
selected(bot)
|
||||
|
||||
|
||||
@game_locales
|
||||
def status_update(bot, update):
|
||||
@ -219,11 +197,10 @@ def status_update(bot, update):
|
||||
pass
|
||||
except NotEnoughPlayersError:
|
||||
gm.end_game(chat, user)
|
||||
send_async(bot, chat.id, text=__("遊戲結束!",
|
||||
multi=game.translate))
|
||||
send_async(bot, chat.id, text=__("Game ended!", game.translate))
|
||||
else:
|
||||
send_async(bot, chat.id, text=__("將 {name} 從遊戲中踢除",
|
||||
multi=game.translate)
|
||||
send_async(bot, chat.id, text=__("Removing {name} from the game",
|
||||
game.translate)
|
||||
.format(name=display_name(user)))
|
||||
|
||||
|
||||
@ -239,24 +216,27 @@ def start_game(bot, update, args):
|
||||
game = gm.chatid_games[chat.id][-1]
|
||||
except (KeyError, IndexError):
|
||||
send_async(bot, chat.id,
|
||||
text=_("此聊天室目前沒有遊戲進行中,使用 /new 開始新遊戲"))
|
||||
text=_("There is no game running in this chat. Create "
|
||||
"a new one with /new"))
|
||||
return
|
||||
|
||||
if game.started:
|
||||
send_async(bot, chat.id, text=_("遊戲已經開始了!"))
|
||||
send_async(bot, chat.id, text=_("The game has already started"))
|
||||
|
||||
elif len(game.players) < 2:
|
||||
send_async(bot, chat.id,
|
||||
text=_("至少要有兩個人 /join 才能開始遊戲"))
|
||||
text=_("At least two players must /join the game "
|
||||
"before you can start it"))
|
||||
|
||||
else:
|
||||
game.play_card(game.last_card)
|
||||
game.started = True
|
||||
|
||||
first_message = (
|
||||
__("由 {name} 開始出牌\n"
|
||||
"輸入 /close 以防止其他人加入此局遊戲",
|
||||
multi=game.translate)
|
||||
__("First player: {name}\n"
|
||||
"Use /close to stop people from joining the game.\n"
|
||||
"Enable multi-translations with /enable_translations",
|
||||
game.translate)
|
||||
.format(name=display_name(game.current_player.user)))
|
||||
|
||||
@run_async
|
||||
@ -289,7 +269,7 @@ def start_game(bot, update, args):
|
||||
)
|
||||
|
||||
send_async(bot, update.message.chat_id,
|
||||
text=_("請選擇你要玩的群組"),
|
||||
text=_('Please select the group you want to play in.'),
|
||||
reply_markup=InlineKeyboardMarkup(groups))
|
||||
|
||||
else:
|
||||
@ -305,19 +285,20 @@ def close_game(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("此聊天室沒有正在進行的遊戲"))
|
||||
text=_("There is no running game in this chat."))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.open = False
|
||||
send_async(bot, chat.id, text=_("已禁止其他人加入這場遊戲"))
|
||||
send_async(bot, chat.id, text=_("Closed the lobby. "
|
||||
"No more players can join this game."))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -332,18 +313,19 @@ def open_game(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
text=_("There is no running game in this chat."))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.open = True
|
||||
send_async(bot, chat.id, text=_("已開放其他人加入,現在可以 /join 本局遊戲"))
|
||||
send_async(bot, chat.id, text=_("Opened the lobby. "
|
||||
"New players may /join the game."))
|
||||
return
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -358,20 +340,20 @@ def enable_translations(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
text=_("There is no running game in this chat."))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.translate = True
|
||||
send_async(bot, chat.id, text=_("開啟翻譯(待移除)"
|
||||
send_async(bot, chat.id, text=_("Enabled multi-translations. "
|
||||
"Disable with /disable_translations"))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -386,20 +368,21 @@ def disable_translations(bot, update):
|
||||
|
||||
if not games:
|
||||
send_async(bot, chat.id,
|
||||
text=_("此聊天室目前沒有遊戲進行中"))
|
||||
text=_("There is no running game in this chat."))
|
||||
return
|
||||
|
||||
game = games[-1]
|
||||
|
||||
if game.owner.id == user.id:
|
||||
game.translate = False
|
||||
send_async(bot, chat.id, text=_("關閉翻譯(待移除)"
|
||||
send_async(bot, chat.id, text=_("Disabled multi-translations. "
|
||||
"Enable them again with "
|
||||
"/enable_translations"))
|
||||
return
|
||||
|
||||
else:
|
||||
send_async(bot, chat.id,
|
||||
text=_("只有創建遊戲的玩家({name})可以執行此指令")
|
||||
text=_("Only the game creator ({name}) can do that")
|
||||
.format(name=game.owner.first_name),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
return
|
||||
@ -415,7 +398,7 @@ def skip_player(bot, update):
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
if not player:
|
||||
send_async(bot, chat.id,
|
||||
text=_("你目前沒有在此聊天室中遊玩"))
|
||||
text=_("You are not playing in a game in this chat."))
|
||||
return
|
||||
|
||||
game = player.game
|
||||
@ -427,12 +410,9 @@ def skip_player(bot, update):
|
||||
delta = (now - started).seconds
|
||||
|
||||
if delta < skipped_player.waiting_time:
|
||||
n = skipped_player.waiting_time - delta
|
||||
send_async(bot, chat.id,
|
||||
text=_("請等待 {time} 秒",
|
||||
"請等待 {time} 秒",
|
||||
n)
|
||||
.format(time=n),
|
||||
text=_("Please wait {time} seconds")
|
||||
.format(time=(skipped_player.waiting_time - delta)),
|
||||
reply_to_message_id=update.message.message_id)
|
||||
|
||||
elif skipped_player.waiting_time > 0:
|
||||
@ -443,15 +423,11 @@ def skip_player(bot, update):
|
||||
except DeckEmptyError:
|
||||
pass
|
||||
|
||||
n = skipped_player.waiting_time
|
||||
send_async(bot, chat.id,
|
||||
text=__("此玩家等待時間已經縮短為 {time} 秒\n"
|
||||
"輪到:{name}",
|
||||
"此玩家等待時間已經縮短為 {time} 秒\n"
|
||||
"輪到:{name}",
|
||||
n,
|
||||
multi=game.translate)
|
||||
.format(time=n,
|
||||
text=__("Waiting time to skip this player has "
|
||||
"been reduced to {time} seconds.\n"
|
||||
"Next player: {name}", game.translate)
|
||||
.format(time=skipped_player.waiting_time,
|
||||
name=display_name(next_player.user)))
|
||||
game.turn()
|
||||
|
||||
@ -459,15 +435,17 @@ def skip_player(bot, update):
|
||||
try:
|
||||
gm.leave_game(skipped_player.user, chat)
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name1} 被跳過 4 次,已從此局遊戲中移除\n"
|
||||
"輪到:{name2}", multi=game.translate)
|
||||
text=__("{name1} was skipped four times in a row "
|
||||
"and has been removed from the game.\n"
|
||||
"Next player: {name2}", game.translate)
|
||||
.format(name1=display_name(skipped_player.user),
|
||||
name2=display_name(next_player.user)))
|
||||
|
||||
except NotEnoughPlayersError:
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} 被跳過 4 次,已從此局遊戲中移除\n"
|
||||
"遊戲結束!", multi=game.translate)
|
||||
text=__("{name} was skipped four times in a row "
|
||||
"and has been removed from the game.\n"
|
||||
"The game ended.", game.translate)
|
||||
.format(name=display_name(skipped_player.user)))
|
||||
|
||||
gm.end_game(chat.id, skipped_player.user)
|
||||
@ -481,6 +459,7 @@ def reply_to_query(bot, update):
|
||||
Builds the result list for inline queries and answers to the client.
|
||||
"""
|
||||
results = list()
|
||||
playable = list()
|
||||
switch = None
|
||||
|
||||
try:
|
||||
@ -497,7 +476,7 @@ def reply_to_query(bot, update):
|
||||
elif user_id == game.current_player.user.id:
|
||||
if game.choosing_color:
|
||||
add_choose_color(results, game)
|
||||
add_other_cards(player, results, game)
|
||||
add_other_cards(playable, player, results, game)
|
||||
else:
|
||||
if not player.drew:
|
||||
add_draw(player, results)
|
||||
@ -517,8 +496,6 @@ def reply_to_query(bot, update):
|
||||
str(card) not in added_ids))
|
||||
added_ids.append(str(card))
|
||||
|
||||
add_gameinfo(game, results)
|
||||
|
||||
elif user_id != game.current_player.user.id or not game.started:
|
||||
for card in sorted(player.cards):
|
||||
add_card(game, card, results, can_play=False)
|
||||
@ -530,7 +507,7 @@ def reply_to_query(bot, update):
|
||||
result.id += ':%d' % player.anti_cheat
|
||||
|
||||
if players and game and len(players) > 1:
|
||||
switch = _('目前遊戲:{group}').format(game=game.chat.title)
|
||||
switch = _('Current game: {game}').format(game=game.chat.title)
|
||||
|
||||
answer_async(bot, update.inline_query.id, results, cache_time=0,
|
||||
switch_pm_text=switch, switch_pm_parameter='select')
|
||||
@ -549,7 +526,7 @@ def process_result(bot, update):
|
||||
game = player.game
|
||||
result_id = update.chosen_inline_result.result_id
|
||||
chat = game.chat
|
||||
except (KeyError, AttributeError):
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
logger.debug("Selected result: " + result_id)
|
||||
@ -564,7 +541,7 @@ def process_result(bot, update):
|
||||
return
|
||||
elif int(anti_cheat) != last_anti_cheat:
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} 提出了作弊嫌疑", multi=game.translate)
|
||||
text=__("Cheat attempt by {name}", game.translate)
|
||||
.format(name=display_name(player.user)))
|
||||
return
|
||||
elif result_id == 'call_bluff':
|
||||
@ -583,7 +560,7 @@ def process_result(bot, update):
|
||||
|
||||
if game in gm.chatid_games.get(chat.id, list()):
|
||||
send_async(bot, chat.id,
|
||||
text=__("輪到:{name}", multi=game.translate)
|
||||
text=__("Next player: {name}", game.translate)
|
||||
.format(name=display_name(game.current_player.user)))
|
||||
|
||||
|
||||
@ -594,7 +571,8 @@ def reset_waiting_time(bot, player):
|
||||
if player.waiting_time < 90:
|
||||
player.waiting_time = 90
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} 的等待時間已重置為 90 秒", multi=player.game.translate)
|
||||
text=__("Waiting time for {name} has been reset to 90 "
|
||||
"seconds", player.game.translate)
|
||||
.format(name=display_name(player.user)))
|
||||
|
||||
|
||||
@ -610,18 +588,17 @@ def do_play_card(bot, player, result_id):
|
||||
if not us:
|
||||
us = UserSetting(id=user.id)
|
||||
|
||||
if us.stats:
|
||||
us.cards_played += 1
|
||||
|
||||
if game.choosing_color:
|
||||
send_async(bot, chat.id, text=_("請選擇一個顏色"))
|
||||
send_async(bot, chat.id, text=_("Please choose a color"))
|
||||
|
||||
if len(player.cards) == 1:
|
||||
send_async(bot, chat.id, text="UNO!")
|
||||
|
||||
if len(player.cards) == 0:
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name} 贏了!", multi=game.translate)
|
||||
text=__("{name} won!", game.translate)
|
||||
.format(name=user.first_name))
|
||||
|
||||
if us.stats:
|
||||
@ -630,15 +607,12 @@ def do_play_card(bot, player, result_id):
|
||||
if game.players_won is 0:
|
||||
us.first_places += 1
|
||||
|
||||
game.players_won += 1
|
||||
|
||||
try:
|
||||
gm.leave_game(user, chat)
|
||||
except NotEnoughPlayersError:
|
||||
send_async(bot, chat.id,
|
||||
text=__("遊戲結束!", multi=game.translate))
|
||||
send_async(bot, chat.id, text=__("Game ended!", game.translate))
|
||||
|
||||
us2 = UserSetting.get(id=game.current_player.user.id)
|
||||
us2 = UserSetting.get(id=game.current_player.next.user.id)
|
||||
if us2 and us2.stats:
|
||||
us2.games_played += 1
|
||||
|
||||
@ -659,7 +633,8 @@ def do_draw(bot, player):
|
||||
player.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
text=__("There are no more cards in the deck.",
|
||||
game.translate))
|
||||
|
||||
if (game.last_card.value == c.DRAW_TWO or
|
||||
game.last_card.special == c.DRAW_FOUR) and \
|
||||
@ -674,28 +649,30 @@ def do_call_bluff(bot, player):
|
||||
|
||||
if player.prev.bluffing:
|
||||
send_async(bot, chat.id,
|
||||
text=__("作弊已確認!作為懲罰,給予 {name} 4 張牌",
|
||||
multi=game.translate)
|
||||
text=__("Bluff called! Giving 4 cards to {name}",
|
||||
game.translate)
|
||||
.format(name=player.prev.user.first_name))
|
||||
|
||||
try:
|
||||
player.prev.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
text=__("There are no more cards in the deck.",
|
||||
game.translate))
|
||||
|
||||
else:
|
||||
game.draw_counter += 2
|
||||
send_async(bot, chat.id,
|
||||
text=__("{name1} 沒有作弊!作為懲罰,給予 {name2} 六張牌",
|
||||
multi=game.translate)
|
||||
text=__("{name1} didn't bluff! Giving 6 cards to {name2}",
|
||||
game.translate)
|
||||
.format(name1=player.prev.user.first_name,
|
||||
name2=player.user.first_name))
|
||||
try:
|
||||
player.draw()
|
||||
except DeckEmptyError:
|
||||
send_async(bot, player.game.chat.id,
|
||||
text=__("已經沒牌了", multi=game.translate))
|
||||
text=__("There are no more cards in the deck.",
|
||||
game.translate))
|
||||
|
||||
game.turn()
|
||||
|
||||
@ -710,14 +687,11 @@ dispatcher.add_handler(CommandHandler('join', join_game))
|
||||
dispatcher.add_handler(CommandHandler('leave', leave_game))
|
||||
dispatcher.add_handler(CommandHandler('open', open_game))
|
||||
dispatcher.add_handler(CommandHandler('close', close_game))
|
||||
# dispatcher.add_handler(CommandHandler('enable_translations',
|
||||
# enable_translations))
|
||||
# dispatcher.add_handler(CommandHandler('disable_translations',
|
||||
# disable_translations))
|
||||
dispatcher.add_handler(CommandHandler('enable_translations',
|
||||
enable_translations))
|
||||
dispatcher.add_handler(CommandHandler('disable_translations',
|
||||
disable_translations))
|
||||
dispatcher.add_handler(CommandHandler('skip', skip_player))
|
||||
dispatcher.add_handler(CommandHandler('notify_me', notify_me))
|
||||
simple_commands.register()
|
||||
settings.register()
|
||||
dispatcher.add_handler(MessageHandler([Filters.status_update], status_update))
|
||||
dispatcher.add_error_handler(error)
|
||||
|
||||
|
4
card.py
4
card.py
@ -116,8 +116,8 @@ STICKERS = {
|
||||
'y_reverse': 'BQADBAADQQIAAl9XmQABZdQFahGG6UQC',
|
||||
'draw_four': 'BQADBAAD9QEAAl9XmQABVlkSNfhn76cC',
|
||||
'colorchooser': 'BQADBAAD8wEAAl9XmQABl9rUOPqx4E4C',
|
||||
'option_draw': 'BQADBAAD-AIAAl9XmQABxEjEcFM-VHIC',
|
||||
'option_pass': 'BQADBAAD-gIAAl9XmQABcEkAAbaZ4SicAg',
|
||||
'option_draw': 'BQADBAADzAIAAl9XmQABTkPaOqA5HIMC',
|
||||
'option_pass': 'BQADBAADzgIAAl9XmQABWSDq3RIg3c0C',
|
||||
'option_bluff': 'BQADBAADygIAAl9XmQABJoLfB9ntI2UC',
|
||||
'option_info': 'BQADBAADxAIAAl9XmQABC5v3Z77VLfEC'
|
||||
}
|
||||
|
@ -33,8 +33,6 @@ class GameManager(object):
|
||||
self.chatid_games = dict()
|
||||
self.userid_players = dict()
|
||||
self.userid_current = dict()
|
||||
self.remind_dict = dict()
|
||||
|
||||
self.logger = logging.getLogger(__name__)
|
||||
|
||||
def new_game(self, chat):
|
||||
@ -49,11 +47,6 @@ class GameManager(object):
|
||||
if chat_id not in self.chatid_games:
|
||||
self.chatid_games[chat_id] = list()
|
||||
|
||||
# remove old games
|
||||
for g in list(self.chatid_games[chat_id]):
|
||||
if not g.players:
|
||||
self.chatid_games[chat_id].remove(g)
|
||||
|
||||
self.chatid_games[chat_id].append(game)
|
||||
return game
|
||||
|
||||
@ -87,11 +80,6 @@ class GameManager(object):
|
||||
except NotEnoughPlayersError:
|
||||
self.end_game(chat, user)
|
||||
|
||||
if user.id not in self.userid_players:
|
||||
self.userid_players[user.id] = list()
|
||||
|
||||
players = self.userid_players[user.id]
|
||||
|
||||
player = Player(game, user)
|
||||
|
||||
players.append(player)
|
||||
@ -104,16 +92,6 @@ class GameManager(object):
|
||||
players = self.userid_players.get(user.id, list())
|
||||
|
||||
if not player:
|
||||
games = self.chatid_games[chat.id]
|
||||
for g in games:
|
||||
for p in g.players:
|
||||
if p.user.id == user.id:
|
||||
if p is g.current_player:
|
||||
g.turn()
|
||||
|
||||
p.leave()
|
||||
return
|
||||
else:
|
||||
raise NoGameInChatError
|
||||
|
||||
game = player.game
|
||||
@ -152,29 +130,14 @@ class GameManager(object):
|
||||
|
||||
# Clear game
|
||||
for player_in_game in game.players:
|
||||
this_users_players = \
|
||||
self.userid_players.get(player_in_game.user.id, list())
|
||||
|
||||
try:
|
||||
this_users_players = self.userid_players[player_in_game.user.id]
|
||||
this_users_players.remove(player_in_game)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if this_users_players:
|
||||
try:
|
||||
self.userid_current[player_in_game.user.id] = this_users_players[0]
|
||||
except KeyError:
|
||||
pass
|
||||
self.userid_current[player.user.id] = this_users_players[0]
|
||||
else:
|
||||
try:
|
||||
del self.userid_players[player_in_game.user.id]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
try:
|
||||
del self.userid_current[player_in_game.user.id]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
self.chatid_games[chat.id].remove(game)
|
||||
if not self.chatid_games[chat.id]:
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 39 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB |
@ -1,171 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Telegram bot to play UNO in group chats
|
||||
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import gettext
|
||||
from functools import wraps
|
||||
|
||||
from locales import available_locales
|
||||
from database import db_session
|
||||
from user_setting import UserSetting
|
||||
from shared_vars import gm
|
||||
|
||||
GETTEXT_DOMAIN = 'unobot'
|
||||
GETTEXT_DIR = 'locales'
|
||||
|
||||
|
||||
class _Underscore(object):
|
||||
"""Class to emulate flufl.i18n behaviour, but with plural support"""
|
||||
def __init__(self):
|
||||
self.translators = {
|
||||
locale: gettext.GNUTranslations(
|
||||
open(gettext.find(
|
||||
GETTEXT_DOMAIN, GETTEXT_DIR, languages=[locale]
|
||||
), 'rb')
|
||||
)
|
||||
for locale
|
||||
in available_locales.keys()
|
||||
if locale != 'zh_TW' # No translation file for zh_TW
|
||||
}
|
||||
self.locale_stack = list()
|
||||
|
||||
def push(self, locale):
|
||||
self.locale_stack.append(locale)
|
||||
|
||||
def pop(self):
|
||||
if self.locale_stack:
|
||||
return self.locale_stack.pop()
|
||||
else:
|
||||
return None
|
||||
|
||||
@property
|
||||
def code(self):
|
||||
if self.locale_stack:
|
||||
return self.locale_stack[-1]
|
||||
else:
|
||||
return None
|
||||
|
||||
def __call__(self, singular, plural=None, n=1, locale=None):
|
||||
if not locale:
|
||||
locale = self.locale_stack[-1]
|
||||
|
||||
if locale not in self.translators.keys():
|
||||
if n is 1:
|
||||
return singular
|
||||
else:
|
||||
return plural
|
||||
|
||||
translator = self.translators[locale]
|
||||
|
||||
if plural is None:
|
||||
return translator.gettext(singular)
|
||||
else:
|
||||
return translator.ngettext(singular, plural, n)
|
||||
|
||||
_ = _Underscore()
|
||||
|
||||
|
||||
def __(singular, plural=None, n=1, multi=False):
|
||||
"""Translates text into all locales on the stack"""
|
||||
translations = list()
|
||||
|
||||
if not multi and len(set(_.locale_stack)) >= 1:
|
||||
translations.append(_(singular, plural, n, 'zh_TW'))
|
||||
|
||||
else:
|
||||
for locale in _.locale_stack:
|
||||
translation = _(singular, plural, n, locale)
|
||||
|
||||
if translation not in translations:
|
||||
translations.append(translation)
|
||||
|
||||
return '\n'.join(translations)
|
||||
|
||||
|
||||
def user_locale(func):
|
||||
@wraps(func)
|
||||
@db_session
|
||||
def wrapped(bot, update, *pargs, **kwargs):
|
||||
user, chat = _user_chat_from_update(update)
|
||||
|
||||
with db_session:
|
||||
us = UserSetting.get(id=user.id)
|
||||
|
||||
if us and us.lang != 'en':
|
||||
_.push(us.lang)
|
||||
else:
|
||||
_.push('zh_TW')
|
||||
|
||||
result = func(bot, update, *pargs, **kwargs)
|
||||
_.pop()
|
||||
return result
|
||||
return wrapped
|
||||
|
||||
|
||||
def game_locales(func):
|
||||
@wraps(func)
|
||||
@db_session
|
||||
def wrapped(bot, update, *pargs, **kwargs):
|
||||
user, chat = _user_chat_from_update(update)
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
locales = list()
|
||||
|
||||
if player:
|
||||
for player in player.game.players:
|
||||
us = UserSetting.get(id=player.user.id)
|
||||
|
||||
if us and us.lang != 'en':
|
||||
loc = us.lang
|
||||
else:
|
||||
loc = 'zh_TW'
|
||||
|
||||
if loc in locales:
|
||||
continue
|
||||
|
||||
_.push(loc)
|
||||
locales.append(loc)
|
||||
|
||||
result = func(bot, update, *pargs, **kwargs)
|
||||
|
||||
while _.code:
|
||||
_.pop()
|
||||
|
||||
return result
|
||||
return wrapped
|
||||
|
||||
|
||||
def _user_chat_from_update(update):
|
||||
|
||||
try:
|
||||
user = update.message.from_user
|
||||
chat = update.message.chat
|
||||
except (NameError, AttributeError):
|
||||
try:
|
||||
user = update.inline_query.from_user
|
||||
chat = gm.userid_current[user.id].game.chat
|
||||
except KeyError:
|
||||
chat = None
|
||||
except (NameError, AttributeError):
|
||||
try:
|
||||
user = update.chosen_inline_result.from_user
|
||||
chat = gm.userid_current[user.id].game.chat
|
||||
except (NameError, AttributeError, KeyError):
|
||||
chat = None
|
||||
|
||||
return user, chat
|
@ -1,21 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Telegram bot to play UNO in group chats
|
||||
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from .available import available_locales
|
@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Telegram bot to play UNO in group chats
|
||||
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
"""Defines a dict of all available locales to the language name"""
|
||||
|
||||
OFFSET = 127462 - ord('A')
|
||||
|
||||
|
||||
def flag(code):
|
||||
return chr(ord(code[0]) + OFFSET) + chr(ord(code[1]) + OFFSET)
|
||||
|
||||
|
||||
available_locales = {'zh_TW': flag('TW') + ' 中文(台灣)'}
|
442
locales/de_DE/LC_MESSAGES/unobot.po
Normal file
442
locales/de_DE/LC_MESSAGES/unobot.po
Normal file
@ -0,0 +1,442 @@
|
||||
# Telegram bot to play UNO in group chats
|
||||
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# Jannes Höke <uno@jhoeke.de>, 2016.
|
||||
#
|
||||
#: bot.py:224
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: uno_bot 0.1\n"
|
||||
"Report-Msgid-Bugs-To: uno@jhoeke.de\n"
|
||||
"POT-Creation-Date: 2016-05-19 22:38+0200\n"
|
||||
"PO-Revision-Date: 2016-05-21 21:16+0200\n"
|
||||
"Last-Translator: Jannes Höke <uno@jhoeke.de>\n"
|
||||
"Language-Team: Deutsch <uno@jhoeke.de>\n"
|
||||
"Language: de_DE\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"X-Generator: Gtranslator 2.91.6\n"
|
||||
|
||||
#: bot.py:60
|
||||
msgid "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>@mau_mau_bot</code> into your chat box and hit <b>space</b>, "
|
||||
"or click the <code>via @mau_mau_bot</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.\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."
|
||||
msgstr ""
|
||||
"Folge den folgenden Schritten:\n"
|
||||
"\n"
|
||||
"1. Füge diesen Bot einer Gruppe hinzu\n"
|
||||
"2. In einer Gruppe kannst du mit /new ein neues Spiel erstellen und mit /"
|
||||
"join einem bestehenden Spiel beitreten\n"
|
||||
"3. Nachdem mindestens zwei Spieler beigetreten sind, starte das Spiel mit /"
|
||||
"start\n"
|
||||
"3. Gib <code>@mau_mau_bot</code> in deine Chatbox ein und drücke die "
|
||||
"<b>Leertaste</b>, oder tippe auf den <code>via @mau_mau_bot</code>-Text "
|
||||
"neben oder über den Nachrichten. Du siehst deine Karten (einige in grau), "
|
||||
"zusätzliche Optionen wie z. B. Ziehen, und ein <b>?</b> um den Infos über "
|
||||
"das laufende Spiel anzuzeigen. Die <b>grauen Karten</b> kannst du gerade "
|
||||
"<b>nicht spielen</b>. Tippe eine der Optionen oder Karten an, um diese "
|
||||
"Aktion auszuführen bzw. die Karte zu spielen. \n"
|
||||
"Spieler können dem Spiel jederzeit beitreten. Um das Spiel zu verlassen, "
|
||||
"benutze /leave. Wenn ein Spieler länger als 90 Sekunden braucht, kannst du "
|
||||
"ihn mit /skip überspringen.\n"
|
||||
"\n"
|
||||
"<b>Sprache</b> und andere Einstellungen: /settings\n"
|
||||
"Weitere Kommandos (nur Spiel-Ersteller):\n"
|
||||
"/close - Lobby schließen\n"
|
||||
"/open - Lobby öffnen\n"
|
||||
"/enable_translations - Übersetze relevante Texte in alle im Spiel gesprochenen"
|
||||
" Sprachen\n"
|
||||
"/disable_translations - Verwende Englisch für diese Texte\n"
|
||||
"\n"
|
||||
"<b>Experimentell</b>: Spiele in mehreren Gruppen gleichzeitig. Um die "
|
||||
"Gruppe, in der du deine Karte spielen willst, auszuwählen, tippe auf den "
|
||||
"<code>Aktuelles Spiel: ...</code>-Button.\n"
|
||||
"Wenn dir dieser Bot gefällt, <a href=\"https://telegram.me/storebot?"
|
||||
"start=mau_mau_bot\">bewerte ihn</a>, tritt dem <a href=\"https://telegram.me/"
|
||||
"unobotupdates\">News-Channel</a> bei und kaufe ein UNO Kartenspiel."
|
||||
|
||||
#: bot.py:88
|
||||
msgid ""
|
||||
"This bot is Free Software and licensed under the AGPL. The code is available "
|
||||
"here: \n"
|
||||
"https://github.com/jh0ker/mau_mau_bot"
|
||||
msgstr ""
|
||||
"Dieser Bot ist Freie Software und lizenziert unter der AGPL. Der Quellcode "
|
||||
"ist hier verfügbar:\n"
|
||||
"https://github.com/jh0ker/mau_mau_bot"
|
||||
|
||||
#: bot.py:133
|
||||
msgid ""
|
||||
"Created a new game! Join the game with /join and start the game with /start"
|
||||
msgstr ""
|
||||
"Neues Spiel erstellt! Tritt dem Spiel mit /join bei und starte es mit /start"
|
||||
|
||||
#: bot.py:152
|
||||
msgid "The lobby is closed"
|
||||
msgstr "Die Lobby ist geschlossen"
|
||||
|
||||
#: bot.py:156
|
||||
msgid "No game is running at the moment. Create a new game with /new"
|
||||
msgstr "Zur Zeit läuft kein Spiel. Erstelle ein neues mit /new"
|
||||
|
||||
#: bot.py:162
|
||||
msgid "You already joined the game. Start the game with /start"
|
||||
msgstr "Du bist dem Spiel bereits beigetreten. Starte es mit /start"
|
||||
|
||||
#: bot.py:167
|
||||
msgid "Joined the game"
|
||||
msgstr "Spiel beigetreten"
|
||||
|
||||
#: bot.py:179 bot.py:191
|
||||
msgid "You are not playing in a game in this group."
|
||||
msgstr "Du spielst in keinem Spiel in dieser Gruppe."
|
||||
|
||||
#: bot.py:197 bot.py:258 bot.py:595
|
||||
msgid "Game ended!"
|
||||
msgstr "Spiel beendet!"
|
||||
|
||||
#: bot.py:201
|
||||
msgid "Okay. Next Player: {name}"
|
||||
msgstr "Okay. Nächster Spieler: {name}"
|
||||
|
||||
#: bot.py:219
|
||||
msgid "Game not found."
|
||||
msgstr "Spiel nicht gefunden."
|
||||
|
||||
#: bot.py:223
|
||||
msgid "Back to last group"
|
||||
msgstr "Zurück zur letzten Gruppe"
|
||||
|
||||
#: bot.py:227
|
||||
msgid "Please switch to the group you selected!"
|
||||
msgstr "Bitte wechsele zu der Gruppe, die du gewählt hast!"
|
||||
|
||||
#: bot.py:233
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Selected group: {group}\n"
|
||||
"<b>Make sure that you switch to the correct group!</b>"
|
||||
msgstr ""
|
||||
"Ausgewählte Gruppe: {group}\n"
|
||||
"<b>Stell sicher, dass du in die richtige Gruppe wechselst!</b>"
|
||||
|
||||
#: bot.py:260
|
||||
#, python-format
|
||||
msgid "Removing {name} from the game"
|
||||
msgstr "Entferne {name} aus dem Spiel"
|
||||
|
||||
#: bot.py:273
|
||||
msgid "There is no game running in this chat. Create a new one with /new"
|
||||
msgstr ""
|
||||
"In dieser Gruppe gibt es kein laufendes Spiel. Erstelle ein neues mit /new"
|
||||
|
||||
#: bot.py:278
|
||||
msgid "The game has already started"
|
||||
msgstr "Das Spiel hat bereits begonnen"
|
||||
|
||||
#: bot.py:281
|
||||
msgid "At least two players must /join the game before you can start it"
|
||||
msgstr "Es müssen mindestens zwei Spieler dem Spiel beitreten, bevor du es "
|
||||
"starten kannst"
|
||||
|
||||
#: bot.py:297
|
||||
#, python-format, fuzzy
|
||||
msgid "First player: {name}\n"
|
||||
"Use /close to stop people from joining the game.\n"
|
||||
"Enable multi-translations with /enable_translations"
|
||||
msgstr ""
|
||||
"Erster Spieler: {name}\n"
|
||||
"Benutze /close, um zu verhindern, dass weitere Spieler beitreten."
|
||||
|
||||
#: bot.py:321
|
||||
msgid "Please select the group you want to play in."
|
||||
msgstr "Bitte wähle die Gruppe, in der du spielen willst."
|
||||
|
||||
#: bot.py:335 bot.py:361
|
||||
msgid "There is no running game in this chat."
|
||||
msgstr "In dieser Gruppe läuft gerade kein Spiel."
|
||||
|
||||
#: bot.py:342
|
||||
msgid "Closed the lobby. No more players can join this game."
|
||||
msgstr ""
|
||||
"Lobby geschlossen. Diesem Spiel können keine weiteren Spieler beitreten."
|
||||
|
||||
#: bot.py:348 bot.py:373
|
||||
#, python-format
|
||||
msgid "Only the game creator ({name}) can do that."
|
||||
msgstr "Dies kann nur der Ersteller des Spiels ({name}) tun."
|
||||
|
||||
#: bot.py:349
|
||||
#, python-format
|
||||
msgid "Enabled multi-translations. Disable with /disable_translations"
|
||||
msgstr "Multi-Übersetzungen aktiviert. Deaktivieren mit /disable_translations"
|
||||
|
||||
#: bot.py:377
|
||||
#, python-format
|
||||
msgid "Disabled multi-translations. Enable them again with /enable_translations"
|
||||
msgstr "Multi-Übersetzungen deaktiviert. Aktiviere sie wieder mit "
|
||||
"/enable_translations"
|
||||
|
||||
#: bot.py:368
|
||||
msgid "Opened the lobby. New players may /join the game."
|
||||
msgstr "Lobby geöffnet. Neue Spieler können nun beitreten."
|
||||
|
||||
#: bot.py:386
|
||||
msgid "You are not playing in a game in this chat."
|
||||
msgstr "Du spielst kein Spiel in dieser Gruppe."
|
||||
|
||||
#: bot.py:400
|
||||
#, python-format
|
||||
msgid "Please wait {time} seconds"
|
||||
msgstr "Bitte warte {time} Sekunden"
|
||||
|
||||
#: bot.py:413
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Waiting time to skip this player has been reduced to {time} seconds.\n"
|
||||
"Next player: {name}"
|
||||
msgstr ""
|
||||
"Die Wartezeit um diesen Spieler zu überspringen wurde auf {time} Sekunden "
|
||||
"reduziert.\n"
|
||||
"Nächster Spieler: {name}"
|
||||
|
||||
#: bot.py:424
|
||||
#, python-format
|
||||
msgid ""
|
||||
"{name1} was skipped four times in a row and has been removed from the game.\n"
|
||||
"Next player: {name2}"
|
||||
msgstr ""
|
||||
"{name1} wurde vier Mal hintereinander übersprungen und daher aus dem Spiel "
|
||||
"entfernt.\n"
|
||||
"Nächster Spieler: {name2}"
|
||||
|
||||
#: bot.py:432
|
||||
#, python-format
|
||||
msgid ""
|
||||
"{name} was skipped four times in a row and has been removed from the game.\n"
|
||||
"The game ended."
|
||||
msgstr ""
|
||||
"{name1} wurde vier Mal hintereinander übersprungen und daher aus dem Spiel "
|
||||
"entfernt.\n"
|
||||
"Das Spiel wurde beendet."
|
||||
|
||||
#: bot.py:455
|
||||
msgid "All news here: https://telegram.me/unobotupdates"
|
||||
msgstr "Alle News hier: https://telegram.me/unobotupdates"
|
||||
|
||||
#: bot.py:513
|
||||
#, python-format
|
||||
msgid "Current game: %s"
|
||||
msgstr "Aktuelles Spiel: {game}"
|
||||
|
||||
#: bot.py:545
|
||||
#, python-format
|
||||
msgid "Cheat attempt by %s"
|
||||
msgstr "{name} hat versucht zu schummeln!"
|
||||
|
||||
#: bot.py:562
|
||||
msgid "Next player: {name}"
|
||||
msgstr "Nächster Spieler: {name}"
|
||||
|
||||
#: bot.py:572
|
||||
#, python-format
|
||||
msgid "Waiting time for {name} has been reset to 90 seconds"
|
||||
msgstr "Die Wartezeit für {name} wurde auf 90 Sekunden zurückgesetzt."
|
||||
|
||||
#: bot.py:585
|
||||
msgid "Please choose a color"
|
||||
msgstr "Bitte wähle eine Farbe"
|
||||
|
||||
#: bot.py:591
|
||||
#, python-format
|
||||
msgid "{name} won!"
|
||||
msgstr "{name} hat gewonnen!"
|
||||
|
||||
#: bot.py:613 bot.py:635 bot.py:647
|
||||
msgid "There are no more cards in the deck."
|
||||
msgstr "Es sind keine Karten mehr im Deck."
|
||||
|
||||
#: bot.py:627
|
||||
#, python-format
|
||||
msgid "Bluff called! Giving 4 cards to {name}"
|
||||
msgstr "Bluff gecalled! {name} bekommt 4 Karten."
|
||||
|
||||
#: bot.py:639
|
||||
#, python-format
|
||||
msgid "{name1} didn't bluff! Giving 6 cards to {name2}"
|
||||
msgstr "{name1} hat nicht geblufft! {name2} bekommt 6 Karten."
|
||||
|
||||
#: results.py:38
|
||||
msgid "Choose Color"
|
||||
msgstr "Wähle Farbe"
|
||||
|
||||
#: results.py:56
|
||||
msgid "Cards (tap for game state):"
|
||||
msgstr "Karten (tippe für Spielinfo):"
|
||||
|
||||
#: results.py:60 results.py:123 results.py:165
|
||||
msgid "Current player: {name}"
|
||||
msgstr "Aktueller Spieler: {name}"
|
||||
|
||||
#: results.py:61 results.py:124 results.py:167
|
||||
msgid "Last card: {card}"
|
||||
msgstr "Letzte Karte: {card}"
|
||||
|
||||
#: results.py:62 results.py:125 results.py:168
|
||||
msgid "Players: {player_list}"
|
||||
msgstr "Spieler: {player_list}"
|
||||
|
||||
#: results.py:72
|
||||
#, python-format
|
||||
msgid "{name} ({number} cards)"
|
||||
msgstr "{name} ({number} Karten)"
|
||||
|
||||
#: results.py:81
|
||||
msgid "You are not playing"
|
||||
msgstr "Du spielst gerade nicht"
|
||||
|
||||
#: results.py:83
|
||||
msgid ""
|
||||
"Not playing right now. Use /new to start a game or /join to join the current "
|
||||
"game in this group"
|
||||
msgstr ""
|
||||
"Du spielst gerade nicht. Benutze /new um ein neues Spiel zu starten oder /"
|
||||
"join, um einem bestehenden Spiel beizutreten."
|
||||
|
||||
#: results.py:95
|
||||
msgid "The game wasn't started yet"
|
||||
msgstr "Das Spiel wurde noch nicht gestartet."
|
||||
|
||||
#: results.py:97
|
||||
msgid "Start the game with /start"
|
||||
msgstr "Starte das Spiel mit /start"
|
||||
|
||||
#: results.py:108
|
||||
#, python-format
|
||||
msgid "Drawing 1 card"
|
||||
msgstr "Zieht 1 Karte"
|
||||
|
||||
msgid "Drawing {number} cards"
|
||||
msgstr "Zieht {number} Karten"
|
||||
|
||||
#: results.py:136
|
||||
msgid "Pass"
|
||||
msgstr "Passe"
|
||||
|
||||
#: results.py:148
|
||||
msgid "I'm calling your bluff!"
|
||||
msgstr "Ich glaube du bluffst!"
|
||||
|
||||
#: settings.py:39
|
||||
msgid "Please edit your settings in a private chat with the bot."
|
||||
msgstr "Bitte ändere deine Einstellungen in einem privaten Chat mit dem Bot."
|
||||
|
||||
#: settings.py:49
|
||||
msgid "Enable statistics"
|
||||
msgstr "Statistiken aktivieren"
|
||||
|
||||
#: settings.py:51
|
||||
msgid "Delete all statistics"
|
||||
msgstr "Alle Statistiken löschen"
|
||||
|
||||
#: settings.py:53
|
||||
msgid "Language"
|
||||
msgstr "Sprache"
|
||||
|
||||
#: settings.py:54
|
||||
msgid "Settings"
|
||||
msgstr "Einstellungen"
|
||||
|
||||
#: settings.py:68
|
||||
msgid "Enabled statistics!"
|
||||
msgstr "Statistiken aktiviert!"
|
||||
|
||||
#: settings.py:70
|
||||
msgid "Select locale"
|
||||
msgstr "Bitte Sprache auswählen"
|
||||
|
||||
#: settings.py:81
|
||||
msgid "Deleted and disabled statistics!"
|
||||
msgstr "Alle Statistiken gelöscht und deaktiviert!"
|
||||
|
||||
#: settings.py:94
|
||||
msgid "Set locale!"
|
||||
msgstr "Sprache gesetzt!"
|
||||
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "You did not enable statistics. Use /settings in "
|
||||
"a private chat with the bot to enable them."
|
||||
msgstr "Du hast die Spiel-Statistiken nicht aktiviert. Aktiviere sie, mit dem "
|
||||
"/settings-Kommando in einem privaten Chat mit dem Bot."
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} games played"
|
||||
msgstr "{number} gespielte Spiele"
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} first places"
|
||||
msgstr "{number}x 1. Platz"
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} cards played"
|
||||
msgstr "{number} gespielte Karten"
|
||||
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Green"
|
||||
msgstr "{emoji} Grün"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Red"
|
||||
msgstr "{emoji} Rot"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Blue"
|
||||
msgstr "{emoji} Blau"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Yellow"
|
||||
msgstr "{emoji} Gelb"
|
||||
|
447
locales/it_IT/LC_MESSAGES/unobot.po
Normal file
447
locales/it_IT/LC_MESSAGES/unobot.po
Normal file
@ -0,0 +1,447 @@
|
||||
# Telegram bot to play UNO in group chats
|
||||
# Copyright (c) 2016 Jannes Höke <uno@jhoeke.de>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: uno_bot 0.1\n"
|
||||
"Report-Msgid-Bugs-To: uno@jhoeke.de\n"
|
||||
"POT-Creation-Date: 2016-05-22 20:02+0200\n"
|
||||
"PO-Revision-Date: 2016-05-22 21:27+0200\n"
|
||||
"Language-Team: en <uno@jhoeke.de>\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"X-Generator: Poedit 1.8.7\n"
|
||||
"Last-Translator: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Language: it_IT\n"
|
||||
|
||||
#: bot.py:60
|
||||
msgid ""
|
||||
"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>@mau_mau_bot</code> into your chat box and hit <b>space</b>, "
|
||||
"or click the <code>via @mau_mau_bot</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.\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."
|
||||
msgstr ""
|
||||
"Segui questi passaggi:\n"
|
||||
"\n"
|
||||
"1. Aggiungi questo bot ad un gruppo\n"
|
||||
"2. Nel gruppo, inizia un nuovo gioco con /new o unisciti ad una partita già "
|
||||
"avviata con /join\n"
|
||||
"3. Quando almeno due giocatori si sono uniti alla partita, si può iniziare "
|
||||
"con /start\n"
|
||||
"4. Digita <code>@mau_mau_bot</code> nella casella di testo e premi "
|
||||
"<b>spazio</b>, o clicca sul testo <code>via @mau_mau_bot</code> vicino ai "
|
||||
"messaggi. Potrai così vedere le tue carte (alcune in grigio), le opzioni "
|
||||
"extra come pesca e <b>?</b> per vedere lo stato della partita attuale. Le "
|
||||
"<b>carte in grigio</b> sono quelle che <b>non puoi giocare</b> al momento. "
|
||||
"Premi un'opzione per eseguire l'azione selezionata.\n"
|
||||
"I giocatori possono unirsi alla partita in qualsiasi momento. Per lasciare "
|
||||
"la partita, usa /leave. Se un giocatore impiega più di 90 secondi a giocare, "
|
||||
"puoi usare /skip per saltare il turno di quel giocatore.\n"
|
||||
"\n"
|
||||
"<b>Lingua</b> e altre opzioni: /settings\n"
|
||||
"Altri comandi (utilizzabili solo da chi ha creato la partita):\n"
|
||||
"/close - Chiude la lobby, nessun giocatore può unirsi al gioco dopo che "
|
||||
"questo è già avviato.\n"
|
||||
"/open - Apre la lobby, i giocatori possono unirsi al gioco in qualsiasi "
|
||||
"momento. \n"
|
||||
"/enable_translations - Traduce i messaggi importanti nelle lingue parlate "
|
||||
"in gioco\n"
|
||||
"/disable_translations - Usa l'inglese per questi messaggi\n"
|
||||
"\n"
|
||||
"<b>Sperimentale:</b> Gioca in più gruppi allo stesso tempo. Premi il tasto "
|
||||
"<code>Partita corrente: ...</code> e scegli il gruppo dove vuoi giocare la "
|
||||
"carta.\n"
|
||||
"Se ti piace questo bot, <a href=\"https://telegram.me/storebot?"
|
||||
"start=mau_mau_bot\">votami</a>, segui gli <a href=\"https://telegram.me/"
|
||||
"unobotupdates\">aggiornamenti</a> e compra il gioco di carte UNO. "
|
||||
|
||||
#: bot.py:88
|
||||
msgid ""
|
||||
"This bot is Free Software and licensed under the AGPL. The code is available "
|
||||
"here: \n"
|
||||
"https://github.com/jh0ker/mau_mau_bot"
|
||||
msgstr ""
|
||||
"Questo bot è Free Software e certificato con AGPL. Il codice è disponibile "
|
||||
"qui:\n"
|
||||
"https://github.com/jh0ker/mau_mau_bot"
|
||||
|
||||
#: bot.py:133
|
||||
msgid ""
|
||||
"Created a new game! Join the game with /join and start the game with /start"
|
||||
msgstr ""
|
||||
"È stato creato un nuovo gioco! Unisciti con /join e inizia la partita con /"
|
||||
"start"
|
||||
|
||||
#: bot.py:152
|
||||
msgid "The lobby is closed"
|
||||
msgstr "La lobby è chiusa. Nessuno nuovo giocatore può unirsi alla partita."
|
||||
|
||||
#: bot.py:156
|
||||
msgid "No game is running at the moment. Create a new game with /new"
|
||||
msgstr ""
|
||||
"Non c'è nessuna partita aperta al momento. Inizia un nuovo gioco con /new"
|
||||
|
||||
#: bot.py:162
|
||||
msgid "You already joined the game. Start the game with /start"
|
||||
msgstr "Ti sei già unito al gioco. Inizia la partita con /start"
|
||||
|
||||
#: bot.py:167
|
||||
msgid "Joined the game"
|
||||
msgstr "Si è unito al gioco"
|
||||
|
||||
#: bot.py:179 bot.py:191
|
||||
msgid "You are not playing in a game in this group."
|
||||
msgstr "Non stai giocando alcuna partita in questo gruppo."
|
||||
|
||||
#: bot.py:197 bot.py:258 bot.py:595
|
||||
msgid "Game ended!"
|
||||
msgstr "La partita è conclusa!"
|
||||
|
||||
#: bot.py:201
|
||||
msgid "Okay. Next Player: {name}"
|
||||
msgstr "Okay. Prossimo giocatore: {name}"
|
||||
|
||||
#: bot.py:219
|
||||
msgid "Game not found."
|
||||
msgstr "Partita non trovata."
|
||||
|
||||
#: bot.py:223
|
||||
msgid "Back to last group"
|
||||
msgstr "Vai all'ultimo gruppo. "
|
||||
|
||||
#: bot.py:227
|
||||
msgid "Please switch to the group you selected!"
|
||||
msgstr "Per favore, spostati sul gruppo che hai selezionato!"
|
||||
|
||||
#: bot.py:233
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Selected group: {group}\n"
|
||||
"<b>Make sure that you switch to the correct group!</b>"
|
||||
msgstr ""
|
||||
"Gruppo selezionato: {group}\n"
|
||||
"<b>Assicurati di spostarti nel gruppo giusto!</b>"
|
||||
|
||||
#: bot.py:260
|
||||
#, python-format
|
||||
msgid "Removing {name} from the game"
|
||||
msgstr "Sto rimuovendo {name} dalla partita"
|
||||
|
||||
#: bot.py:273
|
||||
msgid "There is no game running in this chat. Create a new one with /new"
|
||||
msgstr ""
|
||||
"Non c'è alcuna partita aperta in questa chat. Creane una nuova con /new"
|
||||
|
||||
#: bot.py:278
|
||||
msgid "The game has already started"
|
||||
msgstr "La partita è già iniziata"
|
||||
|
||||
#: bot.py:281
|
||||
msgid "At least two players must /join the game before you can start it"
|
||||
msgstr ""
|
||||
"Ci devono essere almeno due giocatori che hanno cliccato /join per iniziare "
|
||||
"la partita"
|
||||
|
||||
#: bot.py:297
|
||||
#, python-format
|
||||
msgid ""
|
||||
"First player: {name}\n"
|
||||
"Use /close to stop people from joining the game.\n"
|
||||
"Enable multi-translations with /enable_translations"
|
||||
msgstr ""
|
||||
"Primo giocatore: {name}\n"
|
||||
"Usa /close per impedire a nuovi giocatori di unirsi alla partita.\n"
|
||||
"Abilita la funzione di multi-traduzione con /enable_translations"
|
||||
|
||||
#: bot.py:321
|
||||
msgid "Please select the group you want to play in."
|
||||
msgstr "Per favore, seleziona il gruppo dove vuoi giocare."
|
||||
|
||||
#: bot.py:335 bot.py:361
|
||||
msgid "There is no running game in this chat."
|
||||
msgstr "Non c'è alcuna partita aperta in questa chat."
|
||||
|
||||
#: bot.py:342
|
||||
msgid "Closed the lobby. No more players can join this game."
|
||||
msgstr ""
|
||||
"La lobby è chiusa. Nessun nuovo giocatore può unirsi alla partita corrente."
|
||||
|
||||
#: bot.py:348 bot.py:373
|
||||
#, python-format
|
||||
msgid "Only the game creator ({name}) can do that."
|
||||
msgstr "Solo il creatore del gioco ({name}) può farlo. "
|
||||
|
||||
#: bot.py:349
|
||||
#, python-format
|
||||
msgid "Enabled multi-translations. Disable with /disable_translations"
|
||||
msgstr "Multi-traduzione abilitata. Disabilitala con /disable_translations"
|
||||
|
||||
#: bot.py:377
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Disabled multi-translations. Enable them again with /enable_translations"
|
||||
msgstr "Multi-traduzione disabilitata. Abilitala con /enable_translations"
|
||||
|
||||
#: bot.py:368
|
||||
msgid "Opened the lobby. New players may /join the game."
|
||||
msgstr ""
|
||||
"La lobby è aperta. Nuovi giocatori possono unirsi alla partita con /join"
|
||||
|
||||
#: bot.py:386
|
||||
msgid "You are not playing in a game in this chat."
|
||||
msgstr "Non stai giocando alcuna partita in questa chat. "
|
||||
|
||||
#: bot.py:400
|
||||
#, python-format
|
||||
msgid "Please wait {time} seconds"
|
||||
msgstr "Per favore, attendi {time} secondi"
|
||||
|
||||
#: bot.py:413
|
||||
#, python-format
|
||||
msgid ""
|
||||
"Waiting time to skip this player has been reduced to {time} seconds.\n"
|
||||
"Next player: {name}"
|
||||
msgstr ""
|
||||
"Il tempo di attesa per saltare questo giocatore è stata ridotta a {time} "
|
||||
"secondi.\n"
|
||||
"Prossimo giocatore: {name}"
|
||||
|
||||
#: bot.py:424
|
||||
#, python-format
|
||||
msgid ""
|
||||
"{name1} was skipped four times in a row and has been removed from the game.\n"
|
||||
"Next player: {name2}"
|
||||
msgstr ""
|
||||
"{name1} è stato saltato per quattro turni ed è stato rimosso dalla partita.\n"
|
||||
" \n"
|
||||
"Prossimo giocatore: {name2}"
|
||||
|
||||
#: bot.py:432
|
||||
#, python-format
|
||||
msgid ""
|
||||
"{name} was skipped four times in a row and has been removed from the game.\n"
|
||||
"The game ended."
|
||||
msgstr ""
|
||||
"{name} è stato saltato per quattro turni ed è stato rimosso dalla partita.\n"
|
||||
" \n"
|
||||
"La partita è conclusa."
|
||||
|
||||
#: bot.py:455
|
||||
msgid "All news here: https://telegram.me/unobotupdates"
|
||||
msgstr "Tutte le novità le trovi qui: https://telegram.me/unobotupdates"
|
||||
|
||||
#: bot.py:513
|
||||
#, python-format
|
||||
msgid "Current game: {group}"
|
||||
msgstr "Partita corrente: {group}"
|
||||
|
||||
#: bot.py:545
|
||||
#, python-format
|
||||
msgid "Cheat attempt by {name}"
|
||||
msgstr "{name} ha tentato di barare! "
|
||||
|
||||
#: bot.py:562
|
||||
msgid "Next player: {name}"
|
||||
msgstr "Prossimo giocatore: {name}"
|
||||
|
||||
#: bot.py:572
|
||||
#, python-format
|
||||
msgid "Waiting time for {name} has been reset to 90 seconds"
|
||||
msgstr "Il tempo di attesa per {name} è stato reimpostato a 90 secondi"
|
||||
|
||||
#: bot.py:585
|
||||
msgid "Please choose a color"
|
||||
msgstr "Per favore, scegli un colore"
|
||||
|
||||
#: bot.py:591
|
||||
#, python-format
|
||||
msgid "{name} won!"
|
||||
msgstr "{name} ha vinto!"
|
||||
|
||||
#: bot.py:613 bot.py:635 bot.py:647
|
||||
msgid "There are no more cards in the deck."
|
||||
msgstr "Non ci sono più carte sul tavolo."
|
||||
|
||||
#: bot.py:627
|
||||
#, python-format
|
||||
msgid "Bluff called! Giving 4 cards to {name}"
|
||||
msgstr "Il baro è stato scoperto! Sto dando 4 carte a {name}"
|
||||
|
||||
#: bot.py:639
|
||||
#, python-format
|
||||
msgid "{name1} didn't bluff! Giving 6 cards to {name2}"
|
||||
msgstr "{name1} non ha barato! Sto dando 6 carte a {name2}"
|
||||
|
||||
#: results.py:38
|
||||
msgid "Choose Color"
|
||||
msgstr "Scegli il colore"
|
||||
|
||||
#: results.py:56
|
||||
msgid "Cards (tap for game state):"
|
||||
msgstr "Carte (clicca per vedere lo stato della partita):"
|
||||
|
||||
#: results.py:60 results.py:123 results.py:165
|
||||
msgid "Current player: {name}"
|
||||
msgstr "Giocatore attuale: {name}"
|
||||
|
||||
#: results.py:61 results.py:124 results.py:167
|
||||
msgid "Last card: {card}"
|
||||
msgstr "Ultima carta: {card}"
|
||||
|
||||
#: results.py:62 results.py:125 results.py:168
|
||||
msgid "Players: {player_list}"
|
||||
msgstr "Giocatori: {player_list}"
|
||||
|
||||
#: results.py:72
|
||||
#, python-format
|
||||
msgid "{name} ({number} cards)"
|
||||
msgstr "{name} ({number} carte)"
|
||||
|
||||
#: results.py:81
|
||||
msgid "You are not playing"
|
||||
msgstr "Non stai giocando in questa partita. "
|
||||
|
||||
#: results.py:83
|
||||
msgid ""
|
||||
"Not playing right now. Use /new to start a game or /join to join the current "
|
||||
"game in this group"
|
||||
msgstr ""
|
||||
"Non stai giocando in questo momento. Usa /new per iniziare un nuovo gioco o /"
|
||||
"join per partecipare alla partita avviata in questo gruppo"
|
||||
|
||||
#: results.py:95
|
||||
msgid "The game wasn't started yet"
|
||||
msgstr "Il gioco non è ancora iniziato"
|
||||
|
||||
#: results.py:97
|
||||
msgid "Start the game with /start"
|
||||
msgstr "Inizia il gioco con /start"
|
||||
|
||||
#: results.py:108
|
||||
#, python-format
|
||||
msgid "Drawing 1 card"
|
||||
msgstr "Pesca 1 carta"
|
||||
|
||||
msgid "Drawing {number} cards"
|
||||
msgstr "Pesca {number} carte"
|
||||
|
||||
#: results.py:136
|
||||
msgid "Pass"
|
||||
msgstr "Passa"
|
||||
|
||||
#: results.py:148
|
||||
msgid "I'm calling your bluff!"
|
||||
msgstr "Penso che tu stia barando!"
|
||||
|
||||
#: settings.py:39
|
||||
msgid "Please edit your settings in a private chat with the bot."
|
||||
msgstr ""
|
||||
"Per favore, modifica le tue impostazioni in una chat privata con il bot."
|
||||
|
||||
#: settings.py:49
|
||||
msgid "Enable statistics"
|
||||
msgstr "Abilita le statistiche"
|
||||
|
||||
#: settings.py:51
|
||||
msgid "Delete all statistics"
|
||||
msgstr "Elimina tutte le statistiche"
|
||||
|
||||
#: settings.py:53
|
||||
msgid "Language"
|
||||
msgstr "Lingua"
|
||||
|
||||
#: settings.py:54
|
||||
msgid "Settings"
|
||||
msgstr "Impostazioni"
|
||||
|
||||
#: settings.py:68
|
||||
msgid "Enabled statistics!"
|
||||
msgstr "Statistiche abilitate!"
|
||||
|
||||
#: settings.py:70
|
||||
msgid "Select locale"
|
||||
msgstr "Seleziona locale"
|
||||
|
||||
#: settings.py:81
|
||||
msgid "Deleted and disabled statistics!"
|
||||
msgstr "Le statistiche sono state eliminate e disabilitate!"
|
||||
|
||||
#: settings.py:94
|
||||
msgid "Set locale!"
|
||||
msgstr "Imposta locale!"
|
||||
|
||||
#: simple_commands.py
|
||||
msgid ""
|
||||
"You did not enable statistics. Use /settings in a private chat with the bot "
|
||||
"to enable them."
|
||||
msgstr ""
|
||||
"Non hai abilitato le statistiche. Usa /settings in una chat privata col bot "
|
||||
"per abilitarle."
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} games played"
|
||||
msgstr "{number} partite giocate"
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} first places"
|
||||
msgstr "{number} primi posti"
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} cards played"
|
||||
msgstr "{number} carte giocate"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Green"
|
||||
msgstr "{emoji} Verde"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Red"
|
||||
msgstr "{emoji} Rosso"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Blue"
|
||||
msgstr "{emoji} Blu"
|
||||
|
||||
#: utils.py
|
||||
msgid "{emoji} Yellow"
|
||||
msgstr "{emoji} Giallo"
|
@ -29,7 +29,6 @@ msgstr ""
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=utf-8\n"
|
||||
"Content-Transfer-Encoding: utf-8\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
|
||||
#: bot.py:60
|
||||
@ -40,16 +39,15 @@ msgid "Follow these steps:\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 "
|
||||
"4. Type <code>@mau_mau_bot</code> into your chat box and hit <b>space</b>, "
|
||||
"or click the <code>via @mau_mau_bot</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"
|
||||
"player.\n"
|
||||
"\n"
|
||||
"<b>Language</b> and other settings: /settings\n"
|
||||
"Other commands (only game creator):\n"
|
||||
@ -76,14 +74,6 @@ msgstr ""
|
||||
msgid "Created a new game! Join the game with /join and start the game with /start"
|
||||
msgstr ""
|
||||
|
||||
#: bot.py
|
||||
msgid "Send this command in a group to be notified when a new game is started there."
|
||||
msgstr ""
|
||||
|
||||
#: bot.py
|
||||
msgid "A new game has been started in {title}"
|
||||
msgstr ""
|
||||
|
||||
#: bot.py:152
|
||||
msgid "The lobby is closed"
|
||||
msgstr ""
|
||||
@ -194,19 +184,14 @@ msgstr ""
|
||||
|
||||
#: bot.py:400
|
||||
#, python-format
|
||||
msgid "Please wait {time} second"
|
||||
msgid_plural "Please wait {time} seconds"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "Please wait {time} seconds"
|
||||
msgstr ""
|
||||
|
||||
#: bot.py:413
|
||||
#, python-format
|
||||
msgid "Waiting time to skip this player has been reduced to {time} second.\n"
|
||||
msgid "Waiting time to skip this player has been reduced to {time} seconds.\n"
|
||||
"Next player: {name}"
|
||||
msgid_plural "Waiting time to skip this player has been reduced to {time} seconds.\n"
|
||||
"Next player: {name}"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr ""
|
||||
|
||||
#: bot.py:424
|
||||
#, python-format
|
||||
@ -271,10 +256,8 @@ msgid "Choose Color"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:56
|
||||
msgid "Last card (tap for game state):"
|
||||
msgid_plural "Cards (tap for game state):"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "Cards (tap for game state):"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:60 results.py:123 results.py:165
|
||||
msgid "Current player: {name}"
|
||||
@ -285,17 +268,13 @@ msgid "Last card: {card}"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:62 results.py:125 results.py:168
|
||||
msgid "Player: {player_list}"
|
||||
msgid_plural "Players: {player_list}"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "Players: {player_list}"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:72
|
||||
#, python-format
|
||||
msgid "{name} ({number} card)"
|
||||
msgid_plural "{name} ({number} cards)"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "{name} ({number} cards)"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:81
|
||||
msgid "You are not playing"
|
||||
@ -316,10 +295,11 @@ msgstr ""
|
||||
|
||||
#: results.py:108
|
||||
#, python-format
|
||||
msgid "Drawing {number} card"
|
||||
msgid_plural "Drawing {number} cards"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "Drawing 1 card"
|
||||
msgstr ""
|
||||
|
||||
msgid "Drawing {number} cards"
|
||||
msgstr ""
|
||||
|
||||
#: results.py:136
|
||||
msgid "Pass"
|
||||
@ -372,22 +352,16 @@ msgid "You did not enable statistics. Use /settings in "
|
||||
msgstr ""
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} game played"
|
||||
msgid_plural "{number} games played"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "{number} games played"
|
||||
msgstr ""
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} first place"
|
||||
msgid_plural "{number} first places"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "{number} first places"
|
||||
msgstr ""
|
||||
|
||||
#: simple_commands.py
|
||||
msgid "{number} card played"
|
||||
msgid_plural "{number} cards played"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgid "{number} cards played"
|
||||
msgstr ""
|
||||
|
||||
|
||||
#: utils.py
|
||||
@ -405,3 +379,4 @@ msgstr ""
|
||||
#: utils.py
|
||||
msgid "{emoji} Yellow"
|
||||
msgstr ""
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
python-telegram-bot==5
|
||||
pony
|
55
results.py
55
results.py
@ -26,8 +26,8 @@ from telegram import InlineQueryResultArticle, InputTextMessageContent, \
|
||||
InlineQueryResultCachedSticker as Sticker
|
||||
|
||||
import card as c
|
||||
from utils import display_color, display_color_group, display_name
|
||||
from internationalization import _, __
|
||||
from utils import display_color, display_color_group, display_name, \
|
||||
list_subtract, _, __
|
||||
|
||||
|
||||
def add_choose_color(results, game):
|
||||
@ -36,7 +36,7 @@ def add_choose_color(results, game):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
id=color,
|
||||
title=_("選擇顏色"),
|
||||
title=_("Choose Color"),
|
||||
description=display_color(color),
|
||||
input_message_content=
|
||||
InputTextMessageContent(display_color_group(color, game))
|
||||
@ -44,16 +44,17 @@ def add_choose_color(results, game):
|
||||
)
|
||||
|
||||
|
||||
def add_other_cards(player, results, game):
|
||||
def add_other_cards(playable, player, results, game):
|
||||
"""Add hand cards when choosing colors"""
|
||||
if not playable:
|
||||
playable = list()
|
||||
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"hand",
|
||||
title=_("你的手牌(點一下以獲得遊戲狀態):",
|
||||
"你的手牌(點一下以獲得遊戲狀態):",
|
||||
len(player.cards)),
|
||||
description=', '.join([repr(card) for card in player.cards]),
|
||||
title=_("Cards (tap for game state):"),
|
||||
description=', '.join([repr(card) for card in
|
||||
list_subtract(player.cards, playable)]),
|
||||
input_message_content=game_info(game)
|
||||
)
|
||||
)
|
||||
@ -61,9 +62,7 @@ def add_other_cards(player, results, game):
|
||||
|
||||
def player_list(game):
|
||||
"""Generate list of player strings"""
|
||||
return [_("{name}(有 {number} 張牌)",
|
||||
"{name}(有 {number} 張牌)",
|
||||
len(player.cards))
|
||||
return [_("{name} ({number} cards)")
|
||||
.format(name=player.user.first_name, number=len(player.cards))
|
||||
for player in game.players]
|
||||
|
||||
@ -73,9 +72,11 @@ def add_no_game(results):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"nogame",
|
||||
title=_("你沒有在遊戲中"),
|
||||
title=_("You are not playing"),
|
||||
input_message_content=
|
||||
InputTextMessageContent(_('你目前沒有在遊玩,使用 /new 開始新的遊戲或使用 /join 加入目前的遊戲'))
|
||||
InputTextMessageContent(_('Not playing right now. Use /new to '
|
||||
'start a game or /join to join the '
|
||||
'current game in this group'))
|
||||
)
|
||||
)
|
||||
|
||||
@ -85,9 +86,9 @@ def add_not_started(results):
|
||||
results.append(
|
||||
InlineQueryResultArticle(
|
||||
"nogame",
|
||||
title=_("遊戲尚未開始"),
|
||||
title=_("The game wasn't started yet"),
|
||||
input_message_content=
|
||||
InputTextMessageContent(_('使用 /start 開始遊戲'))
|
||||
InputTextMessageContent(_('Start the game with /start'))
|
||||
)
|
||||
)
|
||||
|
||||
@ -100,9 +101,10 @@ def add_draw(player, results):
|
||||
Sticker(
|
||||
"draw", sticker_file_id=c.STICKERS['option_draw'],
|
||||
input_message_content=
|
||||
InputTextMessageContent(__('抽 {number} 張牌',
|
||||
'抽 {number} 張牌', n,
|
||||
multi=player.game.translate)
|
||||
InputTextMessageContent(__('Drawing 1 card', player.game.translate)
|
||||
if n == 1 else
|
||||
__('Drawing {number} cards',
|
||||
player.game.translate)
|
||||
.format(number=n))
|
||||
)
|
||||
)
|
||||
@ -125,9 +127,8 @@ def add_pass(results, game):
|
||||
results.append(
|
||||
Sticker(
|
||||
"pass", sticker_file_id=c.STICKERS['option_pass'],
|
||||
input_message_content=InputTextMessageContent(
|
||||
__('Pass!下一位', multi=game.translate)
|
||||
)
|
||||
input_message_content=InputTextMessageContent(__('Pass',
|
||||
game.translate))
|
||||
)
|
||||
)
|
||||
|
||||
@ -139,8 +140,8 @@ def add_call_bluff(results, game):
|
||||
"call_bluff",
|
||||
sticker_file_id=c.STICKERS['option_bluff'],
|
||||
input_message_content=
|
||||
InputTextMessageContent(__("你作弊,一定還有其他牌可以出!",
|
||||
multi=game.translate))
|
||||
InputTextMessageContent(__("I'm calling your bluff!",
|
||||
game.translate))
|
||||
)
|
||||
)
|
||||
|
||||
@ -162,13 +163,11 @@ def add_card(game, card, results, can_play):
|
||||
def game_info(game):
|
||||
players = player_list(game)
|
||||
return InputTextMessageContent(
|
||||
_("目前玩家:{name}")
|
||||
_("Current player: {name}")
|
||||
.format(name=display_name(game.current_player.user)) +
|
||||
"\n" +
|
||||
_("最後的牌:{card}").format(card=repr(game.last_card)) +
|
||||
_("Last card: {card}").format(card=repr(game.last_card)) +
|
||||
"\n" +
|
||||
_("玩家列表:{player_list}",
|
||||
"玩家列表:{player_list}",
|
||||
len(players))
|
||||
_("Players: {player_list}")
|
||||
.format(player_list=" -> ".join(players))
|
||||
)
|
41
settings.py
41
settings.py
@ -18,14 +18,18 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import logging
|
||||
|
||||
from telegram import ReplyKeyboardMarkup, Emoji
|
||||
from telegram.ext import CommandHandler, RegexHandler
|
||||
|
||||
from utils import send_async
|
||||
from user_setting import UserSetting
|
||||
from utils import _, user_locale
|
||||
from shared_vars import dispatcher
|
||||
from locales import available_locales
|
||||
from internationalization import _, user_locale
|
||||
|
||||
available_locales = [['en_US', 'de_DE'],
|
||||
['it_IT']]
|
||||
|
||||
|
||||
@user_locale
|
||||
@ -34,7 +38,8 @@ def show_settings(bot, update):
|
||||
|
||||
if update.message.chat.type != 'private':
|
||||
send_async(bot, chat.id,
|
||||
text=_("請私訊我來修改你的設定"))
|
||||
text=_("Please edit your settings in a private chat with "
|
||||
"the bot."))
|
||||
return
|
||||
|
||||
us = UserSetting.get(id=update.message.from_user.id)
|
||||
@ -43,12 +48,12 @@ def show_settings(bot, update):
|
||||
us = UserSetting(id=update.message.from_user.id)
|
||||
|
||||
if not us.stats:
|
||||
stats = Emoji.BAR_CHART + ' ' + _("啟用統計資料")
|
||||
stats = Emoji.BAR_CHART + ' ' + _("Enable statistics")
|
||||
else:
|
||||
stats = Emoji.CROSS_MARK + ' ' + _("刪除所有統計資料")
|
||||
stats = Emoji.CROSS_MARK + ' ' + _("Delete all statistics")
|
||||
|
||||
kb = [[stats], [Emoji.EARTH_GLOBE_EUROPE_AFRICA + ' ' + _("語言")]]
|
||||
send_async(bot, chat.id, text=Emoji.WRENCH + ' ' + _("設定"),
|
||||
kb = [[stats], [Emoji.EARTH_GLOBE_EUROPE_AFRICA + ' ' + _("Language")]]
|
||||
send_async(bot, chat.id, text=Emoji.WRENCH + ' ' + _("Settings"),
|
||||
reply_markup=ReplyKeyboardMarkup(keyboard=kb,
|
||||
one_time_keyboard=True))
|
||||
|
||||
@ -62,14 +67,11 @@ 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=_("已啟用統計資料!"))
|
||||
send_async(bot, chat.id, text=_("Enabled statistics!"))
|
||||
|
||||
elif option == Emoji.EARTH_GLOBE_EUROPE_AFRICA:
|
||||
kb = [[locale + ' - ' + descr]
|
||||
for locale, descr
|
||||
in sorted(available_locales.items())]
|
||||
send_async(bot, chat.id, text=_("選擇語言"),
|
||||
reply_markup=ReplyKeyboardMarkup(keyboard=kb,
|
||||
send_async(bot, chat.id, text=_("Select locale"),
|
||||
reply_markup=ReplyKeyboardMarkup(keyboard=available_locales,
|
||||
one_time_keyboard=True))
|
||||
|
||||
elif option == Emoji.CROSS_MARK:
|
||||
@ -78,7 +80,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=_("已停用並刪除統計資料!"))
|
||||
send_async(bot, chat.id, text=_("Deleted and disabled statistics!"))
|
||||
|
||||
|
||||
@user_locale
|
||||
@ -87,19 +89,18 @@ def locale_select(bot, update, groups):
|
||||
user = update.message.from_user
|
||||
option = groups[0]
|
||||
|
||||
if option in available_locales:
|
||||
if option in [locale for row in available_locales for locale in row]:
|
||||
us = UserSetting.get(id=user.id)
|
||||
us.lang = option
|
||||
_.push(option)
|
||||
send_async(bot, chat.id, text=_("已設定所選擇的語言"))
|
||||
send_async(bot, chat.id, text=_("Set locale!"))
|
||||
_.pop()
|
||||
|
||||
|
||||
def register():
|
||||
dispatcher.add_handler(CommandHandler('settings', show_settings))
|
||||
dispatcher.add_handler(RegexHandler('^([' + Emoji.BAR_CHART +
|
||||
dispatcher.add_handler(CommandHandler('settings', show_settings))
|
||||
dispatcher.add_handler(RegexHandler('^([' + Emoji.BAR_CHART +
|
||||
Emoji.EARTH_GLOBE_EUROPE_AFRICA +
|
||||
Emoji.CROSS_MARK + ']) .+$',
|
||||
kb_select, pass_groups=True))
|
||||
dispatcher.add_handler(RegexHandler(r'^(\w\w_\w\w) - .*',
|
||||
dispatcher.add_handler(RegexHandler(r'^(\w\w_\w\w)$',
|
||||
locale_select, pass_groups=True))
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
|
||||
from telegram.ext import Updater
|
||||
from telegram.contrib.botan import Botan
|
||||
from telegram.utils.botan import Botan
|
||||
|
||||
from game_manager import GameManager
|
||||
from database import db
|
||||
|
@ -21,41 +21,44 @@ from telegram import ParseMode
|
||||
from telegram.ext import CommandHandler
|
||||
|
||||
from user_setting import UserSetting
|
||||
from utils import send_async
|
||||
from utils import _, send_async, user_locale
|
||||
from shared_vars import dispatcher
|
||||
from internationalization import _, user_locale
|
||||
|
||||
help_text = ("請跟隨以下指示:\n\n"
|
||||
"1. 將這個機器人新增到群組\n"
|
||||
"2. 輸入 /new 開始一個新遊戲或輸入 /join 加入一個運行中的遊戲\n"
|
||||
"3. 當有兩個或以上的玩家加入,就可以用 /start 開始遊戲\n"
|
||||
"4. 輸入 <code>@unopl_bot</code> 然後按<b>空白鍵</b>或點一下 "
|
||||
"<code>via @unopl_bot</code> 或 <code>透過 @unopl_bot</code>,你便會看見你手上的牌或者是其他選項,例如:抽牌和"
|
||||
"<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> 因為一些原因,您無法同時在不同的群組中遊玩。\n"
|
||||
"如果你喜歡這個 bot,你可以選擇買一副 UNO 牌來支持 UNO!")
|
||||
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>@mau_mau_bot</code> into your chat box and hit "
|
||||
"<b>space</b>, or click the <code>via @mau_mau_bot</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.\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.")
|
||||
|
||||
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'
|
||||
'Pass icon by '
|
||||
'<a href="http://delapouite.com/">Delapouite</a>\n'
|
||||
"Originals available on http://game-icons.net\n"
|
||||
"Icons edited by ɳick")
|
||||
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")
|
||||
|
||||
|
||||
@user_locale
|
||||
@ -68,8 +71,7 @@ def help(bot, update):
|
||||
@user_locale
|
||||
def source(bot, update):
|
||||
"""Handler for the /help command"""
|
||||
send_async(bot, update.message.chat_id, text=_(source_text) + '\n' +
|
||||
_(attributions),
|
||||
send_async(bot, update.message.chat_id, text=_(source_text),
|
||||
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
||||
|
||||
|
||||
@ -87,38 +89,22 @@ 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=_("您尚未啟用統計資料,請私我 "
|
||||
"<code>/settings</code> 來啟用他", parse_mode=ParseMode.HTML))
|
||||
text=_("You did not enable statistics. Use /settings in "
|
||||
"a private chat with the bot to enable them."))
|
||||
else:
|
||||
stats_text = list()
|
||||
|
||||
n = us.games_played
|
||||
stats_text.append(
|
||||
_("已遊玩 {number} 個遊戲",
|
||||
"已遊玩 {number} 個遊戲",
|
||||
n).format(number=n)
|
||||
)
|
||||
|
||||
n = us.first_places
|
||||
_("{number} games played").format(number=us.games_played))
|
||||
stats_text.append(
|
||||
_("拿了 {number} 次第一名",
|
||||
"拿了 {number} 次第一名",
|
||||
n).format(number=n)
|
||||
)
|
||||
|
||||
n = us.cards_played
|
||||
_("{number} first places").format(number=us.first_places))
|
||||
stats_text.append(
|
||||
_("已遊玩 {number} 張牌",
|
||||
"已遊玩 {number} 張牌",
|
||||
n).format(number=n)
|
||||
)
|
||||
_("{number} cards played").format(number=us.cards_played))
|
||||
|
||||
send_async(bot, update.message.chat_id,
|
||||
text='\n'.join(stats_text))
|
||||
|
||||
|
||||
def register():
|
||||
dispatcher.add_handler(CommandHandler('help', help))
|
||||
dispatcher.add_handler(CommandHandler('source', source))
|
||||
# dispatcher.add_handler(CommandHandler('news', news))
|
||||
dispatcher.add_handler(CommandHandler('stats', stats))
|
||||
dispatcher.add_handler(CommandHandler('help', help))
|
||||
dispatcher.add_handler(CommandHandler('source', source))
|
||||
dispatcher.add_handler(CommandHandler('news', news))
|
||||
dispatcher.add_handler(CommandHandler('stats', stats))
|
||||
|
@ -138,7 +138,6 @@ class Test(unittest.TestCase):
|
||||
|
||||
def test_bluffing(self):
|
||||
p = Player(self.game, "Player 0")
|
||||
Player(self.game, "Player 01")
|
||||
|
||||
self.game.last_card = c.Card(c.RED, '1')
|
||||
|
||||
@ -157,8 +156,4 @@ class Test(unittest.TestCase):
|
||||
c.Card(None, None, c.CHOOSE)]
|
||||
|
||||
p.playable_cards()
|
||||
|
||||
p.play(c.Card(None, None, c.DRAW_FOUR))
|
||||
self.game.choose_color(c.GREEN)
|
||||
|
||||
self.assertFalse(self.game.current_player.prev.bluffing)
|
||||
self.assertFalse(p.bluffing)
|
||||
|
@ -24,7 +24,7 @@ from database import db, Optional, Required, PrimaryKey, db_session
|
||||
class UserSetting(db.Entity):
|
||||
|
||||
id = PrimaryKey(int, auto=False, size=64) # Telegram User ID
|
||||
lang = Optional(str, default='') # The language setting for this user
|
||||
lang = Optional(str, default='en') # The language setting for this user
|
||||
stats = Optional(bool, default=False) # Opt-in to keep game statistics
|
||||
first_places = Optional(int, default=0) # Nr. of games won in first place
|
||||
games_played = Optional(int, default=0) # Nr. of games completed
|
||||
|
127
utils.py
127
utils.py
@ -19,17 +19,52 @@
|
||||
|
||||
|
||||
import logging
|
||||
from functools import wraps
|
||||
|
||||
from flufl.i18n import registry
|
||||
from flufl.i18n import PackageStrategy
|
||||
|
||||
from telegram import Emoji
|
||||
from telegram.ext.dispatcher import run_async
|
||||
import locales
|
||||
from database import db_session
|
||||
from user_setting import UserSetting
|
||||
from shared_vars import gm
|
||||
|
||||
from internationalization import _, __
|
||||
|
||||
strategy = PackageStrategy('unobot', locales)
|
||||
application = registry.register(strategy)
|
||||
_ = application._
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
TIMEOUT = 2.5
|
||||
|
||||
|
||||
def __(string, multi_translate):
|
||||
"""Translates text into all locales on the stack"""
|
||||
translations = list()
|
||||
locales = list()
|
||||
|
||||
if not multi_translate:
|
||||
_.push('en_US')
|
||||
translations.append(_(string))
|
||||
_.pop()
|
||||
|
||||
else:
|
||||
while _.code:
|
||||
translation = _(string)
|
||||
|
||||
if translation not in translations:
|
||||
translations.append(translation)
|
||||
|
||||
locales.append(_.code)
|
||||
_.pop()
|
||||
|
||||
for l in reversed(locales):
|
||||
_.push(l)
|
||||
|
||||
return '\n'.join(translations)
|
||||
|
||||
|
||||
def list_subtract(list1, list2):
|
||||
""" Helper function to subtract two lists and return the sorted result """
|
||||
list1 = list1.copy()
|
||||
@ -51,28 +86,28 @@ def display_name(user):
|
||||
def display_color(color):
|
||||
""" Convert a color code to actual color name """
|
||||
if color == "r":
|
||||
return _("{emoji} 紅色").format(emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
return _("{emoji} Red").format(emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
if color == "b":
|
||||
return _("{emoji} 藍色").format(emoji=Emoji.BLUE_HEART)
|
||||
return _("{emoji} Blue").format(emoji=Emoji.BLUE_HEART)
|
||||
if color == "g":
|
||||
return _("{emoji} 綠色").format(emoji=Emoji.GREEN_HEART)
|
||||
return _("{emoji} Green").format(emoji=Emoji.GREEN_HEART)
|
||||
if color == "y":
|
||||
return _("{emoji} 黃色").format(emoji=Emoji.YELLOW_HEART)
|
||||
return _("{emoji} Yellow").format(emoji=Emoji.YELLOW_HEART)
|
||||
|
||||
|
||||
def display_color_group(color, game):
|
||||
""" Convert a color code to actual color name """
|
||||
if color == "r":
|
||||
return __("{emoji} 紅色", game.translate).format(
|
||||
return __("{emoji} Red", game.translate).format(
|
||||
emoji=Emoji.HEAVY_BLACK_HEART)
|
||||
if color == "b":
|
||||
return __("{emoji} 藍色", game.translate).format(
|
||||
return __("{emoji} Blue", game.translate).format(
|
||||
emoji=Emoji.BLUE_HEART)
|
||||
if color == "g":
|
||||
return __("{emoji} 綠色", game.translate).format(
|
||||
return __("{emoji} Green", game.translate).format(
|
||||
emoji=Emoji.GREEN_HEART)
|
||||
if color == "y":
|
||||
return __("{emoji} 黃色", game.translate).format(
|
||||
return __("{emoji} Yellow", game.translate).format(
|
||||
emoji=Emoji.YELLOW_HEART)
|
||||
|
||||
|
||||
@ -103,3 +138,75 @@ def answer_async(bot, *args, **kwargs):
|
||||
bot.answerInlineQuery(*args, **kwargs)
|
||||
except Exception as e:
|
||||
error(None, None, e)
|
||||
|
||||
|
||||
def user_locale(func):
|
||||
@wraps(func)
|
||||
@db_session
|
||||
def wrapped(bot, update, *pargs, **kwargs):
|
||||
user, chat = _user_chat_from_update(update)
|
||||
|
||||
with db_session:
|
||||
us = UserSetting.get(id=user.id)
|
||||
|
||||
if us:
|
||||
_.push(us.lang)
|
||||
else:
|
||||
_.push('en_US')
|
||||
|
||||
result = func(bot, update, *pargs, **kwargs)
|
||||
_.pop()
|
||||
return result
|
||||
return wrapped
|
||||
|
||||
|
||||
def game_locales(func):
|
||||
@wraps(func)
|
||||
@db_session
|
||||
def wrapped(bot, update, *pargs, **kwargs):
|
||||
user, chat = _user_chat_from_update(update)
|
||||
player = gm.player_for_user_in_chat(user, chat)
|
||||
locales = list()
|
||||
|
||||
if player:
|
||||
for player in player.game.players:
|
||||
us = UserSetting.get(id=player.user.id)
|
||||
|
||||
if us:
|
||||
loc = us.lang
|
||||
else:
|
||||
loc = 'en_US'
|
||||
|
||||
if loc in locales:
|
||||
continue
|
||||
|
||||
_.push(loc)
|
||||
locales.append(loc)
|
||||
|
||||
result = func(bot, update, *pargs, **kwargs)
|
||||
|
||||
for i in locales:
|
||||
_.pop()
|
||||
return result
|
||||
return wrapped
|
||||
|
||||
|
||||
def _user_chat_from_update(update):
|
||||
|
||||
try:
|
||||
user = update.message.from_user
|
||||
chat = update.message.chat
|
||||
except (NameError, AttributeError):
|
||||
try:
|
||||
user = update.inline_query.from_user
|
||||
chat = gm.userid_current[user.id].game.chat
|
||||
except KeyError:
|
||||
chat = None
|
||||
except (NameError, AttributeError):
|
||||
try:
|
||||
user = update.chosen_inline_result.from_user
|
||||
chat = gm.userid_current[user.id].game.chat
|
||||
except (NameError, AttributeError):
|
||||
chat = None
|
||||
|
||||
return user, chat
|
||||
|
Reference in New Issue
Block a user