Exemple #1
0
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)
Exemple #2
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    current_user_money = int(database.getDBValue(username, "eco", "money"))
    bank_cost = config.global_economic["bank_cost"]
    if current_user_money < bank_cost:
        bf.ReplyTo(bot,
                   message,
                   "Не хватает денег, заказать банк стоит " + str(bank_cost),
                   stack=False,
                   timeout=3)
        return
    new_bank = bank_func.blank_bank_obj
    database.setDBValue(username, "eco", "money",
                        str(current_user_money - bank_cost))
    bank_func.createBankEntry(username, new_bank)
    UI = "🏦Новый банк создан!\n"
    UI += "\t\tНазвание банка: *" + new_bank["bankname"] + "*\n"
    UI += "📝Описание банка: *" + new_bank["description"] + "*\n"
    UI += "💵Процент по кредиту банка: *" + new_bank["credit_percent"] + "%*\n"
    UI += "💵Процент по дебету банка: *" + new_bank["debit_percent"] + "%*\n"
    UI += "⏱Время сбора процентов: *" + new_bank["time_to_pay"] + "м*\n"
    msg = bot.reply_to(message, UI, parse_mode="Markdown")
    bf.ReplyTo(bot, message, UI, stack=False, timeout=20, use_markdown=True)
Exemple #3
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    req = Request("https://www.worldometers.info/coronavirus",
                  headers={'User-Agent': 'Mozilla/5.0'})
    resource = urllib.request.urlopen(req)
    content = resource.read().decode(resource.headers.get_content_charset())
    corona_cases_count = re.search(
        r'Coronavirus Cases:[a-zA-Z<>\": 0-9\/\n=\-#]*>([0-9, ]*)<',
        content).group(1)
    corona_death_count = re.search(
        r'Deaths:[a-zA-Z<>\": 0-9\/\n=\-#]*>([0-9, ]*)<', content).group(1)
    corona_survive_count = re.search(
        r'Recovered:[a-zA-Z<>\": 0-9\/\n=\-#]*>([0-9, ]*)<', content).group(1)
    result = "Ситуация в 🌎 мире на данный момент\n"
    result += "🦠 Заражено: " + corona_cases_count + "\n"
    result += "☠ Умерло: " + corona_death_count + "\n"
    result += "+ Выздоровело: " + corona_survive_count + "\n"
    result += "-----------\n"
    result += "НАМ ВСЕМ ПИЗДА!\n"
    bf.ReplyTo(bot, message, result, stack=False, timeout=20)
Exemple #4
0
def setPetAvatar(bot, message):
    username = message.from_user.username.replace("@", "")
    try:
        target_pet_id = message.text.split()[1]
        target_value = message.text.split()[2]
        if len(database.getListPetsByUserName(username)) != 0:
            if database.isPetExist(username, target_pet_id) is not None:
                user_money = int(database.getDBValue(username, "eco", "money"))
                change_name_cost = config.global_economic[
                    "pet_change_avatar_cost"]
                UI = ""
                if user_money < change_name_cost:
                    UI = "У вас не достаточно денег для смены аватара!\n"
                    UI += "Цена смены составляет: " + str(
                        change_name_cost) + "💵\n"
                    UI += "💰 Ваш баланс: " + str(user_money) + "\n"
                    bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
                    return
                lost_current = int(
                    database.getDBValue(username, "stats",
                                        "money_lost_in_pet"))
                lost = lost_current + (
                    config.global_economic["pet_change_avatar_cost"])
                database.setDBValue(username, "stats", "money_lost_in_pet",
                                    str(lost))
                user_money = user_money - change_name_cost
                database.setDBValue(username, "eco", "money", str(user_money))
                database.setPetValueByPos(username, target_pet_id,
                                          "pet_avatar", target_value)

                UI += "Изменено:\n"
                UI += "▫ Аватар питомца: " + str(
                    database.getPetValue(username, target_pet_id,
                                         "pet_avatar")) + "\n"
                bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
            else:
                bf.ReplyTo(
                    bot,
                    message,
                    "Такого питомца не существует, посмотреть список питомцев /mypets",
                    stack=False,
                    timeout=3)
        else:
            bf.ReplyTo(
                bot,
                message,
                "У вас нет ни одного питомца, купить /buy_pet [ид питомца] [имя питомца]",
                stack=False,
                timeout=3)
    except:
        bf.ReplyTo(bot,
                   message,
                   "Команда введена не правильно. /pet_setavatar [ид] [смайл]",
                   stack=False,
                   timeout=3)
Exemple #5
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    bf.ReplyTo(
        bot,
        message,
        "Исодный код - [GitHub](https://github.com/LinerSRT/telegram_bot)",
        use_markdown=True)
Exemple #6
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    UI = "Список банков:\n"
    for bank in bank_func.getBankList():
        UI += "\n🏦" + bank[0] + " | Кредит под " + bank[
            1] + "% | Дебет под " + bank[2] + "% | Владелец @" + bank[3] + "\n"
    bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
Exemple #7
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    values = database.getListUsersWhereValue("stats", "message_count", None)
    out = 0
    for item in values:
        out += int(item[1])
    UI = "Всего сообщений получено ботом: " + str(out) + "🧾"
    bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
Exemple #8
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    bf.ReplyTo(bot,
               message,
               "💰 Ваш баланс - " +
               str(database.getDBValue(username, "eco", "money")),
               stack=False,
               timeout=20)
Exemple #9
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    values = database.getListUsersWhereValue("stats", "money_lost_in_slot",
                                             None)
    out = 0
    for item in values:
        out += int(item[1])
    UI = "Рулетка заработала на пользователях: " + str(out) + "💶"
    bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
Exemple #10
0
def processUser(username, bot, message):
    bot.delete_message(message.chat.id, message.message_id)
    bf.ReplyTo(bot,
               message,
               "@" + username + ", " + random.choice(banned_text),
               stack=False,
               timeout=5)
Exemple #11
0
def getUserPets(bot, message):
    username = message.from_user.username.replace("@", "")
    UI = "Ваши питомцы: \n\n"
    if len(database.getListPetsByUserName(username)) == 0:
        bf.ReplyTo(
            bot,
            message,
            "У вас нет питомцев, купить /buy_pet [ид питомца] [имя питомца]",
            stack=False,
            timeout=3)
        return
    for pet in database.getListPetsByUserName(username):
        UI += "ID[" + pet[0] + "] " + str(
            database.getPetValue(username, str(pet[0]),
                                 "pet_avatar")) + " " + str(pet[1]) + "\n"
    bf.ReplyTo(bot, message, UI, stack=False, timeout=10)
Exemple #12
0
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)
Exemple #13
0
def delAdmin(bot, message):
    username = message.from_user.username.replace("@", "")
    target = message.text.split(maxsplit=1)[1].replace("@", "")
    if isOwner(username):
        database.setDBValue(target, "user", "admin", "1")
        bf.ReplyTo(bot,
                   message,
                   "Теперь *" + target + "* больше не администратор",
                   stack=False,
                   timeout=3,
                   use_markdown=True)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Доступно только администраторам",
                   stack=False,
                   timeout=3)
Exemple #14
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    if user_func.isUserAdmin(message.from_user.username):
        try:
            req = Request("http://www.gifporntube.com/gifs/" +
                          str(random.randint(20, 2000)) + ".html",
                          headers={'User-Agent': 'Mozilla/5.0'})
            resource = urllib.request.urlopen(req)
            content = resource.read().decode(
                resource.headers.get_content_charset())
            urls = re.findall(
                'https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+([/a-z_0-9]*.mp4)',
                content)
            markdown = "[ᅠ](http://www.gifporntube.com" + str(urls[0]) + ")"
            usage_count = int(
                database.getDBValue(message.from_user.username, "stats",
                                    "sex_command_count"))
            usage_count += 1
            database.setDBValue(message.from_user.username, "stats",
                                "sex_command_count", str(usage_count))
            bot.delete_message(message.chat.id, message.message_id)
            bf.ReplyTo(bot,
                       message,
                       markdown,
                       stack=False,
                       timeout=6,
                       use_markdown=True)
        except:
            bf.ReplyTo(bot,
                       message,
                       "Временно не доступно",
                       stack=False,
                       timeout=3)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Достпуно только для админов, соси бибу",
                   stack=False,
                   timeout=3)
Exemple #15
0
def unBanUser(bot, message):
    username = message.from_user.username.replace("@", "")
    target = message.text.split(maxsplit=1)[1].replace("@", "")
    if isUserAdmin(username):
        database.setDBValue(target, "user", "banned", "0")
        bf.ReplyTo(bot,
                   message,
                   "Теперь @*" + target + "* не будет сосет бибу",
                   stack=False,
                   timeout=3,
                   use_markdown=True)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Доступно только администраторам",
                   stack=False,
                   timeout=3,
                   use_markdown=True)
Exemple #16
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    if bank_func.isBankExist(username):
        UI = "\t\tНазвание банка: " + bank_func.getBankValue(
            username, "bankname") + "\n"
        UI += "📝Описание банка: " + bank_func.getBankValue(
            username, "description") + "\n"
        UI += "💵Процент по кредиту банка: " + bank_func.getBankValue(
            username, "credit_percent") + "%\n"
        UI += "💵Процент по дебету банка: " + bank_func.getBankValue(
            username, "debit_percent") + "%\n"
        UI += "⏱Время сбора процентов: " + bank_func.getBankValue(
            username, "time_to_pay") + "м\n"
        UI += "💵Баланс банка: " + bank_func.getBankValue(username,
                                                         "money") + "💵\n"
        UI += "👥Количество пользователей: " + str(
            len(bank_func.getBankUsers(username))) + "\n"
        if int(len(bank_func.getBankUsers(username))) > 0:
            for user in bank_func.getBankUsers(username):
                UI += "\t\t\t\t👤 @" + str(user[0])
                if user[1] == "credit":
                    UI += " | Кредитный | Сумма " + str(user[2]) + "💵"
                else:
                    UI += " | Дебетовый | Баланс " + str(user[2]) + "💵"
                UI += "\n"
        bf.ReplyTo(bot,
                   message,
                   UI,
                   stack=False,
                   timeout=20,
                   use_markdown=True)
    else:
        bf.ReplyTo(bot,
                   message,
                   "У вас нет банка, купить /newbank",
                   stack=False,
                   timeout=3)
Exemple #17
0
def send_photo(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    if user_func.isUserAdmin(message.from_user.username):
        try:
            usage_count = int(
                database.getDBValue(message.from_user.username, "stats",
                                    "sex_command_count"))
            usage_count += 1
            database.setDBValue(message.from_user.username, "stats",
                                "sex_command_count", str(usage_count))
            markdown = "[ᅠ](https://www.scrolller.com/media/" + str(
                random.randint(20, 2000)) + ".jpg)"
            usage_count = int(
                database.getDBValue(message.from_user.username, "stats",
                                    "sex_command_count"))
            usage_count += 1
            database.setDBValue(message.from_user.username, "stats",
                                "sex_command_count", str(usage_count))
            bot.delete_message(message.chat.id, message.message_id)
            bf.ReplyTo(bot,
                       message,
                       markdown,
                       stack=False,
                       timeout=6,
                       use_markdown=True)
        except:
            bf.ReplyTo(bot,
                       message,
                       "Временно не доступно",
                       stack=False,
                       timeout=3)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Достпуно только для админов, соси бибу",
                   stack=False,
                   timeout=3)
Exemple #18
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    command = message.text.split()
    if len(command) < 2:
        bf.ReplyTo(
            bot,
            message,
            "Команда введена не правильно. /bank [владелец]. Список банков /banks",
            stack=False,
            timeout=5)
        return
    owner = command[1].replace("@", "")
    if bank_func.isBankExist(owner):
        UI = "\t\tНазвание банка: *" + bank_func.getBankValue(
            owner, "bankname") + "*\n"
        UI += "📝Описание банка: *" + bank_func.getBankValue(
            owner, "description") + "*\n"
        UI += "💵Процент по кредиту банка: *" + bank_func.getBankValue(
            owner, "credit_percent") + "%*\n"
        UI += "💵Процент по дебету банка: *" + bank_func.getBankValue(
            owner, "debit_percent") + "%*\n"
        UI += "⏱Время сбора процентов: *" + bank_func.getBankValue(
            owner, "time_to_pay") + "м*\n"
        bf.ReplyTo(bot,
                   message,
                   UI,
                   stack=False,
                   timeout=20,
                   use_markdown=True)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Пользователь не владеет банком!",
                   stack=False,
                   timeout=3)
Exemple #19
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    global GAME_AVAILABLE
    if len(message.text.split()) < 2:
        bf.SlotGame(bot, message, game_available=GAME_AVAILABLE)
        GAME_AVAILABLE = False
        return
    bet = int(message.text.split()[1])
    bf.SlotGame(bot, message, game_available=GAME_AVAILABLE, game_bet=bet)
    GAME_AVAILABLE = False
Exemple #20
0
def command_help(message):
    if not user_func.userCanUseCommand(
            message.from_user.username.replace("@", "")):
        warn_message = bot.reply_to(message, "Соси бибу, ты забанен")
        time.sleep(3)
        bot.delete_message(message.chat.id, warn_message.message_id)
        return
    help_text = "\n"
    for key in config.commands:
        help_text += key + "   :  "
        help_text += config.commands[key] + "\n"
    help_text += "\n\n▫ - доступно всем \n🔸 - доступно только админам\n🔺 - доступно только создателю"
    help_text += "\n\n ❗️❗️❗️❗️❗️АХТУНГ! ВАРНИНГ! Если вы взяли кредит в банке и не можете его оплатить вовремя, вы попадете в БАН БОТА. Подумайте перед тем как брать кредит!!!"
    bf.ReplyTo(
        bot, message, "Привет, @" + str(message.from_user.username) +
        " рад снова тебя видеть. Вот что я могу:\n" + help_text)
Exemple #21
0
def answer(message):
    if uptime["sec"] < 10:
        sec = "0" + str(uptime["sec"])
    else:
        sec = str(uptime["sec"])
    if uptime["min"] < 10:
        min = "0" + str(uptime["min"])
    else:
        min = str(uptime["min"])
    if uptime["hour"] < 10:
        hour = "0" + str(uptime["hour"])
    else:
        hour = str(uptime["hour"])
    result = hour + ":" + min + ":" + sec
    bf.ReplyTo(bot,
               message,
               "Ебашу на благо общества уже:  ⏱ *" + result + "*",
               stack=False,
               timeout=10,
               use_markdown=True)
Exemple #22
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    if bank_func.isBankExist(username):
        command = message.text.split()
        if len(command) < 3:
            UI = "Список ключей\n"
            UI += "name - Имя банка\n"
            UI += "desc - Описание банка\n"
            UI += "credit_p - Кредитный процент банка\n"
            UI += "debit_p - Дебетовый процент банка\n"
            UI += "\n\nКоманда /setbank [ключ] [значение]"
            bf.ReplyTo(bot, message, UI, stack=False, timeout=5)
            return
        key = command[1]
        value = command[2]
        if key == "name":
            bank_func.setBankValue(username, "bankname", value)
            pass
        elif key == "desc":
            bank_func.setBankValue(username, "description", value)
            pass
        elif key == "credit_p":
            bank_func.setBankValue(username, "credit_percent", value)
            pass
        elif key == "debit_p":
            bank_func.setBankValue(username, "debit_percent", value)
            pass
        else:
            UI = "Список ключей\n\n"
            UI += "name - Имя банка\n"
            UI += "desc - Описание банка\n"
            UI += "credit_p - Кредитный процент банка\n"
            UI += "debit_p - Дебетовый процент банка\n"
            UI += "\n\nКоманда /setbank [ключ] [значение]"
            bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
            return
        UI = "🏦Ваш банк изменен!\n"
        UI += "\t\tНазвание банка: *" + bank_func.getBankValue(
            username, "bankname") + "*\n"
        UI += "📝Описание банка: *" + bank_func.getBankValue(
            username, "description") + "*\n"
        UI += "💵Процент по кредиту банка: *" + bank_func.getBankValue(
            username, "credit_percent") + "%*\n"
        UI += "💵Процент по дебету банка: *" + bank_func.getBankValue(
            username, "debit_percent") + "%*\n"
        bf.ReplyTo(bot,
                   message,
                   UI,
                   stack=False,
                   timeout=20,
                   use_markdown=True)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Вы не владете банком",
                   stack=False,
                   timeout=3)
Exemple #23
0
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)
Exemple #24
0
def getPetStat(bot, message):
    username = message.from_user.username.replace("@", "")
    try:
        target_pet_id = message.text.split()[1]
        if len(database.getListPetsByUserName(username)) != 0:
            if database.isPetExist(username, target_pet_id) is not None:
                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)
            else:
                bf.ReplyTo(
                    bot,
                    message,
                    "Такого питомца не существует, посмотреть список питомцев /mypets",
                    stack=False,
                    timeout=3)
        else:
            bf.ReplyTo(
                bot,
                message,
                "У вас нет ни одного питомца, купить /buy_pet [ид питомца] [имя питомца]",
                stack=False,
                timeout=3)
    except:
        bf.ReplyTo(bot,
                   message,
                   "Команда введена не правильно. /pet [ид]",
                   stack=False,
                   timeout=3)
Exemple #25
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    command = message.text.split()
    if len(command) < 1:
        bf.ReplyTo(
            bot,
            message,
            "Команда введена не правильно. /paytobank [владелец] [сумма]. Список банков /banks",
            stack=False,
            timeout=5)
        return
    usermoney = int(database.getDBValue(username, "eco", "money"))
    owner = command[1].replace("@", "")
    amount = int(command[2])
    if amount > usermoney:
        bf.ReplyTo(bot,
                   message,
                   "У вас не хватает денег. Ваш баланс: " + str(usermoney) +
                   "💵",
                   stack=False,
                   timeout=5)
        return
    if bank_func.isBankExist(owner):
        bank_money = int(bank_func.getBankValue(owner, "money"))
        if username == owner:
            bank_money = bank_money + amount
            UI = "Вы внесли в свой банк 🏦" + bank_func.getBankValue(
                owner, "bankname") + " деньги на сумму: " + str(amount) + "💵\n"
            UI += "Баланс вашего банка: " + str(bank_money) + "💵"
            bank_func.setBankValue(owner, "money", str(bank_money))
            database.setDBValue(username, "eco", "money",
                                str(usermoney - amount))
            bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
            return
        if int(len(bank_func.getBankUsers(owner))) > 0:
            for user in bank_func.getBankUsers(owner):
                if username == user[0]:
                    if user[1] == "credit":
                        credit_money = int(user[2])
                        credit_percent = int(
                            bank_func.getBankValue(owner, "credit_percent"))
                        credit_money = credit_money - (amount - round(
                            bank_func.getValueByPercent(
                                credit_percent, amount)))
                        bank_money = bank_money + amount + round(
                            bank_func.getValueByPercent(
                                credit_percent, amount))
                        usermoney = usermoney - (amount - round(
                            bank_func.getValueByPercent(
                                credit_percent, amount)))
                        bank_func.setBankValue(owner, "money", str(bank_money))
                        if credit_money < 0:
                            credit_money = 0
                        bank_func.setBankUserValue(owner, username,
                                                   credit_money)
                        database.setDBValue(username, "eco", "money",
                                            str(usermoney))
                        UI = "Вы заплатили в банк 🏦 @" + owner + "\n"
                        UI += "Платеж: " + str(
                            amount) + "💵 плюс кредит банка " + str(
                                credit_percent) + "% итого списано - " + str(
                                    amount - round(
                                        bank_func.getValueByPercent(
                                            credit_percent, amount))) + "💵\n"
                        UI += "Спасибо что пользуетесь услугами банка: 🏦" + bank_func.getBankValue(
                            owner, "bankname")
                        bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
                        return
                    else:
                        debet_money = int(user[2])
                        debet_money = debet_money + amount
                        bank_money = bank_money + amount
                        usermoney = usermoney - amount
                        bank_func.setBankValue(owner, "money", str(bank_money))
                        bank_func.setBankUserValue(owner, username,
                                                   debet_money)
                        database.setDBValue(username, "eco", "money",
                                            str(usermoney))
                        UI = "Вы внесли в банк 🏦 @" + owner + "\n"
                        UI += "Платеж: " + str(amount) + "💵\n"
                        UI += "Спасибо что пользуетесь услугами банка: 🏦" + bank_func.getBankValue(
                            owner, "bankname")
                        bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
                        return

        UI = "Вы не являетесь пользователем банка 🏦 " + bank_func.getBankValue(
            owner, "bankname") + " и не можете платить банку"
        bf.ReplyTo(bot, message, UI, stack=False, timeout=5)
    else:
        bf.ReplyTo(bot,
                   message,
                   "Пользователь не владеет банком!",
                   stack=False,
                   timeout=3)
Exemple #26
0
def answer(message):
    if not user_func.userCanUseCommand(message.from_user.username):
        bf.ReplyTo(bot,
                   message,
                   "Соси бибу, ты забанен",
                   stack=False,
                   timeout=3)
        return
    username = message.from_user.username.replace("@", "")
    command = message.text.split()
    if len(command) < 2:
        bf.ReplyTo(
            bot,
            message,
            "Команда введена не правильно. /getcredit [владелец] [сумма]. Список банков /banks",
            stack=False,
            timeout=5)
        return
    usermoney = int(database.getDBValue(username, "eco", "money"))
    owner = command[1].replace("@", "")
    amount = int(command[2])
    if bank_func.isBankExist(owner):
        bank_money = int(bank_func.getBankValue(owner, "money"))
        if amount > bank_money:
            bf.ReplyTo(
                bot,
                message,
                "Банк не может выдать вам кредит, у банка нет нужной суммы!",
                stack=False,
                timeout=5)
            return
        if username == owner:
            bf.ReplyTo(bot,
                       message,
                       "Вы не можете взять кредит у своего банка",
                       stack=False,
                       timeout=5)
            return
        if int(len(bank_func.getBankUsers(owner))) > 0:
            for user in bank_func.getBankUsers(owner):
                if username == user[0]:
                    if user[1] == "credit":
                        credit_money = int(user[2])
                        credit_percent = int(
                            bank_func.getBankValue(owner, "credit_percent"))
                        credit_money = credit_money + (amount + round(
                            bank_func.getValueByPercent(
                                credit_percent, amount)))
                        bank_money = bank_money - amount
                        usermoney = usermoney + (amount - round(
                            bank_func.getValueByPercent(
                                credit_percent, amount)))
                        bank_func.setBankValue(owner, "money", str(bank_money))
                        bank_func.setBankUserValue(owner, username,
                                                   credit_money)
                        database.setDBValue(username, "eco", "money",
                                            str(usermoney))
                        UI = "Вы успешно взяли кредит в банке 🏦 @" + owner + "\n"
                        UI += "Затребовано: " + str(
                            amount) + "💵\nКредит банка " + str(
                                credit_percent
                            ) + "% \nИтого получено - " + str(amount - round(
                                bank_func.getValueByPercent(
                                    credit_percent, amount))) + "💵\n"
                        UI += "Спасибо что пользуетесь услугами банка: 🏦" + bank_func.getBankValue(
                            owner, "bankname") + "\n\n"
                        UI += "Ваш баланс: " + str(usermoney) + "💵\n"
                        bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
                        return

        credit_percent = int(bank_func.getBankValue(owner, "credit_percent"))
        credit_money = amount + round(
            bank_func.getValueByPercent(credit_percent, amount))
        bank_money = bank_money - amount
        usermoney = usermoney + (amount - round(
            bank_func.getValueByPercent(credit_percent, amount)))
        new_bank_user = bank_func.blank_user_obj
        new_bank_user["name"] = username
        new_bank_user["money"] = str(credit_money)
        bank_func.setBankValue(owner, "money", str(bank_money))
        bank_func.setBankUserValue(owner, username, credit_money)
        database.setDBValue(username, "eco", "money", str(usermoney))
        bank_func.addNewUserToBank(owner, new_bank_user)
        UI = "Вы успешно взяли кредит в банке 🏦 @" + owner + " и стали его участником\n"
        UI += "Затребовано: " + str(amount) + "💵\nКредит банка " + str(
            credit_percent) + "% \nИтого получено - " + str(amount - round(
                bank_func.getValueByPercent(credit_percent, amount))) + "💵\n"
        UI += "Спасибо что пользуетесь услугами банка: 🏦" + bank_func.getBankValue(
            owner, "bankname") + "\n\n"
        UI += "Ваш баланс: " + str(usermoney) + "💵\n"
        bf.ReplyTo(bot, message, UI, stack=False, timeout=20)
    else:
        bf.ReplyTo(
            bot,
            message,
            "Такого банка не существует. /getcredit [владелец] [сумма]. Список банков /banks",
            stack=False,
            timeout=3)