Skip to content

Commit efe0787

Browse files
improvements
1 parent d8494fb commit efe0787

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

internal/bot/tg_bot.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ func (b *TgBot) Start(_ context.Context, subjects []*internal.Subject) error {
6161
b.sendMessage(update.Message.Chat.ID, "Список команд: /start, /help, /schedule")
6262
case "schedule":
6363
args := strings.Fields(update.Message.Text)
64-
if len(args) < 3 {
65-
b.sendMessage(update.Message.Chat.ID, "Введите команду в формате: /schedule <Институт> <Группа>")
64+
if len(args) != 2 {
65+
b.sendMessage(update.Message.Chat.ID, "Введите команду в формате: /schedule <Группа>")
6666
return
6767
}
68-
instituteFilter := args[1]
69-
groupFilter := args[2]
70-
b.handleSchedule(update.Message.Chat.ID, instituteFilter, groupFilter)
68+
groupFilter := args[1]
69+
b.handleSchedule(update.Message.Chat.ID, groupFilter)
7170
default:
7271
b.sendMessage(update.Message.Chat.ID, "Неизвестная команда. Введите /help.")
7372
}
@@ -82,15 +81,10 @@ func (b *TgBot) Start(_ context.Context, subjects []*internal.Subject) error {
8281
return nil
8382
}
8483

85-
func (b *TgBot) handleSchedule(chatID int64, instituteFilter, groupFilter string) {
86-
// TODO: ИТКН и ИКН - один институт, был ребрендинг ;-)
87-
if instituteFilter == "ИТКН" {
88-
instituteFilter = "ИКН"
89-
}
90-
84+
func (b *TgBot) handleSchedule(chatID int64, groupFilter string) {
9185
message := "Расписание пересдач:\n"
9286
for _, subj := range b.subjects {
93-
if !(subj.Institute == instituteFilter && subj.Group == groupFilter) {
87+
if subj.Group != groupFilter {
9488
continue
9589
}
9690
message += b.constructSubjectMsg(subj)

internal/parser/excel_parser.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ func (p *ExcelParser) Parse() ([]*internal.Subject, error) {
5151
subjChan := make(chan *subject)
5252
wg := &sync.WaitGroup{}
5353
for _, filePath := range files {
54-
if filePath != "retakes/obektno-orientirovannoe-programmirovanie.xlsx" {
55-
continue
56-
}
5754
wg.Add(1)
5855
go func(filePath string) {
5956
defer wg.Done()

internal/parser/models.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,8 @@ var (
132132
validCommentFields = map[string]struct{}{
133133
"Примечание": {},
134134
}
135+
136+
baseDisciplines = map[string]struct{}{
137+
"Математика": {},
138+
}
135139
)

internal/parser/usecase.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ func (s *subject) validate() error {
4545
}
4646
}
4747
if !found {
48-
return fmt.Errorf("subject has unknown group")
48+
if s.discipline != nil {
49+
if _, ok := baseDisciplines[*s.discipline]; ok {
50+
return nil
51+
}
52+
}
53+
return fmt.Errorf("subject has unknown group: %s", string(*s.group))
4954
}
5055

5156
return nil

retakes/matan.xlsx

11.6 KB
Binary file not shown.

retakes/matematika_3-kurs.xlsx

-11.5 KB
Binary file not shown.
-10.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)