Ejemplo n.º 1
0
async def chek_task(Dispatcher: dp):
    while True:
        try:
            task = Base().read_tasks('tasks')
            file_name = Base().read_notif('notifications')

            if task[1] in file_name:
                logger.debug('[--] SLEEPING 5 SEC')
                time.sleep(5)


            else:
                logger.info('[--] NOTIFICATION ADMIN')
                admins = Base().read_admin_p2p('admins')
                for admin in admins:
                    if admin[1] == 1:

                        file_ = open(task[1], 'rb')
                        await Dispatcher.bot.send_photo(chat_id=admin[0], photo=file_, reply_markup=orsers)
                        Base().add_file_name('notifications', task[1])


        except:
            logger.debug('[--] SLEEPING 5 SEC')
            time.sleep(5)
async def chek_pay(call: types.CallbackQuery):
    indif = sale_chek_qiwi()
    await call.message.delete()
    if len(indif) == 0:
        com = Base().read_tasks('tasks')
        user_pay = InlineKeyboardMarkup()

        sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                    url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
        chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
        promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
        delete_task = InlineKeyboardButton(text='❌ Удалить задание', callback_data=filter.new('delete_task'))
        user_pay.add(sale, chek_sale)
        user_pay.add(promo)
        user_pay.add(delete_task)

        id = Base().read_tasks('tasks')
        await bot.send_message(chat_id=id[0], text='<b>❌ Извини, я не увидел оплату</b>\n\n'
                                                   '<i>Попробуй еще раз 😋</i>', reply_markup=user_pay)

    if len(indif) > 0:
        id = Base().read_tasks('tasks')
        await bot.send_message(chat_id=id[0], text='✅ Оплата прошла успешно\n\n'
                                                   '<b><pre>Ты находишься в закрытом чате с исполнителем напиши ему сообщение</pre></b>')

        admins = Base().read_admin_p2p('admins')
        for admin in admins:
            if admin[1] == 1:
                await bot.send_message(
                    chat_id=admin[0],
                    text='<b><pre>Ты находишься в закрытом чате с заказчиком напиши ему сообщение</pre></b>',
                    reply_markup=stop_chat)
                Base().update_task_id('tasks', True, id[0])
async def orders(message: types.Message):
    admin = Base().read_admin('admins', message.chat.id)
    if admin[1] == 1:
        try:
            data = Base().read_tasks('tasks')
            file = open(data[1], 'rb')
            await message.answer_photo(photo=file, reply_markup=orsers)
        except Exception as e:
            logger.error(e)
            await message.answer(text='Извини я не нашел заданий в базе 😿')
    else:
        await message.answer(text='Извини но ты не админ!\n'
                             'В скором времени тебя назначат админом')
Ejemplo n.º 4
0
async def stop_chat(message: types.Message):
    id = Base().read_tasks('tasks')

    Base().delete_task('tasks', id[0])

    await bot.send_message(
        chat_id=id[0],
        text='Надеюсь тебе все понравилось\n\n'
        '<b>А если у тебя остались вопросы, то обращайся в нашу службу поддержки</b>',
        reply_markup=user_support)

    await message.answer(text='Задание успешно выполнено!',
                         reply_markup=start_menu)
async def swap_admin(call: types.CallbackQuery):
    admins = Base().read_admin_p2p('admins')
    for admin in admins:
        if admin[1] == 1:

            admins_ = Base().read_admin_p2p('admins')
            markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
            for admin_ in admins_:
                btn = types.KeyboardButton(text=f'{admin_[2]}')
                markup.add(btn)

            await bot.send_message(chat_id=call.message.chat.id, text='Выбери Админа 🧔', reply_markup=markup)
            await Admin.adm.set()
            await call.message.delete()
            await call.message.delete()
async def yes_task(call: types.CallbackQuery):
    id = Base().read_tasks('tasks')
    await call.message.delete()
    try:
        if Base().read_user_pay_id('user_pay', id[0])[1] == 0:
            com = Base().read_tasks('tasks')
            user_pay = InlineKeyboardMarkup()

            sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                        url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
            chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
            promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
            delete_task = InlineKeyboardButton(text='❌ Удалить задание', callback_data=filter.new('delete_task'))
            user_pay.add(sale, chek_sale)
            user_pay.add(promo)
            user_pay.add(delete_task)

            await bot.send_message(chat_id=id[0], text='⭐️ Ты уже использовал пробный раз\n\n'
                                                       '<b>Произведи оплату по кнокпе <i>💵 Произвести оплату</i></b>\n\n'
                                                       '<b>После оплаты нажми на кнопку <i>💎 Проверить оплату</i></b>\n\n'
                                                       '😍 Ты можешь поделиться с другом своим промокодом, и тебе начислят бесплатное решение задачи 🍒\n\n'
                                                       f'<i>Твой промокод <b>{id[0]}</b></i>\n\n'
                                                       '<pre>💞 А если у тебя есть промокод твоего знакомого, то нажимай кнопку</pre>',
                                   reply_markup=user_pay)

            await call.message.answer(text='<i>👨 Ждем оплаты заказчика!</i>\n\n'
                                           '<pre>После оплаты заказчика, вас перенаправят в закрытый чат 📣</pre>',
                                      reply_markup=delete_markup)

        if Base().read_user_pay_id('user_pay', id[0])[1] > 0:
            count = Base().read_user_pay_id('user_pay', id[0])[1]
            Base().update_user_pay('user_pay', id[0], int(count) - 1)
            await bot.send_message(chat_id=id[0], text='✅ Твое задание прошло модерацию\n\n'
                                                       '<b><pre>Ты находишься в закрытом чате с исполнителем напиши ему сообщение</pre></b>')

            await call.message.answer(
                text='<b><pre>Ты находишься в закрытом чате с заказчиком напиши ему сообщение</pre></b>',
                reply_markup=stop_chat)
            Base().update_task_id('tasks', True, id[0])


    # если в базе не нашли запись использования пробного раза
    except Exception as e:
        print(e)

        await bot.send_message(chat_id=id[0], text='✅ Твое задание прошло модерацию\n\n'
                                                   '<b><pre>Ты находишься в закрытом чате с исполнителем напиши ему сообщение</pre></b>')

        await call.message.answer(
            text='<b><pre>Ты находишься в закрытом чате с заказчиком напиши ему сообщение</pre></b>',
            reply_markup=stop_chat)
        Base().add_user_pay('user_pay', id[0], 0)
        Base().update_task_id('tasks', True, id[0])
async def no_task(call: types.CallbackQuery):
    # users message
    id = Base().read_tasks('tasks')
    await call.message.delete()
    await bot.send_message(chat_id=id[0], text='❌ Твое задание не прошло модерацию\n\n'
                                               '<pre>Перейди в главное меню и отправь задание снова 🖼</pre>',
                           reply_markup=add_task_user)

    # admins message
    Base().delete_task('tasks', id[0])
    try:
        data = Base().read_tasks('tasks')
        file = open(data[1], 'rb')
        await call.message.answer_photo(photo=file, reply_markup=orsers)
    except:
        await call.message.answer(text='Извини я не нашел заданий в базе 😿')
async def new_admin(message: types.Message, state: FSMContext):
    name = message.text
    Base().add_admin('admins', message.chat.id, False, name)

    await message.answer(text='✅ Успешно, жди когда тебя назначат админом!')

    await state.reset_state()
Ejemplo n.º 9
0
async def on_startup_notify(dp: Dispatcher):
    admin = Base().read_admin('admins')
    try:
        await dp.bot.send_message(admin, "Бот Запущен")

    except Exception as err:
        logging.exception(err)
Ejemplo n.º 10
0
async def photo_download(message: types.Message, state: FSMContext):
    try:
        download_task = await message.photo[-1].download()
        if len(Base().read_tasks_id('tasks', message.chat.id)) == 1:
            await message.answer(
                '🤓 Извини, но ты уже разместил задание, дождись своей очереди ⭐️'
            )
        else:
            Base().add_task('tasks', message.chat.id, f'{download_task.name}',
                            False)
            await message.answer(
                '✅ Твоё задание отправлено на модерацию, дождись ответа 📬',
                reply_markup=delete_markup)
            await state.reset_state()
    except:
        await message.answer(text='Отправляй только задание в ввиде фото!')
        await Photo.chek_photo.set()
async def delete_user_task(call: types.CallbackQuery):
    id = Base().read_tasks('tasks')
    admins = Base().read_admin_p2p('admins')
    for admin in admins:
        if call.message.chat.id == admin[0]:
            Base().delete_task('tasks', id[0])
            await call.message.answer(text='✅ Задание удалено')
            await bot.send_message(chat_id=id[0], text='<b>😿 Твое задание удалали, из-за длительной не оплаты</b>',
                                   reply_markup=add_task_user)

        else:
            if id[0] == call.message.chat.id:
                Base().delete_task('tasks', call.message.chat.id)
                await call.message.delete()
                await call.message.answer(f'✅ Твое задание удалено успешно!', reply_markup=add_task_user)
                admins = Base().read_admin_p2p('admins')
                for admin in admins:
                    if admin[1] == 1:
                        await bot.send_message(chat_id=admin[0],
                                               text='<b>🙈 Заказчик удалил задание, приступай к следующему</b>')
    await call.message.delete()
async def swap_admin(message: types.Message, state: FSMContext):
    name = message.text
    await state.update_data(admin=name)
    Base().update_admin('admins', True, name)

    admins = Base().read_admin_p2p('admins')
    for admin in admins:
        if admin[2] == name:
            pass
        else:
            if admin[1] == 1:
                Base().update_admin('admins', False, admin[2])


    id = Base().read_admin_name('admins', name)

    await bot.send_message(chat_id=message.chat.id, text='✅ Ты поменялся ролями', reply_markup=ReplyKeyboardRemove())

    await bot.send_message(chat_id=id, text=f'Привет, тебя назначили админом 🧔 ', reply_markup=start_menu)

    await state.reset_state()
async def admin_panel_(message: types.Message):
    admin = Base().read_admin('admins', message.chat.id)
    if admin[1] == 1:
        await message.answer(
            text=f'<pre>{message.from_user.full_name} 🧔 </pre>\n\n'
            f'<i>Это твоя админ панель, тут ты можешь</i>\n\n'
            f'<b>- 👥 Поменять админа</b>\n'
            f'<b>- 🌐 Выгрузить базу данных с людьми</b>',
            reply_markup=admin_panel,
            parse_mode='html')

    else:
        await message.answer(text='Извини но ты не админ!\n'
                             'В скором времени тебя назначат админом')
def sale_chek_qiwi():
    s = requests.Session()
    s.headers['authorization'] = 'Bearer ' + QIWI_TOKEN
    parameters = {'rows': '50'}
    h = s.get('https://edge.qiwi.com/payment-history/v1/persons/' + QIWI_ACCOUNT + '/payments', params=parameters)
    req = json.loads(h.text)
    print(req)
    indif = []
    com = Base().read_tasks('tasks')

    for i in range(len(req['data'])):
        if req['data'][i]['comment'] == f'{com[1]}':
            if req['data'][i]['sum']['amount'] == 100:
                indif.append(1)
                logger.info(indif)
                break

    return indif
Ejemplo n.º 15
0
async def bot_start(message: types.Message):
    try:
        admin = Base().read_admin('admins', message.chat.id)
        if admin[1] == 1:
            await message.answer(
                f'Привет <pre>{message.from_user.full_name}</pre>\n\n'
                f'Я <b>бот Решелье 🤖</b>,в котором ты найдешь задания на день',
                reply_markup=start_menu)

        else:
            await message.answer(text='Извини но ты не админ!\n')

    except:
        await message.answer(
            f"Привет я Бот Решелье 🤖, который поможет решить твои задачи по:\n"
            f"<b>Математике, геометрии, алгебре и высшей математике 👨‍🏫</b>\n\n"
            f"Первая попытка бесплатная, последующие решения будут стоить 100 рублей. ‍\n\n"
            f"<code>💎 Отправляй фотографию задачи, и я решу её</code>",
            parse_mode='HTML')

        await Photo.chek_photo.set()
Ejemplo n.º 16
0
async def p2p(message: types.Message):
    try:
        admin = Base().read_admin('admins', message.chat.id)
        if admin[1] == 1:
            try:
                id = Base().read_tasks('tasks')
                if id[2] == 1:
                    photo = await message.photo[-1].download()
                    file = open(photo.name, 'rb')
                    await bot.send_photo(chat_id=id[0], photo=file)
            except Exception as e:
                logger.error(e)

            try:
                id = Base().read_tasks('tasks')
                if id[2] == 1:
                    text = message.text
                    await bot.send_message(chat_id=id[0], text=text)
            except Exception as e:
                logger.error(e)
    except:
        pass
    try:
        if message.chat.id == Base().read_tasks('tasks')[0]:
            id = Base().read_tasks('tasks')
            if id[2] == 1:
                admin = Base().read_admin_p2p('admins')
                for cheker in admin:
                    if cheker[1] == 1:
                        try:
                            photo = await message.photo[-1].download()
                            file = open(photo.name, 'rb')
                            await bot.send_photo(chat_id=cheker[0], photo=file)
                        except Exception as e:
                            logger.error(e)

                        try:
                            text = message.text
                            await bot.send_message(chat_id=cheker[0],
                                                   text=text)
                        except Exception as e:
                            logger.error(e)
                    else:
                        pass
    except:
        await message.answer(text='Извини, но тебе нужно использовать кнопки',
                             reply_markup=user_support)
import requests
import json
from utils.db_api import Base
from loguru import logger

base = Base()

QIWI_TOKEN = 'cf8c9e9923b9165e221096c9e5b40998'
QIWI_ACCOUNT = '+79119009060'

def sale_chek_qiwi():
    s = requests.Session()
    s.headers['authorization'] = 'Bearer ' + QIWI_TOKEN
    parameters = {'rows': '50'}
    h = s.get('https://edge.qiwi.com/payment-history/v1/persons/' + QIWI_ACCOUNT + '/payments', params=parameters)
    req = json.loads(h.text)
    print(req)
    indif = []
    com = Base().read_tasks('tasks')

    for i in range(len(req['data'])):
        if req['data'][i]['comment'] == f'{com[1]}':
            if req['data'][i]['sum']['amount'] == 100:
                indif.append(1)
                logger.info(indif)
                break

    return indif
async def chek_promo(message: types.Message, state: FSMContext):
    user_code = message.text
    code_in_base = Base().read_user_pay('user_pay')
    data = []
    for cod in code_in_base:
        data.append(cod[0])
    print(data)

    if int(user_code):
        if int(user_code) in data:
            try:
                if message.chat.id == int(user_code):
                    com = Base().read_tasks('tasks')
                    user_pay = InlineKeyboardMarkup()

                    sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                                url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
                    chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
                    promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
                    delete_task = InlineKeyboardButton(text='❌ Удалить задание', callback_data=filter.new('delete_task'))
                    user_pay.add(sale, chek_sale)
                    user_pay.add(promo)
                    user_pay.add(delete_task)
                    await message.answer(text='<b>Свой промокод использовать нельзя 😎</b>', reply_markup=user_pay)

                else:
                    code = Base().read_promocod('promocod', message.chat.id)
                    if int(user_code) in code:
                        com = Base().read_tasks('tasks')
                        user_pay = InlineKeyboardMarkup()
                        sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                                    url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
                        chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
                        promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
                        delete_task = InlineKeyboardButton(text='❌ Удалить задание',
                                                           callback_data=filter.new('delete_task'))
                        user_pay.add(sale, chek_sale)
                        user_pay.add(promo)
                        user_pay.add(delete_task)
                        await message.answer('❌ Извини но ты уже использовал этот код', reply_markup=user_pay)


                    else:
                        count = Base().read_user_pay_id('user_pay', user_code)
                        Base().update_user_pay('user_pay', user_code, int(count[1]) + 1)
                        await bot.send_message(chat_id=user_code, text=f'Твой промокод активировали у тебя бесплатных попыток: <b>{int(count[1])+1}</b>')
                        Base().add_promocod('promocod', message.chat.id, user_code)
                        id = Base().read_tasks('tasks')
                        await bot.send_message(chat_id=id[0], text='✅ Промокод активирован\n\n'
                                                                   '<b><pre>Ты находишься в закрытом чате с исполнителем напиши ему сообщение</pre></b>')

                        admins = Base().read_admin_p2p('admins')
                        for admin in admins:
                            if admin[1] == 1:
                                await bot.send_message(
                                    chat_id=admin[0],
                                    text='<b><pre>Ты находишься в закрытом чате с заказчиком напиши ему сообщение</pre></b>',
                                    reply_markup=stop_chat)
                                Base().update_task_id('tasks', True, id[0])

            except Exception as e:
                print(e)
                pass

        # если бот не нашел промокод в базе

        else:
            com = Base().read_tasks('tasks')
            user_pay = InlineKeyboardMarkup()

            sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                        url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
            chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
            promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
            delete_task = InlineKeyboardButton(text='❌ Удалить задание', callback_data=filter.new('delete_task'))
            user_pay.add(sale, chek_sale)
            user_pay.add(promo)
            user_pay.add(delete_task)
            await message.answer(text='❌ Извини но я нешел такой промокод', reply_markup=user_pay)


        await state.reset_state()

    else:
        com = Base().read_tasks('tasks')
        user_pay = InlineKeyboardMarkup()

        sale = InlineKeyboardButton(text='💵 Произвести оплату',
                                    url=f'https://qiwi.com/payment/form/99?blocked%5B0%5D=account&amountFraction=0&extra%5B%27account%27%5D=+79119009060&extra%5B%27comment%27%5D={com[1]}&amountInteger=100&blocked%5B1%5D=comment&cment&currency=RUB')
        chek_sale = InlineKeyboardButton(text='💎 Проверить оплату', callback_data=filter.new('chek_sale'))
        promo = InlineKeyboardButton(text='🔵 Использовать промокод', callback_data=filter.new('use_promo'))
        delete_task = InlineKeyboardButton(text='❌ Удалить задание', callback_data=filter.new('delete_task'))
        user_pay.add(sale, chek_sale)
        user_pay.add(promo)
        user_pay.add(delete_task)

        await message.answer(text='Извини но ты ввел но числовой код, промокоды только числа, попробуй снова', reply_markup=user_pay)
        await Promo.code.set()