locales are working, added de_DE locale
This commit is contained in:
parent
becc7e28dc
commit
5ece46527a
8 changed files with 540 additions and 170 deletions
205
bot.py
205
bot.py
|
@ -30,9 +30,6 @@ from telegram.ext import Updater, InlineQueryHandler, \
|
||||||
from telegram.ext.dispatcher import run_async
|
from telegram.ext.dispatcher import run_async
|
||||||
from telegram.utils.botan import Botan
|
from telegram.utils.botan import Botan
|
||||||
|
|
||||||
from flufl.i18n import registry
|
|
||||||
from flufl.i18n import PackageStrategy
|
|
||||||
|
|
||||||
from game_manager import GameManager
|
from game_manager import GameManager
|
||||||
from credentials import TOKEN, BOTAN_TOKEN
|
from credentials import TOKEN, BOTAN_TOKEN
|
||||||
from start_bot import start_bot
|
from start_bot import start_bot
|
||||||
|
@ -43,8 +40,9 @@ from utils import display_name
|
||||||
import card as c
|
import card as c
|
||||||
from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError,
|
from errors import (NoGameInChatError, LobbyClosedError, AlreadyJoinedError,
|
||||||
NotEnoughPlayersError, DeckEmptyError)
|
NotEnoughPlayersError, DeckEmptyError)
|
||||||
from database import db_session
|
from database import db_session, user_locale
|
||||||
import i18n
|
from utils import _
|
||||||
|
|
||||||
|
|
||||||
TIMEOUT = 2.5
|
TIMEOUT = 2.5
|
||||||
|
|
||||||
|
@ -53,10 +51,6 @@ logging.basicConfig(
|
||||||
level=logging.DEBUG)
|
level=logging.DEBUG)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
strategy = PackageStrategy('uno', i18n)
|
|
||||||
application = registry.register(strategy)
|
|
||||||
_ = application._
|
|
||||||
|
|
||||||
gm = GameManager()
|
gm = GameManager()
|
||||||
u = Updater(token=TOKEN, workers=32)
|
u = Updater(token=TOKEN, workers=32)
|
||||||
dp = u.dispatcher
|
dp = u.dispatcher
|
||||||
|
@ -91,7 +85,7 @@ help_text = ("Follow these steps:\n\n"
|
||||||
"<a href=\"https://telegram.me/storebot?start=mau_mau_bot\">"
|
"<a href=\"https://telegram.me/storebot?start=mau_mau_bot\">"
|
||||||
"rate me</a>, join the "
|
"rate me</a>, join the "
|
||||||
"<a href=\"https://telegram.me/unobotupdates\">update channel</a>"
|
"<a href=\"https://telegram.me/unobotupdates\">update channel</a>"
|
||||||
" and buy an UNO card game.\n")
|
" and buy an UNO card game.")
|
||||||
|
|
||||||
source_text = ("This bot is Free Software and licensed under the AGPL. "
|
source_text = ("This bot is Free Software and licensed under the AGPL. "
|
||||||
"The code is available here: \n"
|
"The code is available here: \n"
|
||||||
|
@ -127,6 +121,7 @@ def error(bot, update, error):
|
||||||
logger.exception(error)
|
logger.exception(error)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def new_game(bot, update):
|
def new_game(bot, update):
|
||||||
"""Handler for the /new command"""
|
"""Handler for the /new command"""
|
||||||
chat_id = update.message.chat_id
|
chat_id = update.message.chat_id
|
||||||
|
@ -138,13 +133,14 @@ def new_game(bot, update):
|
||||||
game = gm.new_game(update.message.chat)
|
game = gm.new_game(update.message.chat)
|
||||||
game.owner = update.message.from_user
|
game.owner = update.message.from_user
|
||||||
send_async(bot, chat_id,
|
send_async(bot, chat_id,
|
||||||
text="Created a new game! Join the game with /join "
|
text=_("Created a new game! Join the game with /join "
|
||||||
"and start the game with /start")
|
"and start the game with /start"))
|
||||||
|
|
||||||
if botan:
|
if botan:
|
||||||
botan.track(update.message, 'New games')
|
botan.track(update.message, 'New games')
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def join_game(bot, update):
|
def join_game(bot, update):
|
||||||
"""Handler for the /join command"""
|
"""Handler for the /join command"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -157,32 +153,33 @@ def join_game(bot, update):
|
||||||
gm.join_game(update.message.from_user, chat)
|
gm.join_game(update.message.from_user, chat)
|
||||||
|
|
||||||
except LobbyClosedError:
|
except LobbyClosedError:
|
||||||
send_async(bot, chat.id, text="The lobby is closed")
|
send_async(bot, chat.id, text=_("The lobby is closed"))
|
||||||
|
|
||||||
except NoGameInChatError:
|
except NoGameInChatError:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="No game is running at the moment. "
|
text=_("No game is running at the moment. "
|
||||||
"Create a new game with /new",
|
"Create a new game with /new"),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
except AlreadyJoinedError:
|
except AlreadyJoinedError:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="You already joined the game. Start the game "
|
text=_("You already joined the game. Start the game "
|
||||||
"with /start",
|
"with /start"),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
except DeckEmptyError:
|
except DeckEmptyError:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="There are not enough cards left in the deck for new "
|
text=_("There are not enough cards left in the deck for new "
|
||||||
"players to join.",
|
"players to join."),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Joined the game",
|
text=_("Joined the game"),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def leave_game(bot, update):
|
def leave_game(bot, update):
|
||||||
"""Handler for the /leave command"""
|
"""Handler for the /leave command"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -191,8 +188,8 @@ def leave_game(bot, update):
|
||||||
player = gm.player_for_user_in_chat(user, chat)
|
player = gm.player_for_user_in_chat(user, chat)
|
||||||
|
|
||||||
if player is None:
|
if player is None:
|
||||||
send_async(bot, chat.id, text="You are not playing in a game in "
|
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||||
"this group.",
|
"this group."),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -203,18 +200,18 @@ def leave_game(bot, update):
|
||||||
gm.leave_game(user, chat)
|
gm.leave_game(user, chat)
|
||||||
|
|
||||||
except NoGameInChatError:
|
except NoGameInChatError:
|
||||||
send_async(bot, chat.id, text="You are not playing in a game in "
|
send_async(bot, chat.id, text=_("You are not playing in a game in "
|
||||||
"this group.",
|
"this group."),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
except NotEnoughPlayersError:
|
except NotEnoughPlayersError:
|
||||||
gm.end_game(chat, user)
|
gm.end_game(chat, user)
|
||||||
send_async(bot, chat.id, text="Game ended!")
|
send_async(bot, chat.id, text=_("Game ended!"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Okay. Next Player: " +
|
text=_("Okay. Next Player: {name}").format(
|
||||||
display_name(game.current_player.user),
|
name=display_name(game.current_player.user)),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
|
|
||||||
|
@ -231,29 +228,30 @@ def select_game(bot, update):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
bot.sendMessage(update.callback_query.message.chat_id,
|
bot.sendMessage(update.callback_query.message.chat_id,
|
||||||
text="Game not found.",
|
text=_("Game not found."),
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
return
|
return
|
||||||
|
|
||||||
back = [[InlineKeyboardButton(text='Back to last group',
|
back = [[InlineKeyboardButton(text=_("Back to last group"),
|
||||||
switch_inline_query='')]]
|
switch_inline_query='')]]
|
||||||
|
|
||||||
bot.answerCallbackQuery(update.callback_query.id,
|
bot.answerCallbackQuery(update.callback_query.id,
|
||||||
text="Please switch to the group you selected!",
|
text=_("Please switch to the group you selected!"),
|
||||||
show_alert=False,
|
show_alert=False,
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
bot.editMessageText(chat_id=update.callback_query.message.chat_id,
|
bot.editMessageText(chat_id=update.callback_query.message.chat_id,
|
||||||
message_id=update.callback_query.message.message_id,
|
message_id=update.callback_query.message.message_id,
|
||||||
text="Selected group: %s\n"
|
text=_("Selected group: {group}\n"
|
||||||
"<b>Make sure that you switch to the correct "
|
"<b>Make sure that you switch to the correct "
|
||||||
"group!</b>"
|
"group!</b>").format(
|
||||||
% gm.userid_current[user_id].game.chat.title,
|
group=gm.userid_current[user_id].game.chat.title),
|
||||||
reply_markup=InlineKeyboardMarkup(back),
|
reply_markup=InlineKeyboardMarkup(back),
|
||||||
parse_mode=ParseMode.HTML,
|
parse_mode=ParseMode.HTML,
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def status_update(bot, update):
|
def status_update(bot, update):
|
||||||
"""Remove player from game if user leaves the group"""
|
"""Remove player from game if user leaves the group"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -270,12 +268,13 @@ def status_update(bot, update):
|
||||||
pass
|
pass
|
||||||
except NotEnoughPlayersError:
|
except NotEnoughPlayersError:
|
||||||
gm.end_game(chat, user)
|
gm.end_game(chat, user)
|
||||||
send_async(bot, chat.id, text="Game ended!")
|
send_async(bot, chat.id, text=_("Game ended!"))
|
||||||
else:
|
else:
|
||||||
send_async(bot, chat.id, text="Removing %s from the game"
|
send_async(bot, chat.id, text=_("Removing {name} from the game")
|
||||||
% display_name(user))
|
.format(name=display_name(user)))
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def start_game(bot, update, args):
|
def start_game(bot, update, args):
|
||||||
"""Handler for the /start command"""
|
"""Handler for the /start command"""
|
||||||
|
|
||||||
|
@ -285,16 +284,18 @@ def start_game(bot, update, args):
|
||||||
try:
|
try:
|
||||||
game = gm.chatid_games[chat.id][-1]
|
game = gm.chatid_games[chat.id][-1]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
send_async(bot, chat.id, text="There is no game running in this "
|
send_async(bot, chat.id,
|
||||||
"chat. Create a new one with /new")
|
text=_("There is no game running in this chat. Create "
|
||||||
|
"a new one with /new"))
|
||||||
return
|
return
|
||||||
|
|
||||||
if game.started:
|
if game.started:
|
||||||
send_async(bot, chat.id, text="The game has already started")
|
send_async(bot, chat.id, text=_("The game has already started"))
|
||||||
|
|
||||||
elif len(game.players) < 2:
|
elif len(game.players) < 2:
|
||||||
send_async(bot, chat.id, text="At least two players must /join "
|
send_async(bot, chat.id,
|
||||||
"the game before you can start it")
|
text=_("At least two players must /join the game "
|
||||||
|
"before you can start it"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
game.play_card(game.last_card)
|
game.play_card(game.last_card)
|
||||||
|
@ -309,10 +310,12 @@ def start_game(bot, update, args):
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
bot.sendMessage(chat.id,
|
bot.sendMessage(chat.id,
|
||||||
text="First player: %s\n"
|
text=_("First player: {name}\n"
|
||||||
"Use /close to stop people from joining "
|
"Use /close to stop people from "
|
||||||
"the game."
|
"joining the game.")
|
||||||
% display_name(game.current_player.user),
|
.format(
|
||||||
|
name=display_name(game.current_player.user)
|
||||||
|
),
|
||||||
timeout=TIMEOUT)
|
timeout=TIMEOUT)
|
||||||
|
|
||||||
send_first()
|
send_first()
|
||||||
|
@ -333,13 +336,14 @@ def start_game(bot, update, args):
|
||||||
)
|
)
|
||||||
|
|
||||||
send_async(bot, update.message.chat_id,
|
send_async(bot, update.message.chat_id,
|
||||||
text='Please select the group you want to play in.',
|
text=_('Please select the group you want to play in.'),
|
||||||
reply_markup=InlineKeyboardMarkup(groups))
|
reply_markup=InlineKeyboardMarkup(groups))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
help(bot, update)
|
help(bot, update)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def close_game(bot, update):
|
def close_game(bot, update):
|
||||||
"""Handler for the /close command"""
|
"""Handler for the /close command"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -347,25 +351,27 @@ def close_game(bot, update):
|
||||||
games = gm.chatid_games.get(chat.id)
|
games = gm.chatid_games.get(chat.id)
|
||||||
|
|
||||||
if not games:
|
if not games:
|
||||||
send_async(bot, chat.id, text="There is no running game in this chat.")
|
send_async(bot, chat.id,
|
||||||
|
text=_("There is no running game in this chat."))
|
||||||
return
|
return
|
||||||
|
|
||||||
game = games[-1]
|
game = games[-1]
|
||||||
|
|
||||||
if game.owner.id == user.id:
|
if game.owner.id == user.id:
|
||||||
game.open = False
|
game.open = False
|
||||||
send_async(bot, chat.id, text="Closed the lobby. "
|
send_async(bot, chat.id, text=_("Closed the lobby. "
|
||||||
"No more players can join this game.")
|
"No more players can join this game."))
|
||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Only the game creator (%s) can do that"
|
text=_("Only the game creator ({name}) can do that")
|
||||||
% game.owner.first_name,
|
.format(name=game.owner.first_name),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def open_game(bot, update):
|
def open_game(bot, update):
|
||||||
"""Handler for the /open command"""
|
"""Handler for the /open command"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -373,24 +379,26 @@ def open_game(bot, update):
|
||||||
games = gm.chatid_games.get(chat.id)
|
games = gm.chatid_games.get(chat.id)
|
||||||
|
|
||||||
if not games:
|
if not games:
|
||||||
send_async(bot, chat.id, text="There is no running game in this chat.")
|
send_async(bot, chat.id,
|
||||||
|
text=_("There is no running game in this chat."))
|
||||||
return
|
return
|
||||||
|
|
||||||
game = games[-1]
|
game = games[-1]
|
||||||
|
|
||||||
if game.owner.id == user.id:
|
if game.owner.id == user.id:
|
||||||
game.open = True
|
game.open = True
|
||||||
send_async(bot, chat.id, text="Opened the lobby. "
|
send_async(bot, chat.id, text=_("Opened the lobby. "
|
||||||
"New players may /join the game.")
|
"New players may /join the game."))
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Only the game creator (%s) can do that."
|
text=_("Only the game creator ({name}) can do that")
|
||||||
% game.owner.first_name,
|
.format(name=game.owner.first_name),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def skip_player(bot, update):
|
def skip_player(bot, update):
|
||||||
"""Handler for the /skip command"""
|
"""Handler for the /skip command"""
|
||||||
chat = update.message.chat
|
chat = update.message.chat
|
||||||
|
@ -398,8 +406,8 @@ def skip_player(bot, update):
|
||||||
|
|
||||||
player = gm.player_for_user_in_chat(user, chat)
|
player = gm.player_for_user_in_chat(user, chat)
|
||||||
if not player:
|
if not player:
|
||||||
send_async(bot, chat.id, text="You are not playing in a game in this "
|
send_async(bot, chat.id,
|
||||||
"chat.")
|
text=_("You are not playing in a game in this chat."))
|
||||||
return
|
return
|
||||||
|
|
||||||
game = player.game
|
game = player.game
|
||||||
|
@ -412,8 +420,8 @@ def skip_player(bot, update):
|
||||||
|
|
||||||
if delta < skipped_player.waiting_time:
|
if delta < skipped_player.waiting_time:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Please wait %d seconds"
|
text=_("Please wait {time} seconds")
|
||||||
% (skipped_player.waiting_time - delta),
|
.format(time=(skipped_player.waiting_time - delta)),
|
||||||
reply_to_message_id=update.message.message_id)
|
reply_to_message_id=update.message.message_id)
|
||||||
|
|
||||||
elif skipped_player.waiting_time > 0:
|
elif skipped_player.waiting_time > 0:
|
||||||
|
@ -425,52 +433,56 @@ def skip_player(bot, update):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Waiting time to skip this player has "
|
text=_("Waiting time to skip this player has "
|
||||||
"been reduced to %d seconds.\n"
|
"been reduced to {time} seconds.\n"
|
||||||
"Next player: %s"
|
"Next player: {name}")
|
||||||
% (skipped_player.waiting_time,
|
.format(time=skipped_player.waiting_time,
|
||||||
display_name(next_player.user)))
|
name=display_name(next_player.user)))
|
||||||
game.turn()
|
game.turn()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
gm.leave_game(skipped_player.user, chat)
|
gm.leave_game(skipped_player.user, chat)
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="%s was skipped four times in a row "
|
text=_("{name1} was skipped four times in a row "
|
||||||
"and has been removed from the game.\n"
|
"and has been removed from the game.\n"
|
||||||
"Next player: %s"
|
"Next player: {name2}")
|
||||||
% (display_name(skipped_player.user),
|
.format(name1=display_name(skipped_player.user),
|
||||||
display_name(next_player.user)))
|
name2=display_name(next_player.user)))
|
||||||
|
|
||||||
except NotEnoughPlayersError:
|
except NotEnoughPlayersError:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="%s was skipped four times in a row "
|
text=_("{name} was skipped four times in a row "
|
||||||
"and has been removed from the game.\n"
|
"and has been removed from the game.\n"
|
||||||
"The game ended."
|
"The game ended.")
|
||||||
% display_name(skipped_player.user))
|
.format(name=display_name(skipped_player.user)))
|
||||||
|
|
||||||
gm.end_game(chat.id, skipped_player.user)
|
gm.end_game(chat.id, skipped_player.user)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def help(bot, update):
|
def help(bot, update):
|
||||||
"""Handler for the /help command"""
|
"""Handler for the /help command"""
|
||||||
send_async(bot, update.message.chat_id, text=_(help_text),
|
send_async(bot, update.message.chat_id, text=_(help_text),
|
||||||
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def source(bot, update):
|
def source(bot, update):
|
||||||
"""Handler for the /help command"""
|
"""Handler for the /help command"""
|
||||||
send_async(bot, update.message.chat_id, text=source_text,
|
send_async(bot, update.message.chat_id, text=_(source_text),
|
||||||
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
parse_mode=ParseMode.HTML, disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def news(bot, update):
|
def news(bot, update):
|
||||||
"""Handler for the /news command"""
|
"""Handler for the /news command"""
|
||||||
send_async(bot, update.message.chat_id,
|
send_async(bot, update.message.chat_id,
|
||||||
text="All news here: https://telegram.me/unobotupdates",
|
text=_("All news here: https://telegram.me/unobotupdates"),
|
||||||
disable_web_page_preview=True)
|
disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def reply_to_query(bot, update):
|
def reply_to_query(bot, update):
|
||||||
"""
|
"""
|
||||||
Handler for inline queries.
|
Handler for inline queries.
|
||||||
|
@ -525,12 +537,13 @@ def reply_to_query(bot, update):
|
||||||
result.id += ':%d' % player.anti_cheat
|
result.id += ':%d' % player.anti_cheat
|
||||||
|
|
||||||
if players and game and len(players) > 1:
|
if players and game and len(players) > 1:
|
||||||
switch = 'Current game: %s' % game.chat.title
|
switch = _('Current game: {game}').format(game=game.chat.title)
|
||||||
|
|
||||||
answer_async(bot, update.inline_query.id, results, cache_time=0,
|
answer_async(bot, update.inline_query.id, results, cache_time=0,
|
||||||
switch_pm_text=switch, switch_pm_parameter='select')
|
switch_pm_text=switch, switch_pm_parameter='select')
|
||||||
|
|
||||||
|
|
||||||
|
@user_locale
|
||||||
def process_result(bot, update):
|
def process_result(bot, update):
|
||||||
"""
|
"""
|
||||||
Handler for chosen inline results.
|
Handler for chosen inline results.
|
||||||
|
@ -557,7 +570,8 @@ def process_result(bot, update):
|
||||||
return
|
return
|
||||||
elif int(anti_cheat) != last_anti_cheat:
|
elif int(anti_cheat) != last_anti_cheat:
|
||||||
send_async(bot, chat.id,
|
send_async(bot, chat.id,
|
||||||
text="Cheat attempt by %s" % display_name(player.user))
|
text=_("Cheat attempt by {name}")
|
||||||
|
.format(name=display_name(player.user)))
|
||||||
return
|
return
|
||||||
elif result_id == 'call_bluff':
|
elif result_id == 'call_bluff':
|
||||||
reset_waiting_time(bot, player)
|
reset_waiting_time(bot, player)
|
||||||
|
@ -574,8 +588,9 @@ def process_result(bot, update):
|
||||||
do_play_card(bot, player, result_id)
|
do_play_card(bot, player, result_id)
|
||||||
|
|
||||||
if game in gm.chatid_games.get(chat.id, list()):
|
if game in gm.chatid_games.get(chat.id, list()):
|
||||||
send_async(bot, chat.id, text="Next player: " +
|
send_async(bot, chat.id,
|
||||||
display_name(game.current_player.user))
|
text=_("Next player: {name}")
|
||||||
|
.format(name=display_name(game.current_player.user)))
|
||||||
|
|
||||||
|
|
||||||
def reset_waiting_time(bot, player):
|
def reset_waiting_time(bot, player):
|
||||||
|
@ -584,8 +599,9 @@ def reset_waiting_time(bot, player):
|
||||||
|
|
||||||
if player.waiting_time < 90:
|
if player.waiting_time < 90:
|
||||||
player.waiting_time = 90
|
player.waiting_time = 90
|
||||||
send_async(bot, chat.id, text="Waiting time for %s has been reset to "
|
send_async(bot, chat.id,
|
||||||
"90 seconds" % display_name(player.user))
|
text=_("Waiting time for {name} has been reset to 90 "
|
||||||
|
"seconds").format(name=display_name(player.user)))
|
||||||
|
|
||||||
|
|
||||||
def do_play_card(bot, player, result_id):
|
def do_play_card(bot, player, result_id):
|
||||||
|
@ -597,17 +613,18 @@ def do_play_card(bot, player, result_id):
|
||||||
user = player.user
|
user = player.user
|
||||||
|
|
||||||
if game.choosing_color:
|
if game.choosing_color:
|
||||||
send_async(bot, chat.id, text="Please choose a color")
|
send_async(bot, chat.id, text=_("Please choose a color"))
|
||||||
|
|
||||||
if len(player.cards) == 1:
|
if len(player.cards) == 1:
|
||||||
send_async(bot, chat.id, text="UNO!")
|
send_async(bot, chat.id, text=_("UNO!"))
|
||||||
|
|
||||||
if len(player.cards) == 0:
|
if len(player.cards) == 0:
|
||||||
send_async(bot, chat.id, text="%s won!" % user.first_name)
|
send_async(bot, chat.id,
|
||||||
|
text=_("{name} won!").format(name=user.first_name))
|
||||||
try:
|
try:
|
||||||
gm.leave_game(user, chat)
|
gm.leave_game(user, chat)
|
||||||
except NotEnoughPlayersError:
|
except NotEnoughPlayersError:
|
||||||
send_async(bot, chat.id, text="Game ended!")
|
send_async(bot, chat.id, text=_("Game ended!"))
|
||||||
gm.end_game(chat, user)
|
gm.end_game(chat, user)
|
||||||
|
|
||||||
if botan:
|
if botan:
|
||||||
|
@ -625,7 +642,7 @@ def do_draw(bot, player):
|
||||||
player.draw()
|
player.draw()
|
||||||
except DeckEmptyError:
|
except DeckEmptyError:
|
||||||
send_async(bot, player.game.chat.id,
|
send_async(bot, player.game.chat.id,
|
||||||
text="There are no more cards in the deck.")
|
text=_("There are no more cards in the deck."))
|
||||||
|
|
||||||
if (game.last_card.value == c.DRAW_TWO or
|
if (game.last_card.value == c.DRAW_TWO or
|
||||||
game.last_card.special == c.DRAW_FOUR) and \
|
game.last_card.special == c.DRAW_FOUR) and \
|
||||||
|
@ -639,27 +656,27 @@ def do_call_bluff(bot, player):
|
||||||
chat = game.chat
|
chat = game.chat
|
||||||
|
|
||||||
if player.prev.bluffing:
|
if player.prev.bluffing:
|
||||||
send_async(bot, chat.id, text="Bluff called! Giving %d cards to %s"
|
send_async(bot, chat.id,
|
||||||
% (game.draw_counter,
|
text=_("Bluff called! Giving 4 cards to {name}")
|
||||||
player.prev.user.first_name))
|
.format(name=player.prev.user.first_name))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
player.prev.draw()
|
player.prev.draw()
|
||||||
except DeckEmptyError:
|
except DeckEmptyError:
|
||||||
send_async(bot, player.game.chat.id,
|
send_async(bot, player.game.chat.id,
|
||||||
text="There are no more cards in the deck.")
|
text=_("There are no more cards in the deck."))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
game.draw_counter += 2
|
game.draw_counter += 2
|
||||||
send_async(bot, chat.id, text="%s didn't bluff! Giving %d cards to %s"
|
send_async(bot, chat.id,
|
||||||
% (player.prev.user.first_name,
|
text="{name1} didn't bluff! Giving 6 cards to {name2}"
|
||||||
game.draw_counter,
|
.format(name1=player.prev.user.first_name,
|
||||||
player.user.first_name))
|
name2=player.user.first_name))
|
||||||
try:
|
try:
|
||||||
player.draw()
|
player.draw()
|
||||||
except DeckEmptyError:
|
except DeckEmptyError:
|
||||||
send_async(bot, player.game.chat.id,
|
send_async(bot, player.game.chat.id,
|
||||||
text="There are no more cards in the deck.")
|
text=_("There are no more cards in the deck."))
|
||||||
|
|
||||||
game.turn()
|
game.turn()
|
||||||
|
|
||||||
|
|
14
database.py
14
database.py
|
@ -18,7 +18,21 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
from pony.orm import Database, db_session, Optional, Required, Set, PrimaryKey
|
from pony.orm import Database, db_session, Optional, Required, Set, PrimaryKey
|
||||||
|
|
||||||
|
from utils import _
|
||||||
|
|
||||||
# Database singleton
|
# Database singleton
|
||||||
db = Database()
|
db = Database()
|
||||||
|
|
||||||
|
|
||||||
|
def user_locale(func):
|
||||||
|
@wraps(func)
|
||||||
|
def wrapped(*pargs, **kwargs):
|
||||||
|
_.push('de_DE') # TODO: Get user locale from Database
|
||||||
|
result = func(*pargs, **kwargs)
|
||||||
|
_.pop()
|
||||||
|
return result
|
||||||
|
return wrapped
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
bot.py
|
|
||||||
results.py
|
|
352
locales/de_DE/LC_MESSAGES/unobot.po
Normal file
352
locales/de_DE/LC_MESSAGES/unobot.po
Normal file
|
@ -0,0 +1,352 @@
|
||||||
|
# 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: mau_mau_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"
|
||||||
|
"Other commands (only game creator):\n"
|
||||||
|
"/close - Close lobby\n"
|
||||||
|
"/open - Open lobby\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"
|
||||||
|
"Weitere Kommandos (nur Spiel-Ersteller):\n"
|
||||||
|
"/close - Lobby schließen\n"
|
||||||
|
"/open - Lobby öffnen\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
|
||||||
|
msgid ""
|
||||||
|
"First player: {name}\n"
|
||||||
|
"Use /close to stop people from joining the game."
|
||||||
|
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: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: "
|
||||||
|
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!"
|
|
@ -25,10 +25,10 @@ msgstr ""
|
||||||
"PO-Revision-Date: 2016-05-19 22:38+0200\n"
|
"PO-Revision-Date: 2016-05-19 22:38+0200\n"
|
||||||
"Last-Translator: Jannes Höke <uno@jhoeke.de>\n"
|
"Last-Translator: Jannes Höke <uno@jhoeke.de>\n"
|
||||||
"Language-Team: en <uno@jhoeke.de>\n"
|
"Language-Team: en <uno@jhoeke.de>\n"
|
||||||
"Language: en\n"
|
"Language: en_US\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=utf-8\n"
|
"Content-Type: text/plain; charset=utf-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: utf-8\n"
|
||||||
|
|
||||||
|
|
||||||
#: bot.py:60
|
#: bot.py:60
|
||||||
|
@ -57,7 +57,7 @@ msgid "Follow these steps:\n"
|
||||||
"a card in.\n"
|
"a card in.\n"
|
||||||
"If you enjoy this bot, <a href=\"https://telegram.me/storebot?"
|
"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/"
|
"start=mau_mau_bot\">rate me</a>, join the <a href=\"https://telegram.me/"
|
||||||
"unobotupdates\">update channel</a> and buy an UNO card game.\n"
|
"unobotupdates\">update channel</a> and buy an UNO card game."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:88
|
#: bot.py:88
|
||||||
|
@ -95,7 +95,7 @@ msgid "Game ended!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:201
|
#: bot.py:201
|
||||||
msgid "Okay. Next Player: "
|
msgid "Okay. Next Player: {name}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:219
|
#: bot.py:219
|
||||||
|
@ -196,20 +196,16 @@ msgstr ""
|
||||||
|
|
||||||
#: bot.py:513
|
#: bot.py:513
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Current game: %s"
|
msgid "Current game: {group}"
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: bot.py:533
|
|
||||||
msgid "Selected result: "
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:545
|
#: bot.py:545
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Cheat attempt by %s"
|
msgid "Cheat attempt by {name}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:562
|
#: bot.py:562
|
||||||
msgid "Next player: "
|
msgid "Next player: {name}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:572
|
#: bot.py:572
|
||||||
|
@ -217,39 +213,27 @@ msgstr ""
|
||||||
msgid "Waiting time for {name} has been reset to 90 seconds"
|
msgid "Waiting time for {name} has been reset to 90 seconds"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:577
|
|
||||||
msgid "Plays the selected card and sends an update to the group if needed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: bot.py:585
|
#: bot.py:585
|
||||||
msgid "Please choose a color"
|
msgid "Please choose a color"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:588
|
|
||||||
msgid "UNO!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: bot.py:591
|
#: bot.py:591
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "{name} won!"
|
msgid "{name} won!"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:601
|
|
||||||
msgid "Played cards"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: bot.py:613 bot.py:635 bot.py:647
|
#: bot.py:613 bot.py:635 bot.py:647
|
||||||
msgid "There are no more cards in the deck."
|
msgid "There are no more cards in the deck."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:627
|
#: bot.py:627
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Bluff called! Giving {number} cards to {name}"
|
msgid "Bluff called! Giving 4 cards to {name}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: bot.py:639
|
#: bot.py:639
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "{name1} didn't bluff! Giving {number} cards to {name2}"
|
msgid "{name1} didn't bluff! Giving 6 cards to {name2}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:38
|
#: results.py:38
|
||||||
|
@ -261,23 +245,20 @@ msgid "Cards (tap for game state):"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:60 results.py:123 results.py:165
|
#: results.py:60 results.py:123 results.py:165
|
||||||
msgid "Current player: "
|
msgid "Current player: {name}"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:61 results.py:124 results.py:167
|
#: results.py:61 results.py:124 results.py:167
|
||||||
msgid "\n"
|
msgid "Last card: {card}"
|
||||||
"Last card: "
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:62 results.py:125 results.py:168
|
#: results.py:62 results.py:125 results.py:168
|
||||||
msgid "\n"
|
msgid "Players: {player_list}"
|
||||||
"Players: "
|
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
|
||||||
#: results.py:72
|
#: results.py:72
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid " ({number} cards)"
|
msgid "{name} ({number} cards)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:81
|
#: results.py:81
|
||||||
|
@ -299,10 +280,11 @@ msgstr ""
|
||||||
|
|
||||||
#: results.py:108
|
#: results.py:108
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Drawing one card"
|
msgid "Drawing 1 card"
|
||||||
msgid_plural "Drawing {number} cards"
|
msgstr ""
|
||||||
msgstr[0] ""
|
|
||||||
msgstr[1] ""
|
msgid "Drawing {number} cards"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: results.py:136
|
#: results.py:136
|
||||||
msgid "Pass"
|
msgid "Pass"
|
69
results.py
69
results.py
|
@ -26,7 +26,7 @@ from telegram import InlineQueryResultArticle, InputTextMessageContent, \
|
||||||
InlineQueryResultCachedSticker as Sticker
|
InlineQueryResultCachedSticker as Sticker
|
||||||
|
|
||||||
import card as c
|
import card as c
|
||||||
from utils import *
|
from utils import display_color, display_name, list_subtract, _
|
||||||
|
|
||||||
|
|
||||||
def add_choose_color(results):
|
def add_choose_color(results):
|
||||||
|
@ -35,7 +35,7 @@ def add_choose_color(results):
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
id=color,
|
id=color,
|
||||||
title="Choose Color",
|
title=_("Choose Color"),
|
||||||
description=display_color(color),
|
description=display_color(color),
|
||||||
input_message_content=
|
input_message_content=
|
||||||
InputTextMessageContent(display_color(color))
|
InputTextMessageContent(display_color(color))
|
||||||
|
@ -48,40 +48,34 @@ def add_other_cards(playable, player, results, game):
|
||||||
if not playable:
|
if not playable:
|
||||||
playable = list()
|
playable = list()
|
||||||
|
|
||||||
players = player_list(game)
|
|
||||||
|
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
"hand",
|
"hand",
|
||||||
title="Cards (tap for game state):",
|
title=_("Cards (tap for game state):"),
|
||||||
description=', '.join([repr(card) for card in
|
description=', '.join([repr(card) for card in
|
||||||
list_subtract(player.cards, playable)]),
|
list_subtract(player.cards, playable)]),
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=game_info(game)
|
||||||
"Current player: " + display_name(game.current_player.user) +
|
|
||||||
"\n" +
|
|
||||||
"Last card: " + repr(game.last_card) + "\n" +
|
|
||||||
"Players: " + " -> ".join(players))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def player_list(game):
|
def player_list(game):
|
||||||
"""Generate list of player strings"""
|
"""Generate list of player strings"""
|
||||||
return [player.user.first_name + " (%d cards)" % len(player.cards)
|
return ["{name} ({number} cards)"
|
||||||
|
.format(name=player.user.first_name, number=len(player.cards))
|
||||||
for player in game.players]
|
for player in game.players]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def add_no_game(results):
|
def add_no_game(results):
|
||||||
"""Add text result if user is not playing"""
|
"""Add text result if user is not playing"""
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
"nogame",
|
"nogame",
|
||||||
title="You are not playing",
|
title=_("You are not playing"),
|
||||||
input_message_content=
|
input_message_content=
|
||||||
InputTextMessageContent('Not playing right now. Use /new to start '
|
InputTextMessageContent(_('Not playing right now. Use /new to '
|
||||||
'a game or /join to join the current game '
|
'start a game or /join to join the '
|
||||||
'in this group')
|
'current game in this group'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -91,38 +85,37 @@ def add_not_started(results):
|
||||||
results.append(
|
results.append(
|
||||||
InlineQueryResultArticle(
|
InlineQueryResultArticle(
|
||||||
"nogame",
|
"nogame",
|
||||||
title="The game wasn't started yet",
|
title=_("The game wasn't started yet"),
|
||||||
input_message_content=
|
input_message_content=
|
||||||
InputTextMessageContent('Start the game with /start')
|
InputTextMessageContent(_('Start the game with /start'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_draw(player, results):
|
def add_draw(player, results):
|
||||||
"""Add option to draw"""
|
"""Add option to draw"""
|
||||||
|
n = player.game.draw_counter or 1
|
||||||
|
|
||||||
results.append(
|
results.append(
|
||||||
Sticker(
|
Sticker(
|
||||||
"draw", sticker_file_id=c.STICKERS['option_draw'],
|
"draw", sticker_file_id=c.STICKERS['option_draw'],
|
||||||
input_message_content=
|
input_message_content=
|
||||||
InputTextMessageContent('Drawing %d card(s)'
|
InputTextMessageContent(_('Drawing 1 card')
|
||||||
% (player.game.draw_counter or 1))
|
if n == 1 else
|
||||||
|
_('Drawing {number} cards')
|
||||||
|
.format(number=n))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_gameinfo(game, results):
|
def add_gameinfo(game, results):
|
||||||
"""Add option to show game info"""
|
"""Add option to show game info"""
|
||||||
players = player_list(game)
|
|
||||||
|
|
||||||
results.append(
|
results.append(
|
||||||
Sticker(
|
Sticker(
|
||||||
"gameinfo",
|
"gameinfo",
|
||||||
sticker_file_id=c.STICKERS['option_info'],
|
sticker_file_id=c.STICKERS['option_info'],
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=game_info(game)
|
||||||
"Current player: " + display_name(game.current_player.user) +
|
|
||||||
"\n" +
|
|
||||||
"Last card: " + repr(game.last_card) + "\n" +
|
|
||||||
"Players: " + " -> ".join(players))
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -132,7 +125,7 @@ def add_pass(results):
|
||||||
results.append(
|
results.append(
|
||||||
Sticker(
|
Sticker(
|
||||||
"pass", sticker_file_id=c.STICKERS['option_pass'],
|
"pass", sticker_file_id=c.STICKERS['option_pass'],
|
||||||
input_message_content=InputTextMessageContent('Pass')
|
input_message_content=InputTextMessageContent(_('Pass'))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -144,14 +137,13 @@ def add_call_bluff(results):
|
||||||
"call_bluff",
|
"call_bluff",
|
||||||
sticker_file_id=c.STICKERS['option_bluff'],
|
sticker_file_id=c.STICKERS['option_bluff'],
|
||||||
input_message_content=
|
input_message_content=
|
||||||
InputTextMessageContent("I'm calling your bluff!")
|
InputTextMessageContent(_("I'm calling your bluff!"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_card(game, card, results, can_play):
|
def add_card(game, card, results, can_play):
|
||||||
"""Add an option that represents a card"""
|
"""Add an option that represents a card"""
|
||||||
players = player_list(game)
|
|
||||||
|
|
||||||
if can_play:
|
if can_play:
|
||||||
results.append(
|
results.append(
|
||||||
|
@ -160,11 +152,18 @@ def add_card(game, card, results, can_play):
|
||||||
else:
|
else:
|
||||||
results.append(
|
results.append(
|
||||||
Sticker(str(uuid4()), sticker_file_id=c.STICKERS_GREY[str(card)],
|
Sticker(str(uuid4()), sticker_file_id=c.STICKERS_GREY[str(card)],
|
||||||
input_message_content=InputTextMessageContent(
|
input_message_content=game_info(game))
|
||||||
"Current player: " + display_name(
|
|
||||||
game.current_player.user) +
|
|
||||||
"\n" +
|
|
||||||
"Last card: " + repr(game.last_card) + "\n" +
|
|
||||||
"Players: " + " -> ".join(players)))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def game_info(game):
|
||||||
|
players = player_list(game)
|
||||||
|
return InputTextMessageContent(
|
||||||
|
_("Current player: {name}")
|
||||||
|
.format(name=display_name(game.current_player.user)) +
|
||||||
|
"\n" +
|
||||||
|
_("Last card: {card}").format(card=repr(game.last_card)) +
|
||||||
|
"\n" +
|
||||||
|
_("Players: {player_list}")
|
||||||
|
.format(player_list=" -> ".join(players))
|
||||||
|
)
|
8
utils.py
8
utils.py
|
@ -18,7 +18,15 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
|
||||||
|
from flufl.i18n import registry
|
||||||
|
from flufl.i18n import PackageStrategy
|
||||||
|
|
||||||
from telegram import Emoji
|
from telegram import Emoji
|
||||||
|
import locales
|
||||||
|
|
||||||
|
strategy = PackageStrategy('unobot', locales)
|
||||||
|
application = registry.register(strategy)
|
||||||
|
_ = application._
|
||||||
|
|
||||||
|
|
||||||
def list_subtract(list1, list2):
|
def list_subtract(list1, list2):
|
||||||
|
|
Loading…
Reference in a new issue