from app.create_lessons_time_list import create_list
from app.messages import error_message

# Статистика
from app.statistic import track


def lessons_time_list(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'lessons_time_list')

    try:
        message = create_list()

        if len(message) == 0:
            message = 'Похоже времени начала и окончания пар ещё нет в базе'

    except BaseException as e:
        app.logger.warning('lessons_time_list: {}'.format(str(e)))
        return error_message, '', ''
    return message, '', ''


lessons_time_list_command = command_system.Command()

lessons_time_list_command.keys = [
    'время занятий', 'время', '/lessons_time', 'lessons_time', '/time', 'time'
]
lessons_time_list_command.description = 'Выводит время начала и окончания пар'
lessons_time_list_command.process = lessons_time_list
Example #2
0
from flask import current_app as app
from app import command_system
from app.scheduledb import ScheduleDB
from app.messages import error_message, report_help_message, report_ok_message

# Статистика
from app.statistic import track


def report(uid, key, arg=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, arg, 'report')

    if arg != '':
        with ScheduleDB(app.config) as db:
            if db.add_report(uid, arg):
                return report_ok_message, '', ''
            else:
                return error_message, '', ''
    else:
        return report_help_message, '', ''


report_command = command_system.Command()

report_command.keys = ['отзыв', 'поддержка', 'репорт', '/report', 'report', '/send_report', 'send_report']
report_command.description = 'Можно отправить информацию об ошибке или что то ещё. ' \
                             'Введите команду(без кавычек): отзыв <ваше сообщение>'
report_command.process = report
Example #3
0
from app.messages import error_message, start_message

# Статистика
from app.statistic import track


def start(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'start')

    # Если пользователя нет в базе, то ему выведет предложение зарегистрироваться
    try:
        is_registered, message, user = registration_check(uid)

        if not is_registered:
            return start_message, '', get_main_keyboard(is_registered=False)
        else:
            return start_message, '', get_main_keyboard(is_registered=True)
    except BaseException as e:
        app.logger.warning('start: {}'.format(str(e)))
        return error_message, '', ''


start_command = command_system.Command()

start_command.keys = [
    'старт', '/start', 'start', 'привет', 'здравствуй', 'начать'
]
start_command.description = 'Выводит стартовое сообщение'
start_command.process = start
Example #4
0
from flask import current_app as app
from app import command_system

# Статистика
from app.statistic import track


def help(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'help')

    message = 'Список команд:\n'

    for c in command_system.command_list:
        message += '{}: {}\n\n'.format(c.keys[0], c.description)

    return message, '', ''


help_command = command_system.Command()

help_command.keys = ['помощь', 'команды', '/help', 'help']
help_command.description = 'Выводит информацию о боте и список доступных команд'
help_command.process = help
Example #5
0
                ap_type = 'Не установлено'
            else:
                faculty = ' '.join(str(
                    info[1]).split()) if len(info) >= 2 else 'Пусто'
                group = ' '.join(str(
                    info[2]).split()) if len(info) >= 3 else 'Пусто'

                if len(info) >= 5 and info[3] is not None:
                    ap_time = str(
                        info[3]) if info[3] is not None else 'Не установлено'
                    ap_type = 'На сегодня' if info[4] else 'На завтра'
                else:
                    ap_time = 'Не установлено'
                    ap_type = 'Не установлено'

            message = '{}\n{}: {}\n{}: {}\n{}: {}\n{}: {}'.format(
                user_info_title_message, user_info_faculty_message, faculty,
                user_info_group_message, group, user_info_ap_time_message,
                ap_time, user_info_ap_type_message, ap_type)
            return message, '', get_user_info_keyboard(is_registered=True)
    except BaseException as e:
        app.logger.warning('user_info: {}'.format(str(e)))
        return error_message, '', ''


user_info_command = command_system.Command()

user_info_command.keys = ['личный кабинет', '/user_info', 'user_info']
user_info_command.description = 'Личный кабинет'
user_info_command.process = user_info
Example #6
0
        if len(organizations) != 0:
            if organizations[0][2] > 0.8:
                message = 'Вы зарегистрированны в: {}'.format(
                    organizations[0][1])
            else:
                message = 'Вы зарегистрированны в наиболее совпадающей с запросом группе: {}\n-----\nДругие похожие:\n'.format(
                    organizations[0][1])
                for org in organizations:
                    message += "{}\n".format(org[1])

            with ScheduleDB(app.config) as db:
                user = db.find_user(uid)
                if user:
                    db.update_user(uid, " ", " ", organizations[0][0])
                else:
                    db.add_user(uid, " ", " ", organizations[0][0])
            message += '\n\n Напишите "помощь", чтобы узнать доступные команды'

            return message
        else:
            return 'Случилось что то странное, попробуйте ввести команду заново'
    except BaseException as e:
        return 'Случилось что то странное, попробуйте ввести команду заново'


registration_command = command_system.Command()

registration_command.keys = ['регистрация', '/registration', 'registration']
registration_command.description = 'Введите команду(без кавычек): регистрация "название вуза" "факультет" "группа"'
registration_command.process = registration
Example #7
0
from app.helpers import registration_check
from app.messages import error_message, settings_message

# Статистика
from app.statistic import track


def settings(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'settings')

    try:
        is_registered, message, user = registration_check(uid)

        if not is_registered:
            return settings_message, '', get_settings_keyboard(
                is_registered=False)
        else:
            return settings_message, '', get_settings_keyboard(
                is_registered=True)
    except BaseException as e:
        app.logger.warning('settings: {}'.format(str(e)))
        return error_message, '', ''


settings_command = command_system.Command()

settings_command.keys = ['настройки', '/settings', 'settings']
settings_command.description = 'Настройки'
settings_command.process = settings
            if difflib.SequenceMatcher(None, type, 'сегодня').ratio() > \
                    difflib.SequenceMatcher(None, type, 'завтра').ratio() or type == '':
                is_today = True
            else:
                is_today = False

            # Проверка на соответствие введённых пользователем данных принятому формату
            if not hour.isdigit() or not minutes.isdigit():
                return auto_posting_on_help_message, '', ''

            if db.set_auto_post_time(uid,
                                     (hour + ":" + minutes + ":" + "00").rjust(
                                         8, '0'), is_today):
                return 'Время установлено', '', ''
            else:
                return error_message, '', ''
    except BaseException as e:
        app.logger.warning('auto_posting_on: {}'.format(str(e)))
        return error_message, '', ''


auto_posting_on_command = command_system.Command()

auto_posting_on_command.keys = [
    'рассылка', 'ap', 'ар', 'автопостинг', '/auto_posting_on',
    'auto_posting_on'
]
auto_posting_on_command.description = 'Включение и выбор времени для автоматической отправки расписания в диалог, ' \
                                      'время должно иметь формат ЧЧ:ММ'
auto_posting_on_command.process = auto_posting_on
Example #9
0
        days = [helpers.daysOfWeek[datetime.weekday(tomorrow)]]
    else:
        days = [helpers.ScheduleType[key]]

    for day in days:
        try:
            with ScheduleDB(app.config) as db:
                user = db.find_user(uid)
            if user and user[0] != '':
                result = create_schedule_text(user[0], day, week_type)
                for schedule_message in result:
                    message += schedule_message + "\n\n"
            else:
                message = "Вас ещё нет в базе данных, поэтому пройдите простую процедуру регистрации:\n"
                message += 'Введите команду(без кавычек): регистрация "название вуза" "факультет" "группа"\n\n'
                message += 'Если вы допустите ошибку, то просто наберите команду заново.\n'
        except BaseException as e:
            message = "Случилось что то странное, попробуйте ввести команду заново"
    return message


schedule_command = command_system.Command()

schedule_command.keys = [
    'расписание', 'неделя', 'сегодня', 'завтра', 'понедельник', 'вторник',
    'cреда', 'четверг', 'пятница', 'cуббота', 'воскресенье'
]
schedule_command.description = 'Выводит расписание, также можно написать любой день недели или команду "сегодня" или "завтра"'
schedule_command.process = schedule
Example #10
0
from flask import current_app as app
from app import command_system
from app.helpers import get_other_keyboard
from app.messages import resources_message

# Статистика
from app.statistic import track


def resources(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'resources')

    return resources_message, '', get_other_keyboard()


resources_command = command_system.Command()

resources_command.keys = ['ресурсы', '/resources', 'resources']
resources_command.description = 'Ресурсы'
resources_command.process = resources
Example #11
0
from app import command_system
from app.helpers import get_main_keyboard
from app.helpers import registration_check
from app.messages import back_message, error_message

# Статистика
from app.statistic import track


def back(uid, key, data=''):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'back')

    # Если пользователя нет в базе, то ему выведет предложение зарегистрироваться
    try:
        is_registered, message, user = registration_check(uid)
        if not is_registered:
            return back_message, '', get_main_keyboard(is_registered=False)
        else:
            return back_message, '', get_main_keyboard(is_registered=True)
    except BaseException as e:
        app.logger.warning('back: {}'.format(str(e)))
        return error_message, '', ''


back_command = command_system.Command()

back_command.keys = ['назад', '/back', 'back']
back_command.description = 'Возвращение в главное меню'
back_command.process = back
Example #12
0
from flask import current_app as app
from app import command_system
from app.helpers import get_other_keyboard
from app.messages import other_message

# Статистика
from app.statistic import track


def other(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'other')

    return other_message, '', get_other_keyboard()


other_command = command_system.Command()

other_command.keys = ['прочее', '/other', 'other']
other_command.description = 'Прочее'
other_command.process = other
Example #13
0
from flask import current_app as app
from app import command_system
from app.helpers import get_other_keyboard
from app.messages import faq_message

# Статистика
from app.statistic import track


def faq(uid, key, data=""):
    # Статистика
    track(app.config['STATISTIC_TOKEN'], uid, key, 'faq')

    return faq_message, '', get_other_keyboard()


faq_command = command_system.Command()

faq_command.keys = ['faq', '/faq']
faq_command.description = 'FAQ'
faq_command.process = faq
Example #14
0
        is_registered, message, user = registration_check(uid)
        if not is_registered:
            return message, '', ''

        with ScheduleDB(app.config) as db:
            exams_list = db.get_exams(user[0])

        message = ''
        for exam in exams_list:
            message += exam[0].strftime('%d.%m.%Y') + ":\n"

            title = ' '.join(str(exam[1]).split())
            lecturer = ' '.join(str(exam[2]).split())
            classroom = ' '.join(str(exam[3]).split())

            message += title + ' | ' + lecturer + ' | ' + classroom + "\n"
            message += "------------\n"
        if len(message) == 0:
            message = 'Похоже расписания экзаменов для вашей группы нет в базе'
    except BaseException as e:
        app.logger.warning('exams: {}'.format(str(e)))
        return error_message, '', ''
    return message, '', ''


exams_command = command_system.Command()

exams_command.keys = ['экзамены', 'экзамен', '/exams', 'exams']
exams_command.description = 'Выводит список экзаменов'
exams_command.process = exams