Exemplo n.º 1
0
    def _unset_indirect(
            date: datetime.date,
            sender: models.Person,
            recipient_listnum: int
            ):
        recipient = database.people.get_student_by_listnum(recipient_listnum)
        if not recipient:
            message = (
                f'InputError: при использовании конструкции "as STUDENT" '
                f'STUDENT должен быть целым числом и находиться в промежутке '
                f'[1, 25].'
            )
            bot.error(sender.id, message)
            return
        database.foodbot.set_eating(recipient, date, None)

        sender_listnum = sender.fields["list_number"]
        sender_message = (
            f'Ученик №{recipient_listnum} удален из списоков "Едят" и '
            f'"Не едят".'
        )
        bot.message(sender.id, sender_message)
        recipient_message = (
            f'Ученик №{sender_listnum} удалил вас из списоков "Едят" и '
            f'"Не едят".'
        )
        bot.message(recipient.id, recipient_message)
Exemplo n.º 2
0
    def _unset_direct(self, date: datetime.date, person: models.Person):
        if not self.has_required_tags(person):
            bot.error(person.id, 'TagError: вы не являетесь учеником.')
            return
        database.foodbot.set_eating(person, date, None)

        message = 'Вы удалены из списков "Едят" и "Не едят".'
        bot.message(person.id, message)
Exemplo n.º 3
0
    def _set_eating_direct(self, date: datetime.date, person: models.Person):
        if not self.has_required_tags(person):
            bot.error(person.id, 'TagError: вы не являетесь учеником.')
            return
        database.foodbot.set_eating(person, date, True)

        message = 'Вы добавлены в список "Едят".'
        bot.message(person.id, message)
Exemplo n.º 4
0
    def run(self, date: datetime.date, person: models.Person, args: List[str]):
        if args:
            message = (
                f'InputError: Команда "{self.keyword}" не может принимать '
                f'никакие аргументы.')
            bot.error(person.id, message)
            return

        eatings = database.foodbot.get_eatings(date)

        eating_list = list()
        not_eating_list = list()
        unset_list = list()

        for student, eating in eatings.items():
            if eating is None:
                unset_list.append(_repr_student(student))
            elif eating:
                eating_list.append(_repr_student(student))
            else:
                not_eating_list.append(_repr_student(student))

        message = (f'Дата: {_repr_date(date)}\n'
                   f'===-===-===-===-===\n'
                   f'\n'
                   f'Едят:\n'
                   f'{_repr_list(eating_list)}\n'
                   f'\n'
                   f'Не едят:\n'
                   f'{_repr_list(not_eating_list)}\n'
                   f'\n'
                   f'Не отметились:\n'
                   f'{_repr_list(unset_list)}\n'
                   f'\n'
                   f'===-===-===-===-===\n'
                   f'# Едят: {len(eating_list)}\n'
                   f'# Не едят: {len(not_eating_list)}\n'
                   f'# Не отметились: {len(unset_list)}\n')
        bot.message(person.id, message)
Exemplo n.º 5
0
    def run(self, date: datetime.date, person: models.Person, args: List[str]):
        if args:
            message = (
                f'InputError: Команда "{self.keyword}" не может принимать '
                f'никакие аргументы.')
            bot.error(person.id, message)
            return

        message = (
            f'Введите\n'
            f'- "{foodbot.SUPER_COMMAND} {foodbot.SetEatingCommand.keyword}", '
            f'чтобы попасть в список "Едят";\n'
            f'- "{foodbot.SUPER_COMMAND} {foodbot.SetNotEatingCommand.keyword}", '
            f'чтобы попасть в список "Не едят";\n'
            f'- "{foodbot.SUPER_COMMAND} {foodbot.UnsetCommand.keyword}", '
            f'чтобы удалить себя из обоих списков;\n'
            f'- "{foodbot.SUPER_COMMAND} {foodbot.ShowListCommand.keyword}", '
            f'чтобы получить списки "Едят" и "Не едят".\n'
            f'- "{foodbot.SUPER_COMMAND} {foodbot.ShowHelpCommand.keyword}", '
            f'чтобы вывести это сообщение."\n'
            f'\n'
            f'Добавьте "as STUDENT" к концу команды, чтобы выполнить ее от лица '
            f'другого ученика. STUDENT - это целое число в диапазоне [1, 25].')
        bot.message(person.id, message)