Untitled
unknown
plain_text
a year ago
14 kB
16
Indexable
import telebot from telebot import types import sqlite3 import requests import utils import json import pandas as pd from bs4 import BeautifulSoup import csv from webdriver_manager.chrome import ChromeDriverManager from selenium import webdriver from selenium.webdriver.common.by import By import os import requests from bs4 import BeautifulSoup import time from selenium.webdriver.common.keys import Keys from selenium.common import exceptions from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import NoSuchElementException from selenium.common.exceptions import StaleElementReferenceException from selenium.webdriver.support.ui import WebDriverWait from urllib.parse import urlparse, parse_qs from selenium.webdriver.chrome.service import Service as ChromeService from webdriver_manager.chrome import ChromeDriverManager admiin_ch = 1610681404 channel_id = -1001832482605 privat = -1001822875136 chat = -1001637818589 con = sqlite3.connect('db.db') cur = con.cursor() cur.execute("""CREATE TABLE IF NOT EXISTS link ( id TEXT )""") cur.execute("""CREATE TABLE IF NOT EXISTS ids ( id TEXT )""") cur.execute("""CREATE TABLE IF NOT EXISTS ban ( id TEXT )""") cur.execute("""CREATE TABLE IF NOT EXISTS days ( id TEXT, days TEXT, username TEXT )""") token = '6651555NhEwpdSvgMKAIkMig' bot = telebot.TeleBot(token) variable = utils.Variable() @bot.message_handler(commands=['start']) def stttttt(message): try: if message.chat.type == 'private': con = sqlite3.connect('db.db') cur = con.cursor() a = cur.execute(f"SELECT * FROM ban").fetchall() con.close() b = 0 for i in a: if i[0] == str(message.chat.id): b+=1 if b != 0: pass else: kb = types.InlineKeyboardMarkup(row_width=1) k1 = types.InlineKeyboardButton(text="🛒 Купить подписку", callback_data="1") k3 = types.InlineKeyboardButton(text="📖 Моя подписка", callback_data="3") k4 = types.InlineKeyboardButton(text="🆘 Поддержка", url="https://t.me/") kb.add(k1,k3,k4) bot.send_message(message.chat.id, "Привет, Ты в боте оплаты приватки АБУZZИЩЕ",reply_markup=kb) else: pass except Exception as e: pass @bot.message_handler(commands=['admin']) def admiiin(message): if message.chat.id == admiin_ch: kb = types.InlineKeyboardMarkup(row_width=1) k1 = types.InlineKeyboardButton(text="ПОДПИСКИ", callback_data="ap1") k2 = types.InlineKeyboardButton(text="ЗАБАНИТЬ", callback_data="ap2") k3 = types.InlineKeyboardButton(text="BASE",callback_data="ap3") kb.add(k1,k2,k3) bot.send_message(chat_id=admiin_ch, text= "ADMIN PANEL",reply_markup=kb) @bot.callback_query_handler(func = lambda call: True) def print_all_commandas(call): username = call.from_user.id print(call.data) if call.data.startswith("payment_"): button_number = int(call.data.split('_')[1]) print(button_number) con = sqlite3.connect('db.db') cur = con.cursor() a = cur.execute(f"SELECT * FROM ban").fetchall() con.close() b = 0 for i in a: if i[0] == str(call.message.chat.id): b+=1 if b != 0: pass else: try: url = f'https://volkovyschool.getcourse.ru/pl/gcpay/client/payment/index?id=&operation_type=&status=0&filter_deal={button_number}&payment_id=&method_type=&transferred=' driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) driver.get(url) time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[1]/div/div[1]/input').send_keys('volm') time.sleep(2) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[2]/div/div[1]/input').send_keys('sojnuun') time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[3]/button[1]').click() time.sleep(3) a = driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/div[2]/div/div/div[3]/table/tbody/tr[1]/td[5]/span').text print(a) if a != "Выполнено": bot.send_message(call.message.chat.id, "Ваша оплата еще не прошла, повторите попытку через некоторое время\nОбычно это занимает от 2 до 5 минут") else: try: con = sqlite3.connect('db.db') cur = con.cursor() statuss = cur.execute(f"SELECT * FROM ids").fetchall() print(statuss) k = 0 for i in statuss: print(int(i[0]),button_number) if int(i[0]) == button_number: k+=1 if k == 0: try: a = cur.execute(f"SELECT days FROM days WHERE id = '{username}'").fetchone()[0] cur.execute(f"UPDATE days SET days = '{int(a)+30}'") cur.execute(f"INSERT INTO ids VALUES({button_number})") con.commit() except: cur.execute(f"INSERT INTO days VALUES (?,?,?)",(username,30,call.from_user.username)) cur.execute(f"INSERT INTO ids VALUES({button_number})") con.commit() con.close() appa = bot.get_chat_members_count(privat) print(appa) invite_link = bot.create_chat_invite_link(privat, member_limit=1).invite_link chat_link = bot.create_chat_invite_link(chat, member_limit=1).invite_link bot.send_message(call.message.chat.id, f"Ваша оплата успешно прошла\n\nКанал: {invite_link}\n\nЧат: {chat_link}") else: bot.send_message(call.message.chat.id, "Эта сделка уже не актуальна") except: print("неконнект в базу данных") except: bot.send_message(call.message.chat.id, "Перегруз Сервера попробуйте чуть позже") if call.data == "1": con = sqlite3.connect('db.db') cur = con.cursor() a = cur.execute(f"SELECT * FROM ban").fetchall() con.close() b = 0 for i in a: if i[0] == str(call.message.chat.id): b+=1 if b != 0: pass else: variable.set_action(call.message.chat.id, 1) bot.send_message(call.message.chat.id, "Введи почту для оформления счета на оплату (если вы уже ее вводили то введите новую почту)") elif call.data == "ap1": bot.send_message(call.message.chat.id, "Введите id пользователя и количество дней через пробел\n\nПример (12312321 30)") variable.set_action(call.message.chat.id,10) elif call.data == "ap2": bot.send_message(call.message.chat.id, "Введите id пользователя для бана") variable.set_action(call.message.chat.id,20) elif call.data == "ap3": conn = sqlite3.connect('db.db') # Выполнение SQL-запроса и получение данных в виде DataFrame query = "SELECT * FROM days" df = pd.read_sql_query(query, conn) # Закрываем соединение с базой данных conn.close() # Сохранение DataFrame в файл Excel df.to_excel('base.xlsx', index=False) o = open("base.xlsx","rb") bot.send_document(call.message.chat.id, o , "Выгрузка базы данных ") elif call.data == "2": print(2) elif call.data == "3": try: con = sqlite3.connect('db.db') cur = con.cursor() try: a = cur.execute(f"SELECT days FROM days WHERE id = '{username}'").fetchone()[0] con.close() bot.send_message(call.message.chat.id, f"У тебя осталось {a} дней до конца подписки") except: bot.send_message(call.message.chat.id, f"У тебя нет подписки") except: bot.send_message(call.message.chat.id, f"Коннект с базой данных утерян") elif call.data == "4": print(4) @bot.message_handler(func=lambda message: True, content_types=['text','photo']) def handle_text(message): text = message.text action = int(variable.get_action(message.chat.id)) if action == 1: try: bot.send_message(message.chat.id, "Генерирую ссылку на оплату, пожалуйста подождите (примерно 30 сек)") url = 'https://volkovyschool.getcourse.ru/pl/user/user/create' driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install())) driver.get(url) time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[1]/div/div[1]/input').send_keys('volkov.ury@gmail.com') time.sleep(2) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[2]/div/div[1]/input').send_keys('sojnu5-qajmYn-wefmun') time.sleep(2) driver.find_element(By.XPATH,'/html/body/div[1]/div/div/div/div[3]/div/div/div/form/div[1]/div[3]/button[1]').click() time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/form/div[2]/div[1]/div[1]/input').send_keys(text) time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/form/div[2]/div[1]/div[3]/input').send_keys(message.from_user.username) time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div[2]/form/div[3]/button').click() time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div/div[3]/div[1]/div[2]/button').click() time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div/div[3]/div[1]/div[2]/ul/li[3]/a').click() time.sleep(3) driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div/form/div[2]/div[2]/div/table/tbody/tr/td/div/div').click() time.sleep(4) driver.find_element(By.XPATH,'//*[@id="w0-container"]/table/tbody/tr[4]/td[2]/div/a').click() time.sleep(2) driver.find_element(By.XPATH,'//*[@id="gc-modal-0"]/div[1]/div/div[1]/div[2]/div[2]/button[1]').click() time.sleep(2) driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div/form/div[4]/input').click() time.sleep(2) link = driver.find_element(By.XPATH,'/html/body/div[2]/div/div/div/div[3]/div[1]/div[1]/a').get_attribute("href") print(link) parsed_url = urlparse(link) query_params = parse_qs(parsed_url.query) # Извлечение значения параметра filter_deal filter_deal_value = query_params.get('id', [None])[0] print("Значение параметра filter_deal:", filter_deal_value) kb = types.InlineKeyboardMarkup(row_width=1) k1 = types.InlineKeyboardButton(text="ОПЛАТИТЬ", url=f'{link}') k2 = types.InlineKeyboardButton(text="Я ОПЛАТИЛ", callback_data=f"payment_{filter_deal_value}") kb.add(k1,k2) bot.send_message(message.chat.id, "Приватка по кешбекам\n\n/мес",reply_markup=kb) variable.set_action(message.chat.id, 0) except: bot.send_message(message.chat.id, "Не верная почта или уже указанная\n\n/start") elif action == 2 : pass elif action == 10: try: idss = message.text.split(' ')[0] dayyys = int(message.text.split(' ')[1]) userka = message.text.split(' ')[2] con = sqlite3.connect('db.db') cur = con.cursor() try: a = cur.execute(f"SELECT days FROM days WHERE id = '{idss}'").fetchone()[0] cur.execute(f"UPDATE days SET days = '{dayyys}' WHERE ids = '{idss}") con.commit() con.close() bot.send_message(message.chat.id, "Успешно") except: cur.execute(f"INSERT INTO days VALUES (?,?,?)",(idss,dayyys,)) con.commit() con.close() bot.send_message(message.chat.id, "Успешно") variable.set_action(message.chat.id, 0) except: bot.send_message(message.chat.id, "Не верный ввод данных") elif action == 20: try: con = sqlite3.connect('db.db') cur = con.cursor() try: a = cur.execute(f"SELECT * FROM ban").fetchall() b = 0 for i in a: if i[0] == message.text: b+=1 if b != 0: bot.send_message(message.chat.id, "Пользователь уже в бане") else: cur.execute(f"INSERT INTO ban VALUES('{message.text}')") con.commit() con.close() bot.send_message(message.chat.id, "Пользователь успешно внесен в бан лист") except: bot.send_message(message.chat.id, "Проблемы с базой данных") except: bot.send_message(message.chat.id, "Не верный ввод данных") if __name__ == "__main__": try: bot.polling(none_stop=True) except: bot.polling() time.sleep(5)
Editor is loading...
Leave a Comment