diff --git a/bot/callbacks.go b/bot/callbacks.go index c700929..10e2418 100644 --- a/bot/callbacks.go +++ b/bot/callbacks.go @@ -44,7 +44,7 @@ func lecturesCallback(bot *tgbotapi.BotAPI, update *tgbotapi.Update, callback_te timetableKey := callback_text[len("lectures_"):strings.Index(callback_text, "_y_")] timetable := model.Timetables[timetableKey] - response, err := commands.GetTimeTable(timetable.Type, timetable.Name, timetable.Curriculum, year, timeForLectures) + response, err := commands.GetTimeTable(timetable.Type, timetable.Name, timetable.Curriculum, timetable.Url, year, timeForLectures) if err != nil { log.Printf("Error [GetTimeTable]: %s\n", err) } diff --git a/commands/uni.go b/commands/uni.go index 128ffb5..ecc74b2 100644 --- a/commands/uni.go +++ b/commands/uni.go @@ -50,9 +50,11 @@ func (t *LezioniTime) UnmarshalJSON(data []byte) error { // GetTimeTable returns an HTML string containing the timetable for the given // course on the given date. Returns an empty string if there are no lessons. -func GetTimeTable(courseType, courseName string, curriculum string, year int, day time.Time) (string, error) { +func GetTimeTable(courseType, courseName string, curriculum string, url string, year int, day time.Time) (string, error) { interval := &timetable.Interval{Start: day, End: day} + // FIXME: after the edit on unibo-go the line below will be valid + // events, err := timetable.FetchTimetable(courseType, courseName, curriculum, url, year, interval) events, err := timetable.FetchTimetable(courseType, courseName, curriculum, year, interval) if err != nil { log.Printf("Error getting timetable: %s\n", err) diff --git a/commands/uni_test.go b/commands/uni_test.go index e0c2507..ecc33db 100644 --- a/commands/uni_test.go +++ b/commands/uni_test.go @@ -107,6 +107,7 @@ func TestGetTimeTable(t *testing.T) { year int day time.Time curriculum string + url string } tests := []struct { name string @@ -146,7 +147,7 @@ func TestGetTimeTable(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := GetTimeTable(tt.args.courseType, tt.args.courseName, tt.args.curriculum, tt.args.year, tt.args.day) + got, err := GetTimeTable(tt.args.courseType, tt.args.courseName, tt.args.curriculum, tt.args.url, tt.args.year, tt.args.day) if err != nil && !tt.error { t.Errorf("GetTimeTable() error = %v", err) return @@ -164,7 +165,7 @@ func TestGetTimeTable(t *testing.T) { func TestWeekend(t *testing.T) { date := time.Date(2023, 3, 11, 0, 0, 0, 0, time.UTC) - result, err := GetTimeTable("laurea", "informatica", "", 1, date) + result, err := GetTimeTable("laurea", "informatica", "", "orario-lezioni", 1, date) if err != nil { t.Fatalf("Error while getting timetable: %s", err) } diff --git a/model/model.go b/model/model.go index 6f92e0e..466c890 100644 --- a/model/model.go +++ b/model/model.go @@ -109,8 +109,9 @@ type Curriculum struct { type Timetable struct { Course string `json:"course"` // Course title Name string `json:"name"` // Course name - Type string `json:"type"` // Type (laurea|magistrale) + Type string `json:"type"` // Type (laurea|magistrale|2cycle) Curriculum string `json:"curricula"` // Curriculum + Url string `json:"url"` } // SECTION ACTION STRUCTS DATA