コード例 #1
0
ファイル: user_func.py プロジェクト: KostyaJRZ/telegram_bot
def showUserStat(bot, username, message):
    if not fileio.isUserExist(username):
        warn_message = bot.reply_to(message, "Пользователя еще нет в базе")
        time.sleep(3)
        bot.delete_message(message.chat.id, warn_message.message_id)
        return

    UI = "📈 Статистика пользователя @" + username + "👨\n\n"
    if isUserAdmin(username):
        UI += "👑 Это администратор: да" + "\n"
    else:
        UI += "👑 Это администратор: нет" + "\n"
    UI += "📝 Сообщений написано: " + database.getDBValue(
        username, "stats", "message_count") + "\n"
    UI += "🎰 Игры сыграно в рулетку: " + str(
        database.getDBValue(username, "stats",
                            "slot_gamed_count")) + " раз(а)\n"
    UI += "🍓 Использовано 18+ команд: " + str(
        database.getDBValue(username, "stats",
                            "sex_command_count")) + " раз(а)\n"
    time.sleep(0.1)
    UI += "💶 Баланс: " + database.getDBValue(username, "eco", "money") + "\n"
    UI += "🤑 Кредит: " + database.getDBValue(username, "eco", "credit") + "\n"
    UI += "% Процент по кредиту: " + database.getDBValue(
        username, "eco", "credit_percent") + "\n"
    time.sleep(0.1)
    UI += "📈💰 Заработано на питомцах: " + database.getDBValue(
        username, "stats", "money_pet_produced") + "💶\n"
    UI += "📉💰Потрачено на рулетку: " + database.getDBValue(
        username, "stats", "money_lost_in_slot") + "💶\n"
    UI += "📉💰Потрачено на питомцев: " + database.getDBValue(
        username, "stats", "money_lost_in_pet") + "💶\n"
    bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
コード例 #2
0
ファイル: bot.py プロジェクト: KostyaJRZ/telegram_bot
def answer(message):
    if user_func.isOwner(message.from_user.username.replace("@", "")):
        target = message.text.split(maxsplit=4)[1].replace("@", "")
        obj = message.text.split(maxsplit=4)[2]
        key = message.text.split(maxsplit=4)[3]
        value = message.text.split(maxsplit=4)[4]
        if fileio.isUserExist(target):
            database.setDBValue(target, obj, key, value)
            bf.ReplyTo(bot,
                       message,
                       "Значение " + key + " у " + target + " теперь - " +
                       value,
                       stack=False,
                       timeout=3)
        else:
            bf.ReplyTo(bot,
                       message,
                       "Данного пользователя нет в базе данных",
                       stack=False,
                       timeout=3)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Доступно только создателю",
                   stack=False,
                   timeout=3)
コード例 #3
0
ファイル: bot.py プロジェクト: KostyaJRZ/telegram_bot
def userListener(messages):
    for message in messages:
        username = message.from_user.username
        if username is not None:
            username = username.replace("@", "")
            try:
                if not fileio.isLogExist(username):
                    with open(fileio.logs_database_folder + username + ".txt",
                              "w+",
                              encoding='utf8') as logfile:
                        TO_LOG = str(message.chat.first_name) + " [" + str(
                            message.chat.id) + "]: " + message.text
                        logfile.write(TO_LOG + "\n")
                else:
                    with open(fileio.logs_database_folder + username + ".txt",
                              "a",
                              encoding='utf8') as logfile:
                        TO_LOG = str(message.chat.first_name) + " [" + str(
                            message.chat.id) + "]: " + message.text
                        logfile.write(TO_LOG + "\n")
                if not fileio.isUserExist(username):
                    user_obj = fileio.blank_user_obj
                    user_obj["id"] = message.from_user.id
                    user_obj["username"] = username
                    user_obj["name"] = message.from_user.first_name
                    fileio.insertUserObj(user_obj)
            except:
                pass
コード例 #4
0
ファイル: bot.py プロジェクト: KostyaJRZ/telegram_bot
def banListener(messages):
    for message in messages:
        username = message.from_user.username
        if username is not None:
            username = username.replace("@", "")
            if fileio.isUserExist(username):
                if database.getDBValue(username, "user", "banned") == "1":
                    banned_func.processUser(username, bot, message)
                    pass
コード例 #5
0
ファイル: bot.py プロジェクト: KostyaJRZ/telegram_bot
def messageCounter(messages):
    for message in messages:
        username = message.from_user.username
        if username is not None:
            username = username.replace("@", "")
            if fileio.isUserExist(username):
                if database.getDBValue(username, "user", "banned") != "1":
                    try:
                        target_message_count = int(
                            database.getDBValue(username, "stats",
                                                "message_count"))
                        target_message_count += 1
                        database.setDBValue(username, "stats", "message_count",
                                            str(target_message_count))
                    except:
                        pass
コード例 #6
0
ファイル: user_func.py プロジェクト: KostyaJRZ/telegram_bot
def buyPet(bot, message):
    username = message.from_user.username.replace("@", "")
    if fileio.isUserExist(username):
        user_money = int(database.getDBValue(username, "eco", "money"))
        pet_cost = config.global_economic["pet_cost"]
        if user_money < pet_cost:
            UI = "У вас не достаточно денег для покупки!\n"
            UI += "Цена нового питомца составляет: " + str(pet_cost) + "💵\n"
            UI += "💰Ваш баланс: " + str(user_money) + "\n"
            bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
            return
        try:
            target_pet_id = message.text.split()[1]
            target_pet_name = message.text.split()[2]
            pet_count = len(database.getListPetsByUserName(username))
            if pet_count == 0:
                pet_count = 1
            user_money = user_money - (pet_cost * pet_count)
            database.setDBValue(username, "user", "money", str(user_money))
            database.addPet(username, target_pet_name, target_pet_id)
            time.sleep(1)
            UI = "Вы успешно купили нового питомца 👍\n"
            UI += "💵 Списано со счета " + str((pet_cost * pet_count)) + " \n\n"
            UI += "💵 Цена = количество * стандартная цена (3000💵 ) \n"
            UI += "💰 Баланс " + str(database.getDBValue(username,
                                                        "money")) + " \n"
            UI += "Состояние \n\n"
            UI += "Владелец: @" + str(username) + "\n"
            UI += "▫️Аватар питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_avatar")) + "\n"
            UI += "▫️Имя питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_name")) + "\n"
            UI += "🍗 Еда питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_food")) + "\n"
            UI += "💧 Вода питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_water")) + "\n"
            UI += "🍗🍗🍗 Избыток еды: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_food_auto")) + "\n"
            UI += "💧💧💧 Избыток воды: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_water_auto")) + "\n"
            UI += "🏠 У питомца есть дом: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_have_house")) + "\n"
            UI += "🏠📊 Уровень дома питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_house_level")) + "\n"
            UI += "💵 Пассивный доход с питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_passive_produce")) + "\n"
            UI += "⏱💵 Тайм-аут дохода в минутах: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_passive_produce_timeout_m")) + "\n"
            UI += "📊 Уровень питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_level")) + "\n"
            UI += "🌟 Опыт питомца: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_exp")) + "\n"
            UI += "💎 Найдено сокровищ питомцем: " + str(
                database.getPetValue(username, target_pet_id,
                                     "pet_unique_treasure")) + "\n"
            bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
        except:
            bf.ReplyTo(
                bot,
                message,
                "Команда введена не правильно. /buy_pet [ид питомца] [имя питомца]\n ID используется для обращения к конкретному питомцу",
                stack=False,
                timeout=3)