Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def pari():
- get_price = requests.get(ENDPOINT + "/api/v3/ticker/price?symbol=BTCUSDT")
- if get_price.status_code == 200:
- settings.price = float(json.loads(get_price.text)['price'])
- settings.global_pari_status = True
- settings.save()
- for user in BotUser.objects.filter(notifications=True):
- translation.activate(user.language)
- button = Buttons.objects.filter(translations__language_code=user.language).first()
- message = Messages.objects.filter(translations__language_code=user.language).first()
- text = str(message.start_pari).replace("{price}", str(settings.price))\
- .replace("{time}", (datetime.today() + timedelta(hours=5)).strftime("%d/%m/%y %H:%M"))
- print(text)
- keyboard = telebot.types.InlineKeyboardMarkup()
- keyboard.add(telebot.types.InlineKeyboardButton(
- text=_(button.lower_price), callback_data="price_lower"),
- telebot.types.InlineKeyboardButton(
- text=_(button.up_price), callback_data="price_up")
- )
- try:
- BOT.send_message(user.chat_id, text, reply_markup=keyboard, parse_mode="Markdown")
- except Exception as err:
- print(err)
- continue
- # time.sleep(10 * 60)
- time.sleep(1 * 60)
- settings.global_pari_status = False
- settings.save()
- # time.sleep(120 * 60)
- time.sleep(3 * 60)
- get_price = requests.get(ENDPOINT + "/api/v3/ticker/price?symbol=BTCUSDT")
- if get_price.status_code == 200:
- settings.new_price = float(json.loads(get_price.text)['price'])
- pari_result = True if settings.new_price > settings.price else False
- all_money = 0
- loser_filter = True if pari_result else False
- for p in Pari.objects.filter(user__rate=loser_filter):
- all_money += p.rate_summa
- # minus procents
- all_money -= (all_money / 100) * settings.procents
- print(all_money)
- for p in Pari.objects.filter(user__rate=pari_result):
- # procents = p.rate_summa / all_money * 100
- win_summa = 100 / (all_money / p.rate_summa)
- print('WIN - ', str(win_summa))
- p.user.balance += win_summa
- p.user.save()
- p.win = True
- p.profit_or_lose = win_summa
- p.save()
- for user in BotUser.objects.filter(notifications=True):
- try:
- translation.activate(user.language)
- message = Messages.objects.filter(translations__language_code=user.language).first()
- prices = [price.profit_or_lose for price in Pari.objects.filter(user__rate=pari_result)]
- text = _(message.end_pari).replace("{price}", str(settings.new_price)) \
- .replace("{biggest_price}", str(max(prices)))
- BOT.send_message(user.chat_id, text)
- except Exception as err:
- print(err)
- continue
- for p in Pari.objects.all():
- HistoryPari.objects.create(
- user = p.user,
- win = p.win,
- rate = p.profit_or_lose,
- date = settings.date_pari
- )
- p.delete()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement