После недельного отдыха решил слить свой старый СМС Активатор который стоял на некомерческой аренде И так, поехали Установка Как установить пайтон: https://zelenka.guru/threads/5855219/ Установка модулей: pip3 install telebot, pip3 install requests Подготовка API SMS Заходим на сайт: https://onlinesim.io/ Создаем там аккаунт к примеру через телеграм и сразу идем в ваш профиль: После этого нажимаем API: И копируем API: (токен сменил,даже не пытайтесь ) Все, токен сохраняем в после вводим его в нашем коде! Crypto Pay Заходим в бота: https://t.me/CryptoBot В меню нажимаем Crypto pay Далее нажимаем "Создать приложение" И так же переходим в API-Токен и копируем его Токен тоже копируем и сохраняем BotFather: В посте выше описано как создать (короче лень объяснять элеметнарное) ()()() Токен тоже сохраняем и идем в файлы Код sms.py import telebot import sqlite3 from telebot import types import time import json import requests import os import pay_crypto chat_log = '' #id чата ***** api_pay = '' #api sms onlinesim.io bot = telebot.TeleBot("", parse_mode="HTML") #Токен бота class MeDb: def __init__(self, id): self.id = id def getMeDB(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() select_me = cursor.execute("SELECT * FROM users WHERE id = ?",(id,)).fetchall() return select_me def getMeBalance(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() balance_me = cursor.execute("SELECT balance FROM users WHERE id = ?",(id,)).fetchone()[0] return balance_me def getMeOrders(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() orders_me = cursor.execute("SELECT orders FROM users WHERE id = ?",(id,)).fetchone()[0] return orders_me def UpdateBalance(self,id,balance): db = sqlite3.connect('base.db') cursor = db.cursor() updateBalances = cursor.execute("UPDATE users SET balance = ? WHERE id = ?",(balance,id,)) db.commit() return updateBalances def updateorders(self,id,endOrder): db = sqlite3.connect('base.db') cursor = db.cursor() updateOrder = cursor.execute("UPDATE users SET orders = ? WHERE id = ?",(endOrder,id,)) db.commit() return updateOrder @bot.message_handler(commands=['start']) def start(message): db = sqlite3.connect('base.db') cursor = db.cursor() cursor.execute("""CREATE TABLE IF NOT EXISTS fact( id INTEGER, fact INTEGER )""") db.commit() cursor.execute("""CREATE TABLE IF NOT EXISTS users( id INTEGER, balance INTEGER, orders INTEGER )""") db.commit() id = message.from_user.id id_select = cursor.execute("SELECT id FROM users WHERE id = ?", (id, )).fetchone() if id_select is None: cursor.execute(f'INSERT OR IGNORE INTO users VALUES ({id}, {0},{0});') db.commit() check = cursor.execute("SELECT id FROM fact WHERE id = ?", (id, )).fetchone() print(check) if check is None: cursor.execute(f'INSERT OR IGNORE INTO fact VALUES ({id}, 0);') db.commit() fact = cursor.execute("SELECT fact FROM fact WHERE id = ?", (id, )).fetchone()[0] if fact == 0: markup = types.InlineKeyboardMarkup(row_width=1) cb_yes = types.InlineKeyboardButton(" Согласиться с правилами", callback_data="cb-yes") cb_no = types.InlineKeyboardButton("❓ Не соглашаюсь с правилами", callback_data="cb-no") markup.add(cb_yes,cb_no) bot.send_message(message.chat.id, text=f"Привет, {message.chat.first_name}\nСогласитесь с правилами бота для продолжения!",reply_markup=markup) if fact == 1: markup_block = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) menu = types.KeyboardButton("Главное меню") markup_block.add(menu) markup_menu = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Пополнение", callback_data="Deposit") menu_2 = types.InlineKeyboardButton("❓ ПОМОЩЬ", callback_data="Help") menu_3 = types.InlineKeyboardButton(" Купить номер", callback_data="Buy-number") markup_menu.add(menu_1 ,menu_3 ,menu_2) get_db = MeDb(message.chat.id) my_info = get_db.getMeDB(message.chat.id) for main in my_info: cash = main[1] order = main[2] bot.send_sticker(message.chat.id,'CAACAgEAAxkBAAEIq6pkQorrnsjMja-GSBha7cn8UIc1PgACiQMAAojcyEeb7pyszvxvJS8E',reply_markup=markup_block) bot.send_message(message.chat.id,"<b>Твой кабинет</b>\n"+ f"\n<b>Баланс: </b>"+'%.2f' % cash + '$' + f"\n<b>Успешных покупок: {order} шт.</b>" , reply_markup=markup_menu) # Меню @bot.callback_query_handler(func=lambda call: True) def call_back(call): req = call.data.split('_') if call.message: if call.data == 'cb-yes': db = sqlite3.connect('base.db' , check_same_thread=False) cursor = db.cursor() cursor.execute("UPDATE fact SET fact = ? WHERE id = ?", (1, call.from_user.id)) db.commit() markup_menu = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton("Личный кабинет", callback_data="main-menu") markup_menu.add(menu_1) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Отлично,переходи в личный кабинет!</b>",reply_markup=markup_menu) if call.data == 'cb-no': bot.send_message(call.message.chat.id, "<b>‼Когда захочешь вернуться, напиши /start</b>") if call.data == 'Deposit': markup_deposit = types.InlineKeyboardMarkup(row_width=1) menu_3 = types.InlineKeyboardButton("Crypto-bot", callback_data="Crypto-bot") backbutton = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_deposit.add(menu_3, backbutton) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Способ попелнения</b>",reply_markup=markup_deposit) if call.data == 'Crypto-bot': msg_pay = bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>✍Введите сумму которую хотите внести</b>\n\n"+"<b>⚠Обрати внимание:</b>\n"+"\n<i>Оплата принимается только в USDT</i>\n\n'<i>Для отмены операции напишите: </i><code>Отмена</code>'") bot.register_next_step_handler(msg_pay, pay_crypto.create_payorder) if call.data == 'Help': markup_help = types.InlineKeyboardMarkup(row_width=2) url_button = types.InlineKeyboardButton("Менежер", url="https://t.me/its_uroboros") backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_help.add(url_button, backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>В случае если вы столкнулись с какими либо проблемами, пишите нам!</b>",reply_markup=markup_help) if call.data == 'main-menu': get_db = MeDb(call.message.chat.id) my_info = get_db.getMeDB(call.message.chat.id) for main in my_info: cash = main[1] order = main[2] markup_menu2 = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Пополнение", callback_data="Deposit") menu_2 = types.InlineKeyboardButton("❓ ПОМОЩЬ", callback_data="Help") menu_3 = types.InlineKeyboardButton(" Купить номер", callback_data="Buy-number") markup_menu2.add(menu_1, menu_3 ,menu_2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Твой кабинет</b>\n"+ f"\n<b>Баланс: </b>"+'%.2f' % cash + '$' + f"\n<b>Успешных покупок: {order} шт.</b>",reply_markup=markup_menu2) if call.data == '****': markup_block = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) menu = types.KeyboardButton("Отмена") markup_block.add(menu) msg = bot.send_message(call.message.chat.id,'<b>✍Введите сумму депозита</b>\n\n<i>❕Напишите</i> <code>Отмена</code> <i>чтобы отменить транзакцию</i>',reply_markup=markup_block) bot.register_next_step_handler(msg, Qiwi_nomer) if call.data == 'Buy-number': markup_number = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Франция", callback_data="countr_33") menu_2 = types.InlineKeyboardButton(" Испания", callback_data="countr_34") menu_3 = types.InlineKeyboardButton(" Германия", callback_data="countr_49") menu_4 = types.InlineKeyboardButton(" Чехия", callback_data="countr_420") menu_5 = types.InlineKeyboardButton(" Кипр", callback_data="countr_357") menu_6 = types.InlineKeyboardButton(" Британия", callback_data="countr_44") menu_7 = types.InlineKeyboardButton(" Дания", callback_data="countr_45") menu_8 = types.InlineKeyboardButton(" Италия", callback_data="countr_39") menu_9 = types.InlineKeyboardButton(" Португалия", callback_data="countr_351") menu_10 = types.InlineKeyboardButton(" Россия", callback_data="countr_7") backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_number.add(menu_1,menu_2,menu_3,menu_4,menu_5,menu_6,menu_7,menu_8,menu_9,menu_10,backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>☔Выбери страну для которой хотите купить номер</b>", reply_markup=markup_number) if req[0] == "countr": country_id = req[1] name_country = '' if country_id == "33": name_country = ' Франция' if country_id == "34": name_country = ' Испания' if country_id == "49": name_country = ' Германия' if country_id == "420": name_country = ' Чехия' if country_id == "357": name_country = ' Кипр' if country_id == "44": name_country = ' Британия' if country_id == "39": name_country = ' Италия' if country_id == "351": name_country = ' Португалия' if country_id == "7": name_country = ' Россия' with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) services = data[country_id] # Получаем значения для каждого сервиса buttons = [] for service, price in services.items(): button_text = f"{service}: {price}$" button = telebot.types.InlineKeyboardButton(text=''+button_text, callback_data=f"service_{service}_{country_id}") buttons.append(button) keyboard = telebot.types.InlineKeyboardMarkup(row_width=2) keyboard.add(*buttons) # отправляем пользователю эту клавиатуру backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') keyboard.add(backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text=f"<b>Выбор сервиса\nСтрана: {name_country}</b>",reply_markup=keyboard) if req[0] == "service": service = req[1] country_id = req[2] #pay_list with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) check = data[country_id][service] get_balance = MeDb(call.from_user.id) me_balance = get_balance.getMeBalance(call.from_user.id) if float(me_balance) < float(check): Deposit = types.InlineKeyboardMarkup(row_width=2) button = types.InlineKeyboardButton(" Пополнить", callback_data="Deposit") Deposit.add(button) bot.send_message(call.from_user.id, '‼<b>На твоем балансе недостаточно средств чтобы купить номер для этого сервиса!</b>\n\n❕<i>Пополни баланс чтобы воспользоваться сервисом</i>',reply_markup=Deposit) else: #инициализация класса для обнвления баланса balance_up = float(me_balance) - float(check) init__Update = MeDb(call.from_user.id) updateDB = init__Update.UpdateBalance(call.from_user.id,balance_up) url = "https://onlinesim.io/api/getNum.php" params = { "apikey": f"{api_pay}", "service": service, 'country':country_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) idtz_idtrans = str(j['tzid']) + '-' + str(call.from_user.id) #id заказа и транзы output = j['response'] tz_id = str(j['tzid']) if output == 'NO_NUMBER': bot.send_message(call.from_user.id,'<b>♂На данный момент номера для данного сервиса нет</b>') if output == 1: url = "https://onlinesim.io/api/getState.php" params = {"apikey": f"{api_pay}", "tzid":tz_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) with open(f'ordersNum/{idtz_idtrans}.json', 'w+') as src: src.write(json.dumps(j, indent=2)) with open(f'ordersNum/{idtz_idtrans}.json', 'r', encoding='utf-8') as sr: check = sr.read() number = json.loads(check) get_numbers = number[0]["number"] name_country = '' if country_id == "33": name_country = ' Франция' if country_id == "34": name_country = ' Испания' if country_id == "49": name_country = ' Германия' if country_id == "420": name_country = ' Чехия' if country_id == "357": name_country = ' Кипр' if country_id == "44": name_country = ' Британия' if country_id == "39": name_country = ' Италия' if country_id == "351": name_country = ' Португалия' if country_id == "7": name_country = ' Россия' bot.send_message(call.from_user.id, f"<b> Страна: {name_country}</b>\n\n"+ f'<b>Сервис: {service}</b>\n' f"<b>Номер телефона: </b> <code>{get_numbers}</code>\n\n"+ '⚠<b>После отправки смс код в бота поступит автоматически</b>') getcode(idtz_idtrans, tz_id,service) idtz_idtrans = 0 tz_id = 0 service = 0 def getcode(idtz_idtrans, tz_id,service): print('new thread code') if idtz_idtrans != 0 and tz_id != 0 and service != 0: me_id = idtz_idtrans.split('-')[1] i = 0 while i == 0: time.sleep(10) url = "https://onlinesim.io/api/getState.php" params = {"apikey": f"{api_pay}", "tzid":tz_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) with open(f'ordersNum/{idtz_idtrans}.json', 'w+') as src: src.write(json.dumps(j, indent=2)) with open(f'ordersNum/{idtz_idtrans}.json', 'r', encoding='utf-8') as sr: check = sr.read() code = json.loads(check) country_id = code[0]['country'] if code[0]['response'] == 'TZ_NUM_WAIT': if code[0]['time'] < 700: print(code[0]['time']) #price_list with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) check = data[country_id][service] get_balance = MeDb(me_id) me_balance = get_balance.getMeBalance(me_id) balance_up = float(me_balance) + float(check) init__Update = MeDb(me_id) updateDB = init__Update.UpdateBalance(me_id,balance_up) url_ok = "https://onlinesim.io/api/setOperationOk.php" params_ok = {"apikey": f"{api_pay}", "tzid":tz_id, } headers_ok = {"accept": "application/json"} responce_ok = requests.get(url_ok, params=params_ok, headers=headers_ok) bot.send_message(idtz_idtrans.split('-')[1],'<b>‼Номер автматически отменен системой!\n♻Средства вернулись на баланс</b>') i += 1 os.remove('ordersNum/'+idtz_idtrans+'.json') elif code[0]['time'] > 700: continue if code[0]['response'] == 'TZ_NUM_ANSWER': i += 1 sms = code[0]['msg'] bot.send_message(idtz_idtrans.split('-')[1], f'<b>Новый код</b>\n\nСМС-КОД: <code>{sms}</code>\n\nУдачи') getOrders = MeDb(me_id) orders = getOrders.getMeOrders(me_id) endOrder = orders + 1 getOrders.updateorders(me_id,endOrder) os.remove('ordersNum/'+idtz_idtrans+'.json') bot.send_message(chat_log,f'<b>Новая покупка</b>\n\nСервис: {service}\nСумма платежа: {amount}$') def Qiwi_nomer(message): msg = message.text if msg == 'Отмена': start(message) else: print(type(msg)) bot.send_message(message.chat.id, f'Вы пополняете {msg} гребней') @bot.message_handler(content_types=['text']) def abort_deposit(message): if message.text == 'Отмена': bot.send_message(message.chat.id, '<b>Вы отменили заявку на пополнение!</b>') if message.text == 'Главное меню': start(message) Python import telebot import sqlite3 from telebot import types import time import json import requests import os import pay_crypto chat_log = '' #id чата ***** api_pay = '' #api sms onlinesim.io bot = telebot.TeleBot("", parse_mode="HTML") #Токен бота class MeDb: def __init__(self, id): self.id = id def getMeDB(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() select_me = cursor.execute("SELECT * FROM users WHERE id = ?",(id,)).fetchall() return select_me def getMeBalance(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() balance_me = cursor.execute("SELECT balance FROM users WHERE id = ?",(id,)).fetchone()[0] return balance_me def getMeOrders(self,id): db = sqlite3.connect('base.db') cursor = db.cursor() orders_me = cursor.execute("SELECT orders FROM users WHERE id = ?",(id,)).fetchone()[0] return orders_me def UpdateBalance(self,id,balance): db = sqlite3.connect('base.db') cursor = db.cursor() updateBalances = cursor.execute("UPDATE users SET balance = ? WHERE id = ?",(balance,id,)) db.commit() return updateBalances def updateorders(self,id,endOrder): db = sqlite3.connect('base.db') cursor = db.cursor() updateOrder = cursor.execute("UPDATE users SET orders = ? WHERE id = ?",(endOrder,id,)) db.commit() return updateOrder @bot.message_handler(commands=['start']) def start(message): db = sqlite3.connect('base.db') cursor = db.cursor() cursor.execute("""CREATE TABLE IF NOT EXISTS fact( id INTEGER, fact INTEGER )""") db.commit() cursor.execute("""CREATE TABLE IF NOT EXISTS users( id INTEGER, balance INTEGER, orders INTEGER )""") db.commit() id = message.from_user.id id_select = cursor.execute("SELECT id FROM users WHERE id = ?", (id, )).fetchone() if id_select is None: cursor.execute(f'INSERT OR IGNORE INTO users VALUES ({id}, {0},{0});') db.commit() check = cursor.execute("SELECT id FROM fact WHERE id = ?", (id, )).fetchone() print(check) if check is None: cursor.execute(f'INSERT OR IGNORE INTO fact VALUES ({id}, 0);') db.commit() fact = cursor.execute("SELECT fact FROM fact WHERE id = ?", (id, )).fetchone()[0] if fact == 0: markup = types.InlineKeyboardMarkup(row_width=1) cb_yes = types.InlineKeyboardButton(" Согласиться с правилами", callback_data="cb-yes") cb_no = types.InlineKeyboardButton("❓ Не соглашаюсь с правилами", callback_data="cb-no") markup.add(cb_yes,cb_no) bot.send_message(message.chat.id, text=f"Привет, {message.chat.first_name}\nСогласитесь с правилами бота для продолжения!",reply_markup=markup) if fact == 1: markup_block = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) menu = types.KeyboardButton("Главное меню") markup_block.add(menu) markup_menu = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Пополнение", callback_data="Deposit") menu_2 = types.InlineKeyboardButton("❓ ПОМОЩЬ", callback_data="Help") menu_3 = types.InlineKeyboardButton(" Купить номер", callback_data="Buy-number") markup_menu.add(menu_1 ,menu_3 ,menu_2) get_db = MeDb(message.chat.id) my_info = get_db.getMeDB(message.chat.id) for main in my_info: cash = main[1] order = main[2] bot.send_sticker(message.chat.id,'CAACAgEAAxkBAAEIq6pkQorrnsjMja-GSBha7cn8UIc1PgACiQMAAojcyEeb7pyszvxvJS8E',reply_markup=markup_block) bot.send_message(message.chat.id,"<b>Твой кабинет</b>\n"+ f"\n<b>Баланс: </b>"+'%.2f' % cash + '$' + f"\n<b>Успешных покупок: {order} шт.</b>" , reply_markup=markup_menu) # Меню @bot.callback_query_handler(func=lambda call: True) def call_back(call): req = call.data.split('_') if call.message: if call.data == 'cb-yes': db = sqlite3.connect('base.db' , check_same_thread=False) cursor = db.cursor() cursor.execute("UPDATE fact SET fact = ? WHERE id = ?", (1, call.from_user.id)) db.commit() markup_menu = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton("Личный кабинет", callback_data="main-menu") markup_menu.add(menu_1) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Отлично,переходи в личный кабинет!</b>",reply_markup=markup_menu) if call.data == 'cb-no': bot.send_message(call.message.chat.id, "<b>‼Когда захочешь вернуться, напиши /start</b>") if call.data == 'Deposit': markup_deposit = types.InlineKeyboardMarkup(row_width=1) menu_3 = types.InlineKeyboardButton("Crypto-bot", callback_data="Crypto-bot") backbutton = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_deposit.add(menu_3, backbutton) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Способ попелнения</b>",reply_markup=markup_deposit) if call.data == 'Crypto-bot': msg_pay = bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>✍Введите сумму которую хотите внести</b>\n\n"+"<b>⚠Обрати внимание:</b>\n"+"\n<i>Оплата принимается только в USDT</i>\n\n'<i>Для отмены операции напишите: </i><code>Отмена</code>'") bot.register_next_step_handler(msg_pay, pay_crypto.create_payorder) if call.data == 'Help': markup_help = types.InlineKeyboardMarkup(row_width=2) url_button = types.InlineKeyboardButton("Менежер", url="https://t.me/its_uroboros") backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_help.add(url_button, backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>В случае если вы столкнулись с какими либо проблемами, пишите нам!</b>",reply_markup=markup_help) if call.data == 'main-menu': get_db = MeDb(call.message.chat.id) my_info = get_db.getMeDB(call.message.chat.id) for main in my_info: cash = main[1] order = main[2] markup_menu2 = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Пополнение", callback_data="Deposit") menu_2 = types.InlineKeyboardButton("❓ ПОМОЩЬ", callback_data="Help") menu_3 = types.InlineKeyboardButton(" Купить номер", callback_data="Buy-number") markup_menu2.add(menu_1, menu_3 ,menu_2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>Твой кабинет</b>\n"+ f"\n<b>Баланс: </b>"+'%.2f' % cash + '$' + f"\n<b>Успешных покупок: {order} шт.</b>",reply_markup=markup_menu2) if call.data == '****': markup_block = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True) menu = types.KeyboardButton("Отмена") markup_block.add(menu) msg = bot.send_message(call.message.chat.id,'<b>✍Введите сумму депозита</b>\n\n<i>❕Напишите</i> <code>Отмена</code> <i>чтобы отменить транзакцию</i>',reply_markup=markup_block) bot.register_next_step_handler(msg, Qiwi_nomer) if call.data == 'Buy-number': markup_number = types.InlineKeyboardMarkup(row_width=2) menu_1 = types.InlineKeyboardButton(" Франция", callback_data="countr_33") menu_2 = types.InlineKeyboardButton(" Испания", callback_data="countr_34") menu_3 = types.InlineKeyboardButton(" Германия", callback_data="countr_49") menu_4 = types.InlineKeyboardButton(" Чехия", callback_data="countr_420") menu_5 = types.InlineKeyboardButton(" Кипр", callback_data="countr_357") menu_6 = types.InlineKeyboardButton(" Британия", callback_data="countr_44") menu_7 = types.InlineKeyboardButton(" Дания", callback_data="countr_45") menu_8 = types.InlineKeyboardButton(" Италия", callback_data="countr_39") menu_9 = types.InlineKeyboardButton(" Португалия", callback_data="countr_351") menu_10 = types.InlineKeyboardButton(" Россия", callback_data="countr_7") backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') markup_number.add(menu_1,menu_2,menu_3,menu_4,menu_5,menu_6,menu_7,menu_8,menu_9,menu_10,backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text="<b>☔Выбери страну для которой хотите купить номер</b>", reply_markup=markup_number) if req[0] == "countr": country_id = req[1] name_country = '' if country_id == "33": name_country = ' Франция' if country_id == "34": name_country = ' Испания' if country_id == "49": name_country = ' Германия' if country_id == "420": name_country = ' Чехия' if country_id == "357": name_country = ' Кипр' if country_id == "44": name_country = ' Британия' if country_id == "39": name_country = ' Италия' if country_id == "351": name_country = ' Португалия' if country_id == "7": name_country = ' Россия' with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) services = data[country_id] # Получаем значения для каждого сервиса buttons = [] for service, price in services.items(): button_text = f"{service}: {price}$" button = telebot.types.InlineKeyboardButton(text=''+button_text, callback_data=f"service_{service}_{country_id}") buttons.append(button) keyboard = telebot.types.InlineKeyboardMarkup(row_width=2) keyboard.add(*buttons) # отправляем пользователю эту клавиатуру backbutton2 = types.InlineKeyboardButton("Назад", callback_data='main-menu') keyboard.add(backbutton2) bot.edit_message_text(chat_id = call.message.chat.id, message_id = call.message.message_id, text=f"<b>Выбор сервиса\nСтрана: {name_country}</b>",reply_markup=keyboard) if req[0] == "service": service = req[1] country_id = req[2] #pay_list with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) check = data[country_id][service] get_balance = MeDb(call.from_user.id) me_balance = get_balance.getMeBalance(call.from_user.id) if float(me_balance) < float(check): Deposit = types.InlineKeyboardMarkup(row_width=2) button = types.InlineKeyboardButton(" Пополнить", callback_data="Deposit") Deposit.add(button) bot.send_message(call.from_user.id, '‼<b>На твоем балансе недостаточно средств чтобы купить номер для этого сервиса!</b>\n\n❕<i>Пополни баланс чтобы воспользоваться сервисом</i>',reply_markup=Deposit) else: #инициализация класса для обнвления баланса balance_up = float(me_balance) - float(check) init__Update = MeDb(call.from_user.id) updateDB = init__Update.UpdateBalance(call.from_user.id,balance_up) url = "https://onlinesim.io/api/getNum.php" params = { "apikey": f"{api_pay}", "service": service, 'country':country_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) idtz_idtrans = str(j['tzid']) + '-' + str(call.from_user.id) #id заказа и транзы output = j['response'] tz_id = str(j['tzid']) if output == 'NO_NUMBER': bot.send_message(call.from_user.id,'<b>♂На данный момент номера для данного сервиса нет</b>') if output == 1: url = "https://onlinesim.io/api/getState.php" params = {"apikey": f"{api_pay}", "tzid":tz_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) with open(f'ordersNum/{idtz_idtrans}.json', 'w+') as src: src.write(json.dumps(j, indent=2)) with open(f'ordersNum/{idtz_idtrans}.json', 'r', encoding='utf-8') as sr: check = sr.read() number = json.loads(check) get_numbers = number[0]["number"] name_country = '' if country_id == "33": name_country = ' Франция' if country_id == "34": name_country = ' Испания' if country_id == "49": name_country = ' Германия' if country_id == "420": name_country = ' Чехия' if country_id == "357": name_country = ' Кипр' if country_id == "44": name_country = ' Британия' if country_id == "39": name_country = ' Италия' if country_id == "351": name_country = ' Португалия' if country_id == "7": name_country = ' Россия' bot.send_message(call.from_user.id, f"<b> Страна: {name_country}</b>\n\n"+ f'<b>Сервис: {service}</b>\n' f"<b>Номер телефона: </b> <code>{get_numbers}</code>\n\n"+ '⚠<b>После отправки смс код в бота поступит автоматически</b>') getcode(idtz_idtrans, tz_id,service) idtz_idtrans = 0 tz_id = 0 service = 0 def getcode(idtz_idtrans, tz_id,service): print('new thread code') if idtz_idtrans != 0 and tz_id != 0 and service != 0: me_id = idtz_idtrans.split('-')[1] i = 0 while i == 0: time.sleep(10) url = "https://onlinesim.io/api/getState.php" params = {"apikey": f"{api_pay}", "tzid":tz_id, } headers = {"accept": "application/json"} response = requests.get(url, params=params, headers=headers) j = json.loads(response.text) with open(f'ordersNum/{idtz_idtrans}.json', 'w+') as src: src.write(json.dumps(j, indent=2)) with open(f'ordersNum/{idtz_idtrans}.json', 'r', encoding='utf-8') as sr: check = sr.read() code = json.loads(check) country_id = code[0]['country'] if code[0]['response'] == 'TZ_NUM_WAIT': if code[0]['time'] < 700: print(code[0]['time']) #price_list with open(f'price/price.json', 'r', encoding='utf-8') as f: data = json.load(f) check = data[country_id][service] get_balance = MeDb(me_id) me_balance = get_balance.getMeBalance(me_id) balance_up = float(me_balance) + float(check) init__Update = MeDb(me_id) updateDB = init__Update.UpdateBalance(me_id,balance_up) url_ok = "https://onlinesim.io/api/setOperationOk.php" params_ok = {"apikey": f"{api_pay}", "tzid":tz_id, } headers_ok = {"accept": "application/json"} responce_ok = requests.get(url_ok, params=params_ok, headers=headers_ok) bot.send_message(idtz_idtrans.split('-')[1],'<b>‼Номер автматически отменен системой!\n♻Средства вернулись на баланс</b>') i += 1 os.remove('ordersNum/'+idtz_idtrans+'.json') elif code[0]['time'] > 700: continue if code[0]['response'] == 'TZ_NUM_ANSWER': i += 1 sms = code[0]['msg'] bot.send_message(idtz_idtrans.split('-')[1], f'<b>Новый код</b>\n\nСМС-КОД: <code>{sms}</code>\n\nУдачи') getOrders = MeDb(me_id) orders = getOrders.getMeOrders(me_id) endOrder = orders + 1 getOrders.updateorders(me_id,endOrder) os.remove('ordersNum/'+idtz_idtrans+'.json') bot.send_message(chat_log,f'<b>Новая покупка</b>\n\nСервис: {service}\nСумма платежа: {amount}$') def Qiwi_nomer(message): msg = message.text if msg == 'Отмена': start(message) else: print(type(msg)) bot.send_message(message.chat.id, f'Вы пополняете {msg} гребней') @bot.message_handler(content_types=['text']) def abort_deposit(message): if message.text == 'Отмена': bot.send_message(message.chat.id, '<b>Вы отменили заявку на пополнение!</b>') if message.text == 'Главное меню': start(message) pay_crypto.py import requests import json import time import sqlite3 import threading crypro_token = '' def create_payorder(message): from sms import bot,types msg_pay = message.text if msg_pay == 'Отмена': bot.send_message(message.chat.id,'<b>✖Транзакция отменена</b>') else: url = 'https://pay.crypt.bot/api/createInvoice' headers = {'Crypto-Pay-API-Token': f'{crypro_token}'} payload = { 'asset': 'USDT', 'amount': msg_pay, } response = requests.post(url, headers=headers, json=payload) j = json.loads(response.text) url_pay = j['result']['pay_url'] hash_pay = j['result']['hash'] amount_pay = j['result']['amount'] asset_pay = j['result']['asset'] time_pay = j['result']['created_at'] markup_urlPay = types.InlineKeyboardMarkup(row_width=2) url_button = types.InlineKeyboardButton("Оплатить", url=f"{url_pay}") markup_urlPay.add(url_button) bot.send_message(message.chat.id,f'<b>Ордер</b>: <code>{hash_pay}</code>\n'+ f'\n<i>Сумма оплаты: {amount_pay} {asset_pay}</i>\n' f'\n<code>#{time_pay}</code>',reply_markup = markup_urlPay) name = str(hash_pay) + '-' + str(message.chat.id) with open(f'paymentsLog/{name}', 'w',encoding='utf-8') as src: src.write(json.dumps(j, indent=2)) checkPay(name) name = 0 def checkPay(name): if name != 0: from sms import bot hasH = name.split('-')[0] id_user = name.split('-')[1] bot.send_message(id_user,'<b>♻После поступления средств бот тебя оповестит</b>') with open(f'paymentsLog/{name}', 'r',encoding='utf-8') as sr: check = sr.read() chek_status = json.loads(check) asset = chek_status['result']['asset'] amount = chek_status['result']['amount'] ivoice = chek_status['result']['invoice_id'] i = 0 while i == 0: time.sleep(5) url = 'https://pay.crypt.bot/api/getInvoices' headers = {'Crypto-Pay-API-Token': f'{crypro_token}'} payload = { 'asset': f'{asset}', 'invoice_ids': f'{ivoice}' } response = requests.get(url, headers=headers, json=payload) j = json.loads(response.text) print (j['result']['items'][0]['status']) if j['result']['items'][0]['status'] == 'active': print('wait') if j['result']['items'][0]['status'] == 'paid': db = sqlite3.connect('base.db') cursor = db.cursor() now_balance = cursor.execute('SELECT balance FROM users WHERE id = ?', (id_user,)).fetchone()[0] balance = float(now_balance) + float(amount) print(balance) cursor.execute(f'UPDATE users SET balance = {balance} WHERE id = {id_user}') db.commit() bot.send_message(id_user,f'<b>✅Ордер: {hasH} оплачен!</b>\n'+ f'\n<b>➕Твой баланс пополнен на {amount} usdt</b>') i += 1 if j['result']['items'][0]['status'] == 'expired': bot.send_message(id_user,f'<b>Ордер: {hasH}\n</b> отменен!</b>') i += 1 Python import requests import json import time import sqlite3 import threading crypro_token = '' def create_payorder(message): from sms import bot,types msg_pay = message.text if msg_pay == 'Отмена': bot.send_message(message.chat.id,'<b>✖Транзакция отменена</b>') else: url = 'https://pay.crypt.bot/api/createInvoice' headers = {'Crypto-Pay-API-Token': f'{crypro_token}'} payload = { 'asset': 'USDT', 'amount': msg_pay, } response = requests.post(url, headers=headers, json=payload) j = json.loads(response.text) url_pay = j['result']['pay_url'] hash_pay = j['result']['hash'] amount_pay = j['result']['amount'] asset_pay = j['result']['asset'] time_pay = j['result']['created_at'] markup_urlPay = types.InlineKeyboardMarkup(row_width=2) url_button = types.InlineKeyboardButton("Оплатить", url=f"{url_pay}") markup_urlPay.add(url_button) bot.send_message(message.chat.id,f'<b>Ордер</b>: <code>{hash_pay}</code>\n'+ f'\n<i>Сумма оплаты: {amount_pay} {asset_pay}</i>\n' f'\n<code>#{time_pay}</code>',reply_markup = markup_urlPay) name = str(hash_pay) + '-' + str(message.chat.id) with open(f'paymentsLog/{name}', 'w',encoding='utf-8') as src: src.write(json.dumps(j, indent=2)) checkPay(name) name = 0 def checkPay(name): if name != 0: from sms import bot hasH = name.split('-')[0] id_user = name.split('-')[1] bot.send_message(id_user,'<b>♻После поступления средств бот тебя оповестит</b>') with open(f'paymentsLog/{name}', 'r',encoding='utf-8') as sr: check = sr.read() chek_status = json.loads(check) asset = chek_status['result']['asset'] amount = chek_status['result']['amount'] ivoice = chek_status['result']['invoice_id'] i = 0 while i == 0: time.sleep(5) url = 'https://pay.crypt.bot/api/getInvoices' headers = {'Crypto-Pay-API-Token': f'{crypro_token}'} payload = { 'asset': f'{asset}', 'invoice_ids': f'{ivoice}' } response = requests.get(url, headers=headers, json=payload) j = json.loads(response.text) print (j['result']['items'][0]['status']) if j['result']['items'][0]['status'] == 'active': print('wait') if j['result']['items'][0]['status'] == 'paid': db = sqlite3.connect('base.db') cursor = db.cursor() now_balance = cursor.execute('SELECT balance FROM users WHERE id = ?', (id_user,)).fetchone()[0] balance = float(now_balance) + float(amount) print(balance) cursor.execute(f'UPDATE users SET balance = {balance} WHERE id = {id_user}') db.commit() bot.send_message(id_user,f'<b>✅Ордер: {hasH} оплачен!</b>\n'+ f'\n<b>➕Твой баланс пополнен на {amount} usdt</b>') i += 1 if j['result']['items'][0]['status'] == 'expired': bot.send_message(id_user,f'<b>Ордер: {hasH}\n</b> отменен!</b>') i += 1 __init__.py from sms import * from pay_crypto import * if __name__ == '__main__': from sms import bot thread = threading.Thread(target=checkPay, args=(name,)) thread = threading.Thread(target=getcode, args=(idtz_idtrans, tz_id, service)) thread.start() bot.infinity_polling() Python from sms import * from pay_crypto import * if __name__ == '__main__': from sms import bot thread = threading.Thread(target=checkPay, args=(name,)) thread = threading.Thread(target=getcode, args=(idtz_idtrans, tz_id, service)) thread.start() bot.infinity_polling() В папке price нужно создать json файл: price.json: { "33": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "7": { "whatsapp":2.10, "viber":1.00, "blablacar":1.00 }, "34": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "49": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "420": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "357": { "whatsapp":5.00, "olx":0.85, "blablacar":1.00 }, "45": { "whatsapp":5.00, "olx":0.85, "blablacar":1.00, "vinted":1.50 }, "44": { "whatsapp":2.50, "olx":0.70, "blablacar":1.00, "vinted":1.30 }, "39": { "whatsapp":5.00, "olx":0.70, "blablacar":1.00 }, "351": { "whatsapp":5.00, "olx":0.70, "blablacar":1.00 } } JS { "33": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "7": { "whatsapp":2.10, "viber":1.00, "blablacar":1.00 }, "34": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "49": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "420": { "whatsapp":3.70, "olx":0.85, "blablacar":1.00, "vinted": 1.50 }, "357": { "whatsapp":5.00, "olx":0.85, "blablacar":1.00 }, "45": { "whatsapp":5.00, "olx":0.85, "blablacar":1.00, "vinted":1.50 }, "44": { "whatsapp":2.50, "olx":0.70, "blablacar":1.00, "vinted":1.30 }, "39": { "whatsapp":5.00, "olx":0.70, "blablacar":1.00 }, "351": { "whatsapp":5.00, "olx":0.70, "blablacar":1.00 } } Запуск python __init__.py
ФРУТС, с гита такая ошибка) upd: пофиксил но сервисов там нет толком как и стран) + оплату переделывать нужно)
Juza, создай чат, закинь туда бота и засунь в админы) возми айди чата и засунь в скрипт где айди чата)