示例#1
0
    async def check(self, message: types.Message):
        print('filter: isExecutor_and_higher')
        admins = db.select_id_users(status='admin')
        list_admins_id = []

        for item in admins:
            list_admins_id.append(item[0])

        print('filter: isExecutor_and_higher')
        changers = db.select_id_users(status='changer')
        list_changers_id = []

        for item in changers:
            list_changers_id.append(item[0])

        print('filter: isExecutor_and_higher')
        executors = db.select_id_users(status='executor')
        list_executors_id = []

        for item in executors:
            list_executors_id.append(item[0])

        return\
            message.from_user.id in super_admins or\
            message.from_user.id in list_admins_id or\
            message.from_user.id in list_changers_id or\
            message.from_user.id in list_executors_id
async def notify_about_permit_to_order(permit_numb, username):
    from loader import dp, db
    from data import emoji
    from utils import notify_someone

    kvz = emoji.all_emoji['квз']

    warning = f'УВЕДОМЛЕНИЕ\n{kvz}Новая заявка на пропуск{kvz}\nпропуск #N{permit_numb} заказал @{username}'

    await notify_someone(warning, 'admin')

    secretary = db.select_id_users(status='secretary')

    if not len(secretary) == 0:
        list_secretary_id = []

        for item in secretary:
            list_secretary_id.append(item[0])

        for user in list_secretary_id:
            await dp.bot.send_message(user, warning)

        return

    else:
        print('СЕКРЕТАРЕЙ НЕТ В БАЗЕ')

    return
示例#3
0
async def notify_someone_except_user(text, user_id, *args):
    '''
    *args - statuses of users. For ex.:
    notify_someone(text, 'admin', 'changer', 'operator', 'secretary')
    '''
    from loader import dp, db
    from data.config import super_admins

    groups = args

    for user in super_admins:
        if user != user_id:
            await dp.bot.send_message(user, text)

    for item in groups:
        group = db.select_id_users(status=item)

        if not len(group) == 0:
            list_group_id = []

            for some_item in group:
                list_group_id.append(some_item[0])

            for user in list_group_id:
                if user not in super_admins:
                    if user != user_id:
                        await dp.bot.send_message(user, text)

    return
示例#4
0
    async def check(self, message: types.Message):
        print('filter: IsAdmin')
        admins = db.select_id_users(status='admin')
        list_admins_id = []

        for item in admins:
            list_admins_id.append(item[0])

        return message.from_user.id in list_admins_id or message.from_user.id in super_admins
示例#5
0
    async def check(self, message:types.Message):
        print('filter: BlokedUser')
        bloked_users = db.select_id_users(status='block')
        list_bloked_id = []

        for item in bloked_users:
            list_bloked_id.append(item[0])
        
        return message.from_user.id in list_bloked_id
示例#6
0
    async def check(self, message:types.Message):
        print('filter: isAdmin_or_isChanger')
        admins = db.select_id_users(status='admin')
        list_admins_id = []

        for item in admins:
            list_admins_id.append(item[0])

        print('filter: isAdmin_or_isSecretary')
        changers = db.select_id_users(status='secretary')
        list_changers_id = []

        for item in changers:
            list_changers_id.append(item[0])
        

        return \
        message.from_user.id in list_admins_id or  \
        message.from_user.id in super_admins or  \
        message.from_user.id in list_changers_id
示例#7
0
async def notify_about_balance():
    from loader import dp, db, sheet
    from data.config import super_admins
    from data.config import group_chat

    balance_rub, balance_usd, balance_eur = sheet.get_balance_AEG3()

    warning = '❗️❗️❗️❗️❗️❗️\nДЛЯ ИСПОЛНЕНИЯ ВСЕХ ЗАЯВОК НЕ ХВАТАЕТ:\n'

    if int(balance_rub) < 0:
        balance_rub = abs(int(balance_rub))
        balance_rub = f'{balance_rub:,}'
        balance_rub = balance_rub.replace(',', '.')
        balance_rub = balance_rub + '₽'
        warning = warning + balance_rub + ' '

    if int(balance_usd) < 0:
        balance_usd = abs(int(balance_usd))
        balance_usd = f'{balance_usd:,}'
        balance_usd = balance_usd.replace(',', '.')
        balance_usd = balance_usd + '$'
        warning = warning + balance_usd + ' '

    if int(balance_eur) < 0:
        balance_eur = abs(int(balance_eur))
        balance_eur = f'{balance_eur:,}'
        balance_eur = balance_eur.replace(',', '.')
        balance_eur = balance_eur + '€'
        warning = warning + balance_eur

    if warning == '❗️❗️❗️❗️❗️❗️\nДЛЯ ИСПОЛНЕНИЯ ВСЕХ ЗАЯВОК НЕ ХВАТАЕТ:\n':

        return

    else:
        warning = warning + '\n❗️❗️❗️❗️❗️❗️'
        await dp.bot.send_message(group_chat, warning)

        admins = db.select_id_users(status='admin')
        change = db.select_id_users(status='changer')

        if not len(super_admins) == 0:
            for user in super_admins:
                await dp.bot.send_message(user, warning)

        if not len(admins) == 0:
            list_admins_id = []

            for item in admins:
                list_admins_id.append(item[0])

            for user in list_admins_id:
                await dp.bot.send_message(user, warning)

        if not len(change) == 0:
            list_changers_id = []

            for item in change:
                list_changers_id.append(item[0])

            for user in list_changers_id:
                await dp.bot.send_message(user, warning)

    return
async def notify_about_cancel_request(request, username, user_id):
    from emoji import emojize
    
    from loader import bot, db
    from data.config import super_admins


    emo_issuing_office = emojize(':office:', use_aliases=True)    
    emo_cash_recive = emojize(':chart_with_upwards_trend:', use_aliases=True)
    emo_delivery = emojize(':steam_locomotive:', use_aliases=True)
    emo_exchange = emojize(':recycle:', use_aliases=True)
    emo_cash_in = emojize(':atm:', use_aliases=True)
    emo_cash_atm = emojize(':credit_card:', use_aliases=True)

    emo_request = {
        'выдача в офисе': emo_issuing_office,
        'прием кэша': emo_cash_recive,
        'доставка': emo_delivery,
        'обмен': emo_exchange,
        'кэшин': emo_cash_in,
        'снятие с карт': emo_cash_atm,
    }

    type_operation = emo_request[request[3]]
    number_request = request[2]
    date_request = request[0]

    warning = f'Заявка {type_operation} #N{number_request} от {date_request} была отменена. Отменил - {username}'

    admins = db.select_id_users(status='admin')
    change = db.select_id_users(status='changer')

    if not len(super_admins) == 0:
        for user in super_admins:
            if user == user_id:
                pass
            else:
                await bot.send_message(user, warning)

    if not len(admins) == 0:
        list_admins_id = []

        for item in admins:
            list_admins_id.append(item[0])

        for user in list_admins_id:
            if user == user_id:
                pass
            else:
                await bot.send_message(user, warning)

    if not len(change) == 0:
        list_changers_id = []

        for item in change:
            list_changers_id.append(item[0])

        for user in list_changers_id:
            if user == user_id:
                await bot.send_message(user, warning)

    return