Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAIN:
- import logging
- import sqlite3
- import configparser, time, random
- from aiogram import Bot, Dispatcher, executor, types
- from aiogram.dispatcher import FSMContext
- from aiogram.utils import executor
- from qiwipyapi import Wallet
- from aiogram.contrib.fsm_storage.memory import MemoryStorage
- from aiogram.dispatcher.filters.state import State, StatesGroup
- from aiogram.dispatcher.filters import BoundFilter
- from string import ascii_letters, digits
- import db
- import functions as fc
- import keyboard as kb
- import keyboard as key
- from config import number, QIWI_SEC_TOKEN, admin
- from aiogram.dispatcher import FSMContext
- config = configparser.ConfigParser()
- config.read("settings.ini")
- TOKEN = config["tgbot"]["token"]
- class IsPrivate(BoundFilter):
- async def check(self, message: types.Message):
- return message.chat.type == types.ChatType.PRIVATE
- class Info(StatesGroup):
- upload_file = State()
- upload_file_password = State()
- delete_file = State()
- check_password = State()
- logging.basicConfig(level=logging.INFO)
- bot = Bot(token=TOKEN)
- storage = MemoryStorage()
- dp = Dispatcher(bot, storage=MemoryStorage())
- connection = sqlite3.connect('data.db')
- q = connection.cursor()
- wallet_p2p = Wallet(number, p2p_sec_key=QIWI_SEC_TOKEN)
- class Form(StatesGroup):
- report = State()
- @dp.message_handler(IsPrivate(), commands=['start', 'help'], state='*')
- async def start_command(message: types.Message, state: FSMContext):
- args = message.get_args()
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- if db.get_users_exist(message.chat.id) == False:
- await db.add_user_to_db(message)
- if not args:
- await bot.send_message(chat_id=message.chat.id, text=f'👋, <b>{message.from_user.first_name} \n</b> Я помогу тебе поделиться файлами.\n👇👇👇👇👇', reply_markup = kb.menu_kb(), parse_mode='html')
- else:
- type_file, fileID, viwes, password = db.get_file(args)
- if type_file is None and fileID is None:
- await bot.send_message(chat_id=message.chat.id, text='Я не нашел данный файл:(', reply_markup = kb.menu_kb())
- else:
- if password == (None,):
- db.update_viwes(args)
- if type_file[0] == 'photo':
- await bot.send_photo(chat_id=message.chat.id, photo=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'video':
- await bot.send_video(chat_id=message.chat.id, video=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'voice':
- await bot.send_voice(chat_id=message.chat.id, voice=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'document':
- await bot.send_document(chat_id=message.chat.id, document=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- else:
- await bot.send_message(chat_id=message.chat.id, text='Упс, кажется файл защищен паролем, введите пароль:', reply_markup = kb.back_kb())
- await state.update_data(check_password=args)
- await Info.check_password.set()
- else:
- if not args:
- await bot.send_message(chat_id=message.chat.id, text=f'Привет, <b>{message.from_user.first_name}</b>\nЯ помогу тебе поделиться файлами.', reply_markup=key.menu, parse_mode="HTML")
- else:
- type_file, fileID, viwes, password = db.get_file(args)
- if type_file is None and fileID is None:
- await bot.send_message(chat_id=message.chat.id, text='Я не нашел данный файл:(', reply_markup = kb.menu)
- else:
- if password == (None,):
- db.update_viwes(args)
- if type_file[0] == 'photo':
- await bot.send_photo(chat_id=message.chat.id, photo=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'video':
- await bot.send_video(chat_id=message.chat.id, video=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'voice':
- await bot.send_voice(chat_id=message.chat.id, voice=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- elif type_file[0] == 'document':
- await bot.send_document(chat_id=message.chat.id, document=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={args}', reply_markup = kb.menu)
- else:
- await bot.send_message(chat_id=message.chat.id, text='Упс, кажется файл защищен паролем, введите пароль:', reply_markup = kb.back_kb())
- await state.update_data(check_password=args)
- await Info.check_password.set()
- @dp.message_handler(text='📤Download')
- async def create_post(message: types.Message):
- if db.get_users_exist(message.chat.id) == True:
- await bot.send_message(chat_id=message.chat.id, text='Отправь мне файл.', reply_markup = kb.back_kb())
- await Info.upload_file.set()
- # @dp.message_handler(text='👤 Профиль 👤')
- # async def profile(message: types.Message):
- # if db.get_users_exist(message.chat.id) == True:
- # await bot.send_message(chat_id=message.chat.id, text=f'Ваше имя: <b>{message.from_user.first_name}</b>\n'
- # f'🫵 ник: <i>@{message.from_user.username}</i>\n'
- # f'Твой ID: {message.from_user.id}', parse_mode="HTML")
- @dp.message_handler(text='📁Мои файлы')
- async def create_post(message: types.Message):
- if db.get_users_exist(message.chat.id) == True:
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- all_types, all_ids, all_viwes, passwords = db.get_files_user(message.from_user.id)
- if all_types == []:
- await bot.send_message(chat_id=message.chat.id, text='У вас нету загруженных файлов, чтобы загрузить файлы нажмите "📤Download"', reply_markup = kb.menu)
- else:
- text='Ваши файлы: \n\n'
- for i, id_file in enumerate(all_ids):
- text+=f'{i+1}. https://t.me/{str(bot_name)}?start={id_file[0]} | {all_types[i][0]} | 👁 {all_viwes[i][0]} | Пароль: {passwords[i][0]}\n\n'
- await bot.send_message(chat_id=message.chat.id, text=text, reply_markup = kb.delete_file())
- # Работа с файлами добавление/удаление/пароль
- @dp.message_handler(state=Info.check_password, content_types=types.ContentTypes.ANY)
- async def upload_file(message: types.Message, state: FSMContext):
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- if message.text:
- if message.text.lower() == 'отмена':
- await bot.send_message(chat_id=message.chat.id, text='Вы вернулись в главное меню.', reply_markup=key.menu)
- await state.finish()
- else:
- user_data = await state.get_data()
- code = user_data['check_password']
- type_file, fileID, viwes, password = db.get_file(code)
- print(viwes[0])
- if message.text == password[0]:
- db.update_viwes(code)
- if type_file[0] == 'photo':
- await bot.send_photo(chat_id=message.chat.id, photo=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={code}', reply_markup = kb.menu_kb())
- elif type_file[0] == 'video':
- await bot.send_video(chat_id=message.chat.id, video=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={code}', reply_markup = kb.menu_kb())
- elif type_file[0] == 'voice':
- await bot.send_voice(chat_id=message.chat.id, voice=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={code}', reply_markup = kb.menu_kb())
- elif type_file[0] == 'document':
- await bot.send_document(chat_id=message.chat.id, document=fileID[0], caption=f'Вот ваш файл:\n\n👁 Просмотры: {int(viwes[0])+1}\n\nВы перешли по ссылке: https://t.me/{str(bot_name)}?start={code}', reply_markup = kb.menu_kb())
- await state.finish()
- else:
- await bot.send_message(chat_id=message.chat.id, text='Упс, это не верный пароль, попробуй еще раз:', reply_markup = kb.back_kb())
- else:
- await bot.send_message(chat_id=message.chat.id, text='Упс, это не верный пароль, попробуй еще раз:', reply_markup = kb.back_kb())
- @dp.message_handler(state=Info.upload_file_password, content_types=types.ContentTypes.TEXT)
- async def upload_file(message: types.Message, state: FSMContext):
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- user_data = await state.get_data()
- file_data = user_data['upload_file_password']
- if message.text == '-':
- if file_data.split('|')[1] == 'photo':
- code = file_data.split('|')[2]
- db.add_new_file(file_data.split('|')[0], 'photo', file_data.split('|')[2], file_data.split('|')[3])
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'video':
- code = file_data.split('|')[2]
- db.add_new_file(file_data.split('|')[0], 'video', file_data.split('|')[2], file_data.split('|')[3])
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'voice':
- code = file_data.split('|')[2]
- db.add_new_file(file_data.split('|')[0], 'voice', file_data.split('|')[2], file_data.split('|')[3])
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'document':
- code = file_data.split('|')[2]
- db.add_new_file(file_data.split('|')[0], 'document', file_data.split('|')[2], file_data.split('|')[3])
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif message.text.lower() == 'отмена':
- await bot.send_message(chat_id=message.chat.id, text='Вы вернулись в главное меню.', reply_markup=key.menu)
- await state.finish()
- else:
- if file_data.split('|')[1] == 'photo':
- code = file_data.split('|')[2]
- db.add_new_file_with_password(file_data.split('|')[0], 'photo', file_data.split('|')[2], file_data.split('|')[3], message.text)
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nПароль: {message.text}\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'video':
- code = file_data.split('|')[2]
- db.add_new_file_with_password(file_data.split('|')[0], 'video', file_data.split('|')[2], file_data.split('|')[3], message.text)
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nПароль: {message.text}\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'voice':
- code = file_data.split('|')[2]
- db.add_new_file_with_password(file_data.split('|')[0], 'voice', file_data.split('|')[2], file_data.split('|')[3], message.text)
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nПароль: {message.text}\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- elif file_data.split('|')[1] == 'document':
- code = file_data.split('|')[2]
- db.add_new_file_with_password(file_data.split('|')[0], 'document', file_data.split('|')[2], file_data.split('|')[3], message.text)
- await bot.send_message(chat_id=message.chat.id, text=f'Файл был успешно загружен.\n\nПароль: {message.text}\n\nЧтобы 👁 на файл перейди по сылке:\nhttps://t.me/{bot_name}?start={code}', reply_markup=kb.menu)
- await state.finish()
- @dp.message_handler(state=Info.upload_file, content_types=types.ContentTypes.ANY)
- async def upload_file(message: types.Message, state: FSMContext):
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- if message.photo:
- fileID = message.photo[-1].file_id
- code = ''.join(random.sample(ascii_letters + digits, random.randint(33, 40)))
- await state.update_data(upload_file_password=f'{message.from_user.id}|photo|{code}|{fileID}')
- await bot.send_message(chat_id=message.chat.id, text='Введи пароль, для файла. Если не хочешь, то напиши "-".', reply_markup=kb.back_kb())
- await Info.upload_file_password.set()
- elif message.text:
- if message.text.lower() == 'отмена':
- await bot.send_message(chat_id=message.chat.id, text='Ты вернулся в назад.', reply_markup=key.menu)
- await state.finish()
- else:
- await bot.send_message(chat_id=message.chat.id, text='Отправь мне файл.', reply_markup = kb.back_kb())
- elif message.voice:
- fileID = message.voice.file_id
- code = ''.join(random.sample(ascii_letters + digits, random.randint(33, 40)))
- await state.update_data(upload_file_password=f'{message.from_user.id}|voice|{code}|{fileID}')
- await bot.send_message(chat_id=message.chat.id, text='Введи пароль, для файла. Если не хочешь, то напиши "-".', reply_markup=kb.back_kb())
- await Info.upload_file_password.set()
- elif message.video:
- fileID = message.video.file_id
- code = ''.join(random.sample(ascii_letters + digits, random.randint(33, 40)))
- await state.update_data(upload_file_password=f'{message.from_user.id}|video|{code}|{fileID}')
- await bot.send_message(chat_id=message.chat.id, text='Введи пароль, для файла. Если не хочешь, то напиши "-".', reply_markup=kb.back_kb())
- await Info.upload_file_password.set()
- elif message.document:
- fileID = message.document.file_id
- code = ''.join(random.sample(ascii_letters + digits, random.randint(33, 40)))
- await state.update_data(upload_file_password=f'{message.from_user.id}|document|{code}|{fileID}')
- await bot.send_message(chat_id=message.chat.id, text='Введи пароль, для файла. Если не хочешь, то напиши "-".', reply_markup=kb.back_kb())
- await Info.upload_file_password.set()
- @dp.message_handler(state=Info.delete_file, content_types=types.ContentTypes.TEXT)
- async def del_file(message: types.Message, state: FSMContext):
- try:
- number = int(message.text)
- user_data = await state.get_data()
- mess_id = user_data['delete_file']
- all_types, all_ids, all_viwes, passwords = db.get_files_user(message.from_user.id)
- if number > len(all_ids):
- await bot.send_message(chat_id=message.chat.id, text='Такого файла не существует. Введи номер файла:', reply_markup=kb.delete_back())
- else:
- db.delete_file(all_ids[(number-1)][0])
- await bot.delete_message(message.chat.id, mess_id)
- await bot.send_message(chat_id=message.chat.id, text='Вы успешно удалили файл!', reply_markup=kb.menu_kb())
- await state.finish()
- except ValueError:
- await bot.send_message(chat_id=message.chat.id, text='Введи номер файла:', reply_markup=kb.delete_back())
- @dp.callback_query_handler(state='*')
- async def handler_call(call: types.CallbackQuery, state: FSMContext):
- bot_data = await bot.get_me()
- bot_name = bot_data['username']
- chat_id = call.from_user.id
- if call.data == 'delete_file':
- all_types, all_ids, all_viwes, passwords = db.get_files_user(chat_id)
- if all_ids == []:
- await bot.delete_message(chat_id, call.message.message_id)
- await bot.send_message(chat_id=chat_id, text='У вас нету загруженных файлов, чтобы загрузить файлы нажмите "Загрузить файл"', reply_markup = kb.menu_kb())
- else:
- text='Файлы для удаления: \n\n'
- for i, id_file in enumerate(all_ids):
- text+=f'{i+1}. https://t.me/{str(bot_name)}?start={id_file[0]} | {all_types[i][0]} | 👁 {all_viwes[i][0]} | Пароль: {passwords[i][0]}\n\n'
- text+='Введи номер файла, который ты хочешь удалить.'
- await bot.edit_message_text(chat_id=chat_id, message_id=call.message.message_id, text=text, reply_markup=kb.delete_back())
- await state.update_data(delete_file=call.message.message_id)
- await Info.delete_file.set()
- if call.data == 'delete_back':
- await state.finish()
- all_types, all_ids, all_viwes, passwords = db.get_files_user(chat_id)
- if all_ids == []:
- await bot.delete_message(chat_id, call.message.message_id)
- await bot.send_message(chat_id=chat_id, text='У вас нету загруженных файлов, чтобы загрузить файлы нажмите "Загрузить файл"', reply_markup = kb.menu_kb())
- else:
- text='Ваши файлы: \n\n'
- for i, id_file in enumerate(all_ids):
- text+=f'{i+1}. https://t.me/{str(bot_name)}?start={id_file[0]} | {all_types[i][0]} | 👁 {all_viwes[i][0]} | Пароль: {passwords[i][0]}\n\n'
- await bot.edit_message_text(chat_id=chat_id, message_id=call.message.message_id, text=text, reply_markup=kb.delete_file())
- #Кубик бот
- @dp.message_handler()
- async def anytext(message: types.Message):
- chat_id = message.chat.id
- fc.first(chat_id=chat_id)
- if message.text == '👤 Профиль 👤':
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{message.chat.id}"').fetchone()
- connection.commit()
- await message.answer(f'Ваш профиль:\nID - {message.chat.id}\nUsername - {message.from_user.mention}\nБаланс: {bal[0]}₽', reply_markup=key.buy)
- elif message.text == '🎲 Кубик 🎲':
- await message.answer('Установите сумму на которую хотите сыграть, с помощью кнопок ниже\nПримечание: сумма должна иметься на балансе!', reply_markup=key.summ)
- elif message.text == '✉️ Info':
- await message.answer(f'Это кубик-бот, вы ставите ставку на цифру и либо выигрываете, либо проигрываете.\nВывод от 100 рублей на балансе\nПри выводе взимается комиссия в размере 5%.\nПо всем вопросам обращаться - [клик](tg://user?id={admin})', reply_markup=key.menu, parse_mode='Markdown')
- elif message.text == '10р':
- summ = 10
- link = fc.pay(chat_id=chat_id, summ=summ)
- await message.answer(f'Ваш ID - {message.chat.id}\nК оплате - {summ}₽\n[Ссылка для оплаты]({link})', reply_markup=key.pay, parse_mode='Markdown')
- elif message.text == '50р':
- summ = 50
- link = fc.pay(chat_id=chat_id, summ=summ)
- await message.answer(f'Ваш ID - {message.chat.id}\nК оплате - {summ}₽\n[Ссылка для оплаты]({link})', reply_markup=key.pay, parse_mode='Markdown')
- elif message.text == '100р':
- summ = 100
- link = fc.pay(chat_id=chat_id, summ=summ)
- await message.answer(f'Ваш ID - {message.chat.id}\nК оплате - {summ}₽\n[Ссылка для оплаты]({link})', reply_markup=key.pay, parse_mode='Markdown')
- elif message.text == '500р':
- summ = 500
- link = fc.pay(chat_id=chat_id, summ=summ)
- await message.answer(f'Ваш ID - {message.chat.id}\nК оплате - {summ}₽\n[Ссылка для оплаты]({link})', reply_markup=key.pay, parse_mode='Markdown')
- elif message.text == '1000р':
- summ = 1000
- link = fc.pay(chat_id=chat_id, summ=summ)
- await message.answer(f'Ваш ID - {message.chat.id}\nК оплате - {summ}₽\n[Ссылка для оплаты]({link})', reply_markup=key.pay, parse_mode='Markdown')
- elif message.text == 'Назад':
- await message.answer('Возвращаюсь назад..', reply_markup=key.menu)
- elif message.text == '/admin':
- if str(chat_id) == str(admin):
- await message.answer('Добро пожаловать в админ панель:', reply_markup=key.apanel)
- else:
- await message.answer('Черт! Ты меня взломал🙃')
- @dp.callback_query_handler(lambda call: True) # Inline часть
- async def cal(call):
- chat_id = call.message.chat.id
- bak = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- balik = bak[0]
- connection.commit()
- if call.data == '10r':
- if balik >= 10:
- q.execute(f'UPDATE users SET stavka = 10 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Установлена сумма ставки в размере 10 рублей\nТеперь выберите цифру на которую ставите.', reply_markup=key.cifr)
- else:
- await call.message.answer('Недостаточно средств, пополните баланс.', reply_markup=key.menu)
- elif call.data == '50r':
- if balik >= 50:
- q.execute(f'UPDATE users SET stavka = 50 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Установлена сумма ставки в размере 50 рублей\nТеперь выберите цифру на которую ставите.', reply_markup=key.cifr)
- else:
- await call.message.answer('Недостаточно средств, пополните баланс.', reply_markup=key.menu)
- elif call.data == '100r':
- if balik >= 100:
- q.execute(f'UPDATE users SET stavka = 100 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Установлена сумма ставки в размере 100 рублей\nТеперь выберите цифру на которую ставите.', reply_markup=key.cifr)
- else:
- await call.message.answer('Недостаточно средств, пополните баланс.', reply_markup=key.menu)
- elif call.data == '500r':
- if balik >= 500:
- q.execute(f'UPDATE users SET stavka = 500 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Установлена сумма ставки в размере 500 рублей\nТеперь выберите цифру на которую ставите.', reply_markup=key.cifr)
- else:
- await call.message.answer('Недостаточно средств, пополните баланс.', reply_markup=key.menu)
- elif call.data == '1000r':
- if balik >= 1000:
- q.execute(f'UPDATE users SET stavka = 1000 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Установлена сумма ставки в размере 1000 рублей\nТеперь выберите цифру на которую ставите.', reply_markup=key.cifr)
- else:
- await call.message.answer('Недостаточно средств, пополните баланс.', reply_markup=key.menu)
- elif call.data == '1':
- q.execute(f'UPDATE users SET num = 1 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 1', reply_markup=key.next)
- elif call.data == '2':
- q.execute(f'UPDATE users SET num = 2 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 2', reply_markup=key.next)
- elif call.data == '3':
- q.execute(f'UPDATE users SET num = 3 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 3', reply_markup=key.next)
- elif call.data == '4':
- q.execute(f'UPDATE users SET num = 4 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 4', reply_markup=key.next)
- elif call.data == '5':
- q.execute(f'UPDATE users SET num = 5 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 5', reply_markup=key.next)
- elif call.data == '6':
- q.execute(f'UPDATE users SET num = 6 WHERE user_id IS "{chat_id}"')
- connection.commit()
- await call.message.answer('Вы поставили на цифру 6', reply_markup=key.next)
- elif call.data == 'next':
- ss = q.execute(f'SELECT stavka FROM users WHERE user_id IS "{chat_id}"').fetchone()
- connection.commit()
- number = q.execute(f'SELECT num FROM users WHERE user_id IS "{chat_id}"').fetchone()
- connection.commit()
- await call.message.answer(f'Отлично, вот ваша ставка:\nСумма: {ss[0]}\nСтавка на цифру {number[0]}\nЕсли все верно, жмите "Верно", если нет, жмите "Назад"', reply_markup=key.ask)
- elif call.data == 'back':
- await call.message.answer('Возвращаюсь назад...', reply_markup=key.menu)
- elif call.data == 'ok':
- rep = fc.dice()
- number = q.execute(f'SELECT num FROM users WHERE user_id IS "{chat_id}"').fetchone()
- nm = number[0]
- connection.commit()
- if rep == nm:
- ss = q.execute(f'UPDATE users SET balance = balance + stavka WHERE user_id IS "{chat_id}"').fetchone()
- connection.commit()
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- await call.message.answer(f'Поздравляем! Вам повезло, выпало число: {rep}\nВаш баланс: {bal[0]}₽', reply_markup=key.menu)
- else:
- aa = q.execute(f'UPDATE users SET balance = balance - stavka WHERE user_id IS "{chat_id}"').fetchone()
- connection.commit()
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- await call.message.answer(f'Увы, но вы проиграли, вам выпало число: {rep}\nВаш баланс: {bal[0]}₽', reply_markup=key.menu)
- elif call.data == 'pay':
- await call.message.answer('Выберите сумму для пополнения:', reply_markup=key.paysum)
- elif call.data == 'check':
- try:
- re = q.execute(f"SELECT bd FROM users WHERE user_id = {chat_id}").fetchone()
- status = wallet_p2p.invoice_status(bill_id=re[0])
- val = status['amount']['value']
- value = int(float(val))
- a = status['status']['value']
- if a == 'WAITING':
- await call.message.answer('Ошибка! Платёж не найден.', reply_markup=key.pay)
- elif a == 'PAID':
- await call.message.answer('Оплата успешно найдена.\nТеперь вы можете вывести баланс.', reply_markup=key.menu)
- q.execute(f'UPDATE users SET balance = balance + {value} WHERE user_id IS "{chat_id}"')
- q.execute(f'UPDATE users SET bd = 0 WHERE user_id IS "{chat_id}"')
- connection.commit()
- elif a == 'EXPIRED':
- await call.message.answer('Время жизни счета истекло. Счет не оплачен', reply_markup=key.pay)
- elif a == 'REJECTED':
- await call.message.answer('Счет отклонен', reply_markup=key.pay)
- elif a == 'UNPAID':
- await call.message.answer('Ошибка при проведении оплаты. Счет не оплачен', reply_markup=key.pay)
- except Exception as err:
- await call.message.answer(f'Ошибка:\n{err}')
- elif call.data == 'out':
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- if bal[0] >= 100:
- await call.message.answer('Выберите сумму, которую хотите вывести:\nЕсли желаемой суммы нет в списке, нажмите на "Другое" и напишите администратору.', reply_markup=key.viv)
- else:
- await call.message.answer(f'Недостаточно средств на балансе\nВывод от 100 рублей!', reply_markup=key.menu)
- elif call.data == '100rub':
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- q.execute(f'UPDATE users SET balance = balance - 100 WHERE user_id = "{chat_id}"')
- connection.commit()
- await call.message.answer(f'Заявка на вывод успешно отправлена администраторам, с вами скоро свяжутся.', reply_markup=key.menu)
- await bot.send_message(admin, f'Новая заявка на вывод:\nID - {chat_id}\nЮзернейм - {call.from_user.mention}\n[Ссылка на пользователя]({call.from_user.url})\nБаланс: {bal[0]}₽\nХочет вывести: 100 руб\nС учетом комиссии получит: 95\nСвяжитесь с пользователем, чтобы отправить ему деньги.', parse_mode='Markdown')
- elif call.data == '500rub':
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- if bal[0] >= 500:
- q.execute(f'UPDATE users SET balance = balance - 500 WHERE user_id = "{chat_id}"')
- connection.commit()
- await call.message.answer(f'Заявка на вывод успешно отправлена администраторам, с вами скоро свяжутся.', reply_markup=key.menu)
- await bot.send_message(admin, f'Новая заявка на вывод:\nID - {chat_id}\nЮзернейм - {call.from_user.mention}\n[Ссылка на пользователя]({call.from_user.url})\nБаланс: {bal[0]}₽\nХочет вывести: 500 руб\nС учетом комиссии получит: 475\nСвяжитесь с пользователем, чтобы отправить ему деньги.', parse_mode='Markdown')
- else:
- await call.message.answer('Недостаточно средств на балансе', reply_markup=key.menu)
- elif call.data == '1000rub':
- bal = q.execute(f'SELECT balance FROM users WHERE user_id = "{chat_id}"').fetchone()
- connection.commit()
- if bal[0] >= 1000:
- q.execute(f'UPDATE users SET balance = balance - 1000 WHERE user_id = "{chat_id}"')
- connection.commit()
- await call.message.answer(f'Заявка на вывод успешно отправлена администраторам, с вами скоро свяжутся.', reply_markup=key.menu)
- await bot.send_message(admin, f'Новая заявка на вывод:\nID - {chat_id}\nЮзернейм - {call.from_user.mention}\n[Ссылка на пользователя]({call.from_user.url})\nБаланс: {bal[0]}₽\nХочет вывести: 1000 руб\nС учетом комиссии получит: 950\nСвяжитесь с пользователем, чтобы отправить ему деньги.', parse_mode='Markdown')
- else:
- await call.message.answer('Недостаточно средств на балансе', reply_markup=key.menu)
- elif call.data == 'stats':
- re = q.execute(f'SELECT * FROM users').fetchall()
- kol = len(re)
- bal = q.execute(f"SELECT sum(balance) FROM users").fetchone()
- connection.commit()
- await call.message.answer(f'Всего пользователей: {kol}\nОбщий баланс всех пользователей: {bal[0]}₽')
- if __name__ == "__main__":
- db.check_db()
- executor.start_polling(dp, skip_updates=True)
- KEYBOARD:
- from aiogram.types import ReplyKeyboardRemove, ReplyKeyboardMarkup, KeyboardButton, InlineKeyboardMarkup, InlineKeyboardButton
- from aiogram import Bot, Dispatcher, executor, types
- from config import ausername
- # Клавиатура
- menu = types.ReplyKeyboardMarkup(row_width=3, resize_keyboard=True)
- menu.add(
- types.KeyboardButton(text='Зароботок'),
- types.KeyboardButton(text='🎲 Кубик 🎲'),
- types.KeyboardButton(text='📤Download'),
- types.KeyboardButton(text='📁Мои файлы'),
- types.KeyboardButton(text='👤 Профиль 👤'),
- types.KeyboardButton(text='✉️ Info')
- )
- def back_kb():
- button1 = KeyboardButton('Отмена')
- back_kb1 = ReplyKeyboardMarkup(resize_keyboard=True, one_time_keyboard=True)
- back_kb1.add(button1)
- return back_kb1
- def delete_file():
- markup = InlineKeyboardMarkup()
- btn2 = InlineKeyboardButton(text='🔄 Удалить файл 🔄', callback_data=f'delete_file')
- markup.add(btn2)
- return markup
- def delete_back():
- markup = InlineKeyboardMarkup()
- btn2 = InlineKeyboardButton(text='Отмена', callback_data=f'delete_back')
- markup.add(btn2)
- return markup
- summ = types.InlineKeyboardMarkup(row_width=3)
- summ.add(
- types.InlineKeyboardButton(text='10 руб', callback_data='10r'),
- types.InlineKeyboardButton(text='50 руб', callback_data='50r'),
- types.InlineKeyboardButton(text='100 руб', callback_data='100r'),
- types.InlineKeyboardButton(text='500 руб', callback_data='500r'),
- types.InlineKeyboardButton(text='1000 руб', callback_data='1000r'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- cifr = types.InlineKeyboardMarkup(row_width=3)
- cifr.add(
- types.InlineKeyboardButton(text='1', callback_data='1'),
- types.InlineKeyboardButton(text='2', callback_data='2'),
- types.InlineKeyboardButton(text='3', callback_data='3'),
- types.InlineKeyboardButton(text='4', callback_data='4'),
- types.InlineKeyboardButton(text='5', callback_data='5'),
- types.InlineKeyboardButton(text='6', callback_data='6'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- next = types.InlineKeyboardMarkup(row_width=3)
- next.add(
- types.InlineKeyboardButton(text='Продолжить', callback_data='next'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- ask = types.InlineKeyboardMarkup(row_width=3)
- ask.add(
- types.InlineKeyboardButton(text='Верно', callback_data='ok'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- buy = types.InlineKeyboardMarkup(row_width=3)
- buy.add(
- types.InlineKeyboardButton(text='Пополнить', callback_data='pay'),
- types.InlineKeyboardButton(text='Вывод', callback_data='out'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- pay = types.InlineKeyboardMarkup(row_width=3)
- pay.add(
- types.InlineKeyboardButton(text='Проверить оплату', callback_data='check'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- paysum = types.ReplyKeyboardMarkup(resize_keyboard=True)
- paysum.add(
- types.KeyboardButton(text='10р'),
- types.KeyboardButton(text='50р'),
- types.KeyboardButton(text='100р'),
- types.KeyboardButton(text='500р'),
- types.KeyboardButton(text='1000р'),
- types.KeyboardButton(text='Назад')
- )
- apanel = types.InlineKeyboardMarkup(row_width=3)
- apanel.add(
- types.InlineKeyboardButton(text='Статистика', callback_data='stats'),
- types.InlineKeyboardButton(text='Розсилка', callback_data='rozsl')
- )
- output = types.InlineKeyboardMarkup(row_width=3)
- output.add(
- types.InlineKeyboardButton(text='Вывести', callback_data='output'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
- viv = types.InlineKeyboardMarkup(row_width=3, )
- viv.add(
- types.InlineKeyboardButton(text='500 руб', callback_data='500rub'),
- types.InlineKeyboardButton(text='1000 руб', callback_data='1000rub'),
- types.InlineKeyboardButton(text='Другое', url=f't.me/{ausername}'),
- types.InlineKeyboardButton(text='Назад', callback_data='back')
- )
Add Comment
Please, Sign In to add comment