Beispiel #1
0
def join_bot_player(bot, update):

    chat = update.message.chat
    user = User(bot.id, bot.first_name, 0)
    try:
        gm.join_game(user, chat)
        send_async(bot,
                   chat.id,
                   text='Medicilândia uno bot entrou na partida.',
                   reply_to_message_id=update.message.message_id)
    except LobbyClosedError:
        send_async(bot, chat.id, text=_("The lobby is closed"))

    except NoGameInChatError:
        send_async(bot,
                   chat.id,
                   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=_("Bot 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=_("There are not enough cards left in the deck for "
                          "new players to join."),
                   reply_to_message_id=update.message.message_id)
Beispiel #2
0
def join_game(bot, update):
    """Handler for the /join command"""
    choice = [[
        InlineKeyboardButton(text=_("Choose the mode!"),
                             switch_inline_query_current_chat='')
    ]]
    user = update.message.from_user
    chat = update.message.chat
    games = gm.chatid_games.get(chat.id)
    game = games[-1]

    if update.message.chat.type == 'private':
        help_handler(bot, update)
        return

    try:
        gm.join_game(update.message.from_user, chat)

    except LobbyClosedError:
        send_async(bot, chat.id, text=_("The lobby is closed"))

    except NoGameInChatError:
        send_async(bot,
                   chat.id,
                   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=_("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=_("There are not enough cards left in the deck for "
                          "new players to join."),
                   reply_to_message_id=update.message.message_id)

    else:
        if user.id in game.owner:
            send_async(bot,
                       chat.id,
                       text=_("Joined the game"),
                       reply_markup=InlineKeyboardMarkup(choice),
                       reply_to_message_id=update.message.message_id)
        if user.id not in game.owner:
            send_async(bot,
                       chat.id,
                       text=_("Joined the game"),
                       reply_to_message_id=update.message.message_id)
Beispiel #3
0
def join_game(bot, update):

    #Start DB
    us = UserSetting.get(id=update.message.from_user.id)

    if not us:
        us = UserSetting(id=update.message.from_user.id)


#Start DB
    """Handler for the /join command"""
    chat = update.message.chat

    if update.message.chat.type == 'private':
        help_handler(bot, update)
        return

    try:
        gm.join_game(update.message.from_user, chat)

    except LobbyClosedError:
        send_async(bot, chat.id, text=_("The lobby is closed"))

    except NoGameInChatError:
        send_async(bot,
                   chat.id,
                   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=_("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=_("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=_("Joined the game"),
                   reply_to_message_id=update.message.message_id)
Beispiel #4
0
def join_game(bot, update):
    """Handler for the /join command"""
    chat = update.message.chat

    if update.message.chat.type == 'private':
        help_handler(bot, update)
        return

    try:
        gm.join_game(update.message.from_user, chat)

    except LobbyClosedError:
        send_async(bot,
                   chat.id,
                   text="Abe bhag bihari",
                   reply_to_message_id=update.message.message_id)

    except NoGameInChatError:
        send_async(bot,
                   chat.id,
                   text=_("kardi jatin bihari pruthi wali baat "
                          "Naya game bana /new"),
                   reply_to_message_id=update.message.message_id)

    except AlreadyJoinedError:
        send_async(bot,
                   chat.id,
                   text=_("kardi bihari wali baat, start kar aise /start"),
                   reply_to_message_id=update.message.message_id)

    except DeckEmptyError:
        send_async(bot,
                   chat.id,
                   text=_("There are not enough cards left in the deck for "
                          "new players to join."),
                   reply_to_message_id=update.message.message_id)

    else:
        send_async(bot,
                   chat.id,
                   text=_("Has entered bihar"),
                   reply_to_message_id=update.message.message_id)
Beispiel #5
0
def join_game(bot, update):
    """Handler for the /join command"""
    chat = update.message.chat

    if update.message.chat.type == 'private':
        help(bot, update)
        return

    try:
        gm.join_game(update.message.from_user, chat)

    except LobbyClosedError:
            send_async(bot, chat.id, text=_("The lobby is closed"))

    except NoGameInChatError:
        send_async(bot, chat.id,
                   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=_("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=_("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=_("Joined the game"),
                   reply_to_message_id=update.message.message_id)