Beispiel #1
0
    bot_link = f"https://t.me/{bot_username}?start={chat_id}"
    await message.answer(text=
            f"{message.from_user.first_name}!\n"
            f"Ваша реферальная ссылка на сайт aeremins.ru/ref={chat_id}\n"
            f"Ваша реферальная ссылка для приглашений: {bot_link}\n"
            f"Проверить рефералов можно по команде: Мои рефералы 👥\n"
            f"Посмотреть баланс: Мой баланс 💵\n"
            f"Ответы на вопросы: FAQ 📖\n"
            f"Вывести деньги: Вывести деньги 💳\n"
            f"Страна: интернет-магазина Украина\n"
            f"Доставка не осуществляется в Донецкую и Луганскую области",
                         reply_markup=menu
                         )


@dp.message_handler(Text(equals=["Мои рефералы 👥"]))
async def get_button(message: Message):
    file_words = open(f"dictionaries/{message.chat.id}ref.txt", 'a')
    with open(f"dictionaries/{message.chat.id}ref.txt") as file:  # Открываем для чтения
        read_words = [row.strip() for row in file]  # Записываем в массив
    new_words = []
    if len(read_words) == 0:
        await message.answer(f'У вас еще нет рефералов')
    else:
        [new_words.append(item) for item in read_words if item not in new_words]  # Фильтруем, чтобы не было схожих слов

        a = "\n".join(new_words)
        print(a)

        await message.answer(f'Ваши рефералы:\n{a}')
Beispiel #2
0
                                              "Ваше ПІБ: {}\n"
                                              "Стан послуги: {}\n"
                                              "Ваш пакет: {}").format(
                database.data[0], database.data[1], database.data[2], database.data[3], net_off, database.data[5]),
                reply_markup=client_request)
            await db.message("BOT", 10001, msg.html_text, msg.date)

    else:
        msg = await message.answer(
            text=_("Вказаний номер телефону не знайдено у нашому білінгу\n"
                   "Якщо ви бажаєте підключитися - залиште заявку на підключення натиснувши кнопку"),
            reply_markup=unknown_request_button)
        await db.message("BOT", 10001, msg.html_text, msg.date)


@dp.message_handler(Text(equals=["Головне меню", "Главное меню", "Main menu"]))
async def main_menu(message: types.Message):
    await db.message(message.from_user.full_name, message.from_user.id, message.text, message.date)
    tel = await db.select_tel(user_id=message.from_user.id)
    await database.search_query(tel)
    try:
        await db.set_contract(database.data[2], message.from_user.id)
    except IndexError:
        pass
    net_on = __("Увімкнено")
    net_off = __("Вимкнено")
    if len(database.data) > 0:
        if await database.check_net_pause(database.data[2]) is True and database.data[4] == "on":
            msg = await message.answer(text=_("Ваш username: {}\n"
                                              "На вашому рахунку: {}\n"
                                              "Ваш номер договору: {}\n"
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.builtin import Text
from re import *

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback
from loader import dp, bot
from states.user_mes import UserMes
from utils.db_api.models import messagesCouponModel, banListModel, userInformationModel
from utils.notify_admins import notify_admins_message
from utils import function
from utils.telegram_files import TelegramFiles


@dp.message_handler(Text(equals=["Написать администрации", "/ames"]))
async def start_write_administration(message: types.Message,
                                     state: FSMContext):
    if banListModel.is_ban_user(message.from_user.id):
        await message.answer("Вы забанены")
        return
    keyboard = None
    lastMessage = messagesCouponModel.get_last_message_day_user(
        message.from_user.id)
    if lastMessage and len(lastMessage) >= 20:
        mes = config.message["increased_requests"]
    elif lastMessage and lastMessage[len(lastMessage) -
                                     1].date > time.time() - 60 * 30:
        mes = config.message["repeat_requests"].format(
            min=int((lastMessage[len(lastMessage) - 1].date -
                     (time.time() - 60 * 30)) / 60))
Beispiel #4
0
from aiogram import types
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback, numbering_callback
from loader import dp, bot
from states.admin_close_order_pr import AdminCloseOrderPr
from states.admin_pr_mes import AdminPrMes
from states.admin_price_order import AdminPriceOrder
from utils.db_api.models import ordersProcessingModel, paymentModel
from utils import function


@dp.message_handler(Text(equals=["Заказы на рассмотрении", "/orderspr"]),
                    user_id=config.ADMINS)
async def show_orders(message: types.Message):
    mes, keyboard = await menu_main(0)
    await message.answer(text=mes, reply_markup=keyboard)


@dp.callback_query_handler(
    numbering_callback.filter(what_action="OrderProcessingNumbering"),
    user_id=config.ADMINS)
async def close_order_button(call: types.CallbackQuery, callback_data: dict):
    mes, keyboard = await menu_main(int(callback_data["number"]))
    try:
        await call.message.edit_text(text=mes, reply_markup=keyboard)
    except:
        await call.answer(cache_time=1)
Beispiel #5
0
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback
from loader import dp, bot
from states.admin_create_department import DepartmentAdd
from states.admin_edit_department import DepartmentEdit
from utils.db_api.models import departmentModel
from utils import function
from utils.yandex_disk import YandexDisk

### Информация о заказах ###


@dp.message_handler(Text(equals=["Отделы", "/departments"]),
                    user_id=config.ADMINS)
async def show_orders(message: types.Message):
    departments = departmentModel.get_all_departments()
    if departments:
        text = ""
        num = 1
        for item in departments:
            staffInfo = ""
            for employee in item.staff:
                try:
                    user = await bot.get_chat(employee)
                    staffInfo += config.adminMessage[
                        "department_info_staff"].format(name=user.full_name,
                                                        id=employee)
                except:
from aiogram import types
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback, numbering_callback
from loader import dp, bot
from states.admin_mes_user import AdminMesUser
from utils.db_api.models import messagesCouponModel
from utils import function
from utils.telegram_files import TelegramFiles


@dp.message_handler(Text(equals=["Сообщения от пользователей", "/mes"]),
                    user_id=config.ADMINS)
async def all_messages(message: types.Message):
    mes, keyboard = await menu_main(0)
    await message.answer(text=mes, reply_markup=keyboard)


@dp.callback_query_handler(
    numbering_callback.filter(what_action="messagesUserNumbering"),
    user_id=config.ADMINS)
async def close_order_button(call: types.CallbackQuery, callback_data: dict):
    mes, keyboard = await menu_main(int(callback_data["number"]))
    try:
        await call.message.edit_text(text=mes, reply_markup=keyboard)
    except:
        await call.answer(cache_time=1)
Beispiel #7
0
 def test_validate(self, param, key):
     value = 'spam and eggs'
     config = {param: value}
     res = Text.validate(config)
     assert res == {key: value}
Beispiel #8
0
# -*- coding: utf-8 -*-

from aiogram import types
from aiogram.dispatcher.filters.builtin import Text
from aiogram.types import InlineQuery

import config
from keyboards import inline_kb
from loader import dp
from utils.db_api import mscenter_table, all_city_names


@dp.inline_handler(Text(all_city_names, ignore_case=True))
async def show_msc_in_city(query: InlineQuery):
    city = query.query.title()
    answer = await create_answer(city)

    await query.answer(results=[
        types.InlineQueryResultArticle(
            id="unknown",
            thumb_url=
            "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/160/apple/96/hospital_1f3e5.png",
            title=f"🏥 РС-центры в городе: {city}",
            input_message_content=types.InputMessageContent(
                message_text=answer, parse_mode="Markdown"))
    ], )


@dp.inline_handler(regexp="\w")
async def show_msc(query: InlineQuery):
    city: str = query.query.title()
Beispiel #9
0
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback, numbering_callback
from loader import dp
from states.admin_create_promoCode import CodeAdd
from states.admin_edit_promoCode import CodeEdit
from utils.db_api.models import promoCodesModel
from utils import function

### Информация о промокодах ###


@dp.message_handler(Text(equals=["Промокоды", "/codes"]),
                    user_id=config.ADMINS)
async def show_codeList(message: types.Message):
    mes, keyboard = await menu_main(0)
    await message.answer(text=mes, reply_markup=keyboard)


@dp.callback_query_handler(
    numbering_callback.filter(what_action="PromoCodeNumbering"),
    user_id=config.ADMINS)
async def close_order_button(call: types.CallbackQuery, callback_data: dict):
    mes, keyboard = await menu_main(int(callback_data["number"]))
    try:
        await call.message.edit_text(text=mes, reply_markup=keyboard)
    except:
        await call.answer(cache_time=1)
Beispiel #10
0
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback, numbering_callback
from loader import dp, bot
from states.admin_close_order import AdminCloseOrder
from states.admin_mes_order import AdminMesOrder
from utils.db_api.models import orderModel, tasksModel, paymentModel
from utils import function

### Информация о заказах ###
from utils.telegram_files import TelegramFiles


@dp.message_handler(Text(equals=["Заказы", "/orders"]), user_id=config.ADMINS)
async def show_orders(message: types.Message):
    mes, keyboard = await menu_main(0)
    await message.answer(text=mes, reply_markup=keyboard)


@dp.callback_query_handler(
    numbering_callback.filter(what_action="OrderNumbering"),
    user_id=config.ADMINS)
async def close_order_button(call: types.CallbackQuery, callback_data: dict):
    mes, keyboard = await menu_main(int(callback_data["number"]))
    try:
        await call.message.edit_text(text=mes, reply_markup=keyboard)
    except:
        await call.answer(cache_time=1)
Beispiel #11
0
@dp.message_handler(CommandHelp())
async def bot_help(message: types.Message):
    print(message.from_user.id)
    await message.answer(config.message["Help_Menu"])


@dp.message_handler(commands=["menu"])
async def show_menu(message: types.Message):
    await message.answer(config.message["Main_Menu"], reply_markup=menu)


@dp.message_handler(commands=["about"])
async def show_menu(message: types.Message):
    await message.answer(config.message["About_Us"], reply_markup=menu)


@dp.message_handler(Text(equals=["О нас"]))
async def show_about(message: types.Message):
    await message.answer(config.message["About_Us"], reply_markup=menu)


@dp.message_handler(commands=["Ukeyboard"])
async def show_help(message: types.Message):
    await message.answer(config.adminMessage["help"], reply_markup=menu)


@dp.message_handler(Text(equals=["Использовать скидку"]))
async def show_product(message: types.Message):
    await message.answer(config.message["use_discount"])
from aiogram.dispatcher.filters.builtin import Text
from aiogram.types import Message, ReplyKeyboardRemove
from keyboards.default import main_menu
from loader import dp, bot
from aiogram.dispatcher import FSMContext
from states.botStates import StatesOfBot
from keyboards.inline import setup_button_inline, setup_callback


@dp.message_handler(Text(equals=["Студент", "Преподаватель"]),
                    state=StatesOfBot.start_state)
async def accept_groups(message: Message, state: FSMContext):
    await message.answer(f"Вы {message.text}. Переходите к следующему пункту",
                         reply_markup=ReplyKeyboardRemove())

    await message.answer(
        f"Введите название вашей группы, скопировав из списка\n"
        "Например 2ИС-2")

    file_name_group = open('handlers/users/name_groups.txt')
    await bot.send_document(chat_id=message.chat.id, document=file_name_group)
    file_name_group.close()

    await StatesOfBot.who_you_are_state.set()


@dp.message_handler(state=StatesOfBot.who_you_are_state)
async def search_groups(message: Message, state: FSMContext):
    # await message.answer(f"main_menu state. welcome ~/")
    await message.answer(message.text)
    data_file = []
Beispiel #13
0
from loader import dp, db

from aiogram.dispatcher.filters.builtin import Text
from aiogram import types
from aiogram.types import ReplyKeyboardMarkup, KeyboardButton

from middlewares import _, __
from keyboards.default.buttons import lang_change


@dp.message_handler(Text(equals=__("Змінити мову")))
async def change_lang(message: types.Message):
    await db.message(message.from_user.full_name, message.from_user.id,
                     message.text, message.date)
    msg = await message.answer(text=_("Оберіть мову"),
                               reply_markup=lang_change)
    await db.message("BOT", 10001, msg.html_text, msg.date)


@dp.message_handler(Text(equals=["🇷🇺 RU", "🇺🇸 EN", "🇺🇦 UA"]))
async def changed_lang(message: types.Message):
    await db.message(message.from_user.full_name, message.from_user.id,
                     message.text, message.date)
    await db.set_lang(message.text[3:].lower(), message.from_user.id)
    if message.text[3:] == "UA":
        return_button = ReplyKeyboardMarkup(
            resize_keyboard=True,
            keyboard=[[KeyboardButton(text="Головне меню")]],
            one_time_keyboard=True)
    elif message.text[3:] == "EN":
        return_button = ReplyKeyboardMarkup(
Beispiel #14
0
@dp.message_handler(CommandStart())
async def bot_start(message: types.Message):
    await message.answer(f'Привет, {message.from_user.full_name}')
    name = message.from_user.full_name
    try:
        db.add_user(id=message.from_user.id, name=name)
    except sqlite3.IntegrityError as err:
        print(err)
    if message.from_user.id in ADMIN_IDS:
        reply_markup = admin_button
    else:
        reply_markup = movie
    await message.answer('Стартуем', reply_markup=reply_markup)


@dp.message_handler(Text('Рандомный сериал'))
async def random_serial(message: types.Message):
    list_of_serial = db_c.random_serial_from_db()
    name_of_content = list_of_serial[1]
    overview_of_content = list_of_serial[2]
    picture = list_of_serial[3]
    await message.answer_photo(
        caption=f'<b>{name_of_content}</b>\n\n{overview_of_content}',
        photo=picture)


@dp.message_handler(IsAdmin(), Text('Добавить сериал'))
async def adm_button(message: types.Message):
    await message.answer("Добавляем новый сериал",
                         reply_markup=new_serial_button)
Beispiel #15
0
async def bot_help(message: types.Message):
    print(message.from_user.id)
    await message.answer(config.message["Help_Menu"])


@dp.message_handler(commands=["menu"])
async def show_menu(message: types.Message):
    await message.answer(config.message["Main_Menu"], reply_markup=menu)


@dp.message_handler(commands=["items"])
async def show_menu(message: types.Message):
    await message.answer(config.message["Product_Menu"], reply_markup=await buttons.getTypeWorkKeyboard())


@dp.message_handler(Text(equals=["Список предметов"]))
async def show_product(message: types.Message):
    await message.answer(config.message["Product_Menu"], reply_markup=await buttons.getTypeWorkKeyboard())


@dp.message_handler(commands=["about"])
async def show_menu(message: types.Message):
    await message.answer(config.message["About_Us"], reply_markup=menu)


@dp.message_handler(Text(equals=["О нас"]))
async def show_about(message: types.Message):
    await message.answer(config.message["About_Us"], reply_markup=menu)


@dp.message_handler(commands=["Ukeyboard"])
Beispiel #16
0
    except asyncpg.exceptions.UniqueViolationError:
        user = await db.select_single_user(telegram_id=message.from_user.id)

    count_users = await db.count_users()
    print(count_users)

    # await db.add_user(message.from_user.full_name,message.from_user.username,message.from_user.id)
    await message.answer(
        f"Привет, <b>{message.from_user.full_name}</b>!\nЯ создан, специально для того"
        f" чтобы помочь вам с вашими вопросами, просто выберите один из пунктов меню ниже,"
        f" и мы постараемся решить вашу проблему!",
        reply_markup=buttons_m)


# knopka odin
@dp.message_handler(Text("📃 Расписание"))
async def get_inst(message: types.Message):
    await message.answer(
        "Давайте поможем друг другу, перед вами список институтов, выберите нужный!",
        reply_markup=choice)


# perehod nazad na glavnoe menyu
@dp.message_handler(Text("Главное меню"))
async def choose_size(message):
    await bot_start(message)


#perehod obrantno na mneyu nizhe dlya metod_ukaz

#knopka 2
Beispiel #17
0
from aiogram import types
from aiogram.dispatcher.filters.builtin import Text
from aiogram.dispatcher import FSMContext
from keyboards.reply import choose_menu
from loader import dp


@dp.message_handler(state='*', commands='cancel')
@dp.message_handler(Text(equals='Bekor qilish', ignore_case=True), state='*')
async def cancel_handler(message: types.Message, state: FSMContext):
    """
    Allow user to cancel any action
    """
    current_state = await state.get_state()
    if current_state is None:
        await message.answer("Bekor qilinadigan hech narsa yoq!",
                             reply_markup=choose_menu())
        return
    await state.finish()
    await message.answer("Bekor qilindi!", reply_markup=choose_menu())
from aiogram import types
from aiogram.dispatcher import FSMContext
from aiogram.dispatcher.filters.builtin import Text

from data import config
from keyboards.inline import buttons
from keyboards.inline.callback_datas import confirmation_callback, action_callback, numbering_callback
from loader import dp, bot
from states.admin_mes_user import AdminMesUser
from utils.db_api.models import messagesModel
from utils import function
from utils.telegram_files import TelegramFiles


@dp.message_handler(Text(equals=["Сообщения от заказчиков", "/mesOrder"]),
                    user_id=config.ADMINS)
async def order_messages(message: types.Message):
    mes, keyboard = await menu_main(0, True)
    await message.answer(text=mes, reply_markup=keyboard)


@dp.callback_query_handler(
    numbering_callback.filter(what_action="messagesClientNumbering"),
    user_id=config.ADMINS)
async def close_order_button(call: types.CallbackQuery, callback_data: dict):
    mes, keyboard = await menu_main(int(callback_data["number"]), True)
    try:
        await call.message.edit_text(text=mes, reply_markup=keyboard)
    except:
        await call.answer(cache_time=1)