Ejemplo n.º 1
0
def adding_general(bot, update, user_data):
    """
    Добавление Генерала
    """
    mes = update.message
    try:
        player_id = int(mes.text)
    except ValueError:
        bot.send_message(chat_id=update.message.from_user.id,
                         text="Неверный синтаксис.")
        return
    if player_id in high_access_list:
        bot.send_message(chat_id=update.message.from_user.id,
                         text="Этот человек уже являетсяс генералом.")
        return
    player = Player.get_player(player_id, notify_on_error=False)
    if player is None:
        bot.send_message(chat_id=update.message.from_user.id,
                         text="Невозможно найти этого холопа. "
                         "Убедитесь, что он зарегистрирован в боте")
        return
    throne = Location.get_location(2)
    mid_players = throne.special_info.get("mid_players")
    mid_players.append(player_id)
    throne.update_location_to_database()
    fill_mid_players()
    bot.send_message(chat_id=update.message.from_user.id,
                     text="@{} теперь генерал!".format(player.username))
    user_data.update({"status": "king_cabinet"})
Ejemplo n.º 2
0
def remove_general(bot, update):
    """
    Функция удаления Генерала
    """
    mes = update.message
    player_id = re.search("_(\\d+)", mes.text)
    if player_id is None:
        bot.send_message(chat_id=update.message.from_user.id,
                         text="Неверный синтаксис.")
        return
    player_id = int(player_id.group(1))
    if player_id not in high_access_list:
        bot.send_message(chat_id=update.message.from_user.id,
                         text="Так он, это, вроде и не генерал вовсе. "
                         "Может, помилуем?")
        return
    player = Player.get_player(player_id, notify_on_error=False)
    throne = Location.get_location(2)
    mid_players = throne.special_info.get("mid_players")
    mid_players.remove(player_id)
    throne.update_location_to_database()
    fill_mid_players()
    bot.send_message(chat_id=update.message.from_user.id,
                     text="@{} сослан в тортугу и больше не генерал".format(
                         player.username))
Ejemplo n.º 3
0
def castle_update_monitor():
    cursor = conn.cursor()
    data = update_request_queue.get()
    while data is not None:
        if data[0] == "update_guild":
            recashe_order_chats(
                new_cursor=cursor
            )  # Неоптимально, но это не должно вызываться часто.
            # upd: TODO: говнище, всё переделать. Могут не уйти приказы из-за этого
        elif data[0] == "update_mid":
            fill_mid_players(other_process=True)

        data = update_request_queue.get()
 def filter(self, message):
     fill_mid_players(other_process=True)
     return check_access(message.from_user.id)