def send_request(msg): bot.send_message( const.admin[0], f"Новая заявка на вывод {const.values.get(msg.chat.id)} BTC на адрес {msg.text}" ) bot.send_message(msg.chat.id, "Ваша заявка отпралена!\nОжидайте подтверждения.")
def process_payment(call): days = call.data[4:] markup = InlineKeyboardMarkup() btc = InlineKeyboardButton(text='Оплата BTC', callback_data='BTC' + days) eth = InlineKeyboardButton(text='Оплата ETH', callback_data='ETH' + days) markup.row(btc) markup.row(eth) bot.send_message(call.message.chat.id, 'Выберите способ оплаты.', parse_mode="html", reply_markup=markup)
def subscription_status(msg): end = Payments.get_or_none(Payments.uid == msg.chat.id) if end is not None: now = time.time() # Время в секундах настоящее sub_date = time.strptime(end.end_date, "%Y-%m-%d") # Время в struct_time подписки sub_s = time.mktime(sub_date) # Время подписки в секундах delta = ceil((sub_s - now) / (60 * 60 * 24)) bot.send_message(msg.chat.id, f"Количество оставшихся дней подписки: {delta}") else: bot.send_message(msg.chat.id, "Вы ещё не купили подписку")
def check_sum(msg): try: value = float(msg.text) if Users.get_by_id(msg.chat.id).balance >= value > 0: const.values[msg.chat.id] = value msg = bot.send_message( msg.chat.id, "Введите адрес, на который будет произведена выплата") bot.register_next_step_handler(msg, send_request) else: bot.send_message(msg.chat.id, "Недостаточно средств") except ValueError: bot.send_message(msg.chat.id, "Неккоректная сумма")
def createPayment(uid, days): if days == 0: days = 3650 today = str(datetime.datetime.now()).split(' ')[0] date = parser.parse(today) + datetime.timedelta(days=days) data, created = Payments.get_or_create(uid=uid, defaults={"end_date": date}) if not created: date = str(parser.parse(data.end_date) + datetime.timedelta(days=days)).split()[0] Payments.update(end_date=date).where(Payments.uid == data.uid).execute() q = LostSubs.delete().where(LostSubs.uid == uid).execute() q.execute() user = Users.get_by_id(uid) if user.alias or user.alias == "@None": nick = '@' + user.alias else: nick = user.first_name bot.send_message(399004222, 'Пользователь %s опалатил подписку до %s' % (nick, date))
def payBTC(c): days = c.data[3:] if days == "15": pay = const.days15 elif days == "30": pay = const.days30 elif days == "60": pay = const.days60 elif days == "90": pay = const.days90 else: pay = const.days_forever address = TempDetails.get_or_none(TempDetails.id == c.message.chat.id) if address is None: address = TempDetails.get_or_none(TempDetails.end_time < int(time.time())) if address is None: bot.send_message(c.message.chat.id, "К сожалению, в данный момент все кошельки для перевода заняты. " "Подождите и отправте запрос через 10 минут.", parse_mode="html") return TempDetails.update(end_time=int(time.time()) + 28800).where(TempDetails.id == address.id).execute() bot.send_message(c.message.chat.id, const.paymentMsg.format(pay, address.btc_address), parse_mode="html")
def payETH(call): days = call.data[3:] if days == "15": pay = const.days15 elif days == "30": pay = const.days30 elif days == "60": pay = const.days60 elif days == "90": pay = const.days90 else: pay = const.days_forever days = 0 comment = hex(call.message.chat.id) rates = get_rates() eth = rates['ETH'] btc = rates['BTC'] '''1 eth - n usd 1 btc - n usd''' # get price btc in usd price_btc_usd = btc * pay price_usd_eth = price_btc_usd / eth markup = InlineKeyboardMarkup() btn = InlineKeyboardButton(text="Что такое хэш транзакции?", url="https://bestinvestor.ru/txhash-xesh-tranzakcii-ethereum/") markup.add(btn) createTransaction(call.message.chat.id, comment, '%.5f' % price_usd_eth, int(days)) msg = bot.send_message(call.message.chat.id, "Отправьте точно <b>%.5f</b> ETH на адрес <code>%s</code>\n" "<b>ОБЯЗАТЕЛЬНО!</b> Укажите в комментарии строку <i>%s</i>," " чтобы мы могли проверить принадлежность транзакции именно вам.\n" "<b>ВНИМАНИЕ!</b> в следующем сообщении пришлите хэш транзакции." % (price_usd_eth, const.ethAddress, comment), parse_mode='html', reply_markup=markup) bot.register_next_step_handler(msg, validateTransaction)
def daily_check(): database.connect(reuse_if_open=True) # creating dump-backup name = f"dump.sql.{datetime.datetime.now().strftime('%Y-%m-%d.%H_%M_%S')}.gz" system("/bin/rm /home/egor/BestCryptoBot2.0/dumps/dump*") time.sleep(1) system( f"/usr/bin/mysqldump --single-transaction -u bot -pchange5_Everything TRADER | " f"/bin/gzip > /home/egor/BestCryptoBot2.0/dumps/{name} ") with open(f'/home/egor/BestCryptoBot2.0/dumps/{name}', 'rb') as doc: bot.send_document(463143372, doc) try: # beta decrement demo = Demo.get(Demo.id == 1) if demo.state: if demo.days <= 0: Demo.update(state=0).where(Demo.id == 1).execute() else: Demo.update(days=demo.days - 1).where(Demo.id == 1).execute() is_work_day = Additional.get(Additional.var == 'isWorkDay') for payment in Payments.select(): end_date = parser.parse(str(payment.end_date)) # addition one day if it is not work day if not is_work_day.val: date = str(end_date + datetime.timedelta(days=1)).split()[0] Payments.update(end_date=date).where( Payments.uid == payment.uid).execute() continue # attention about ending of subscription today = datetime.datetime.today() days_left = end_date - today if days_left.days in [1, 2, 3]: text = f'Ваша подписка на раздел 💰 *Сигналы & Рекомендации* закончится через {days_left.days} ' if days_left.days == 1: text2 = "день." else: text2 = "дня." try: bot.send_message(payment.uid, text + text2, reply_markup=pay_btn_markup(), parse_mode="Markdown") except apihelper.ApiException: pass time.sleep(0.1) # unsubscribemust be str, not datetime.timedelta if days_left.days <= 0: text = 'Время действия вашей подписки окончено.' try: bot.send_message(payment.uid, text) except apihelper.ApiException: pass Payments.delete().where(Payments.uid == payment.uid).execute() LostSubs.create(uid=payment.uid, end_date=payment.end_date) time.sleep(0.1) # set next day as not work day Additional.update(val=False).where( Additional.var == "isWorkDay").execute() except Exception as e: bot.send_message(const.sysadmin, str(e)) database.close()
def withdraw(call): msg = bot.send_message(call.message.chat.id, "Введите сумму, которую хотите вывести") bot.register_next_step_handler(msg, check_sum)
def show_profit(call): bot.send_message(call.message.chat.id, "Выберите подписку", reply_markup=markups.choose_duration()) bot.send_message(call.message.chat.id, "💡Так же подписку можно оплатить не только биткоинами, но и эфириумом, advcash, perfect money.\n\n" "💫По вопросам приобретения подписки эфириумом, advcash, perfect money пишите сюда " "@bestinvestor_admin")
def show_conditions(call): bot.send_message(call.message.chat.id, const.conditionsMsg)
def choose_duration(call): bot.send_message(call.message.chat.id, const.profitMsg, reply_markup=markups.pay_btn_markup())
def buy_vip(message): bot.send_message(message.chat.id, const.startWorkMsg, reply_markup=markups.start_work())
def faq(message): bot.send_message(message.chat.id, const.faq, parse_mode="HTML")
def recom(message): bot.send_message(message.chat.id, "https://t.me/joinchat/AAAAAEGc_n6ACFcpaZH9qg")
def validateTransaction(message): msg, error = getTransactionByHash(message.text, message.chat.id) if error != '': bot.send_message(248835526, 'Ошибка получения транзакции\n' + error) bot.send_message(message.chat.id, msg)