From f38fca44fbb9db1db5467a24b22ef561264ac55f Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 13:27:39 +0700 Subject: [PATCH 1/6] =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D0=BB=D0=B0=D0=B3?= =?UTF-8?q?=D0=B0=D1=8E=20=D1=82=D0=B0=D0=BA=D0=BE=D0=B9=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=BB=20=D1=81=20=D0=9D=D0=93=20=D1=81=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/messages.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/messages/messages.go b/messages/messages.go index c0bf6d3..ec45b5f 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -33,7 +33,7 @@ func HelpMessage(chatID int64) string { "- /ping отобью pong\n" + "- /today_lessons покажу расписание на сегодня\n" + "- /tomorrow_lessons покажу расписание на завтра\n" + - "- /all_lessons - пары на несколько дней\n" + + "- /all_lessons - пары на несколько дней\n" + "- /weather покажу погоду у универа\n" + "- /new_year - посчитаю количество дней до нового года\n" + "\nНу а больше я пока ничего не умею" + @@ -55,7 +55,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { } endDate := "" for _, l := range schedule { - if endDate != l.TimeStart.Format("02.01") { + if endDate != l.TimeStart.Format("02.01") { if endDate != "" { s += "\n" } @@ -67,16 +67,16 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { } l.Name = strings.ReplaceAll(l.Name, l.Place, "") l.Name = strings.ReplaceAll(l.Name, "()", "") - l.Name = strings.ReplaceAll(l.Name, l.TimeStart.Format("15:04"), "") + l.Name = strings.ReplaceAll(l.Name, l.TimeStart.Format("15:04"), "") l.Name = strings.TrimSpace(l.Name) s += fmt.Sprintf("%s %s (%s)\n", l.TimeMsg, l.Name, l.Place) } if prefix != "" { s += "\n" + - "Д — Димитрова 66\n" + // (Филологический, социологический) - "Л — Ленина 61\n" + // (Математический, биологический) - "М — Ленина 61а\n" + // (Исторический и географический) - "С — Социалистический 68" // (Экономический и юридический) + "Д — Димитрова 66\n" + // (Филологический, социологический) + "Л — Ленина 61\n" + // (Математический, биологический) + "М — Ленина 61а\n" + // (Исторический и географический) + "С — Социалистический 68" // (Экономический и юридический) } return s } @@ -105,7 +105,7 @@ func WeatherMessage(w weather.Weather) string { func NewYearMessage(message new_year_service.NewYearMessage) string { loc := time.FixedZone("UTC+7", +7*60*60) - ny := time.Date(2024, 1, 1, 0, 0, 0, 0, loc) + ny := time.Date(time.Now().Year()+1, 1, 1, 0, 0, 0, 0, loc) now := time.Now().In(loc) days := ny.Sub(now).Hours() / 24 if message.Header != "" { From 454f544bf38d5c5d88acb90b4ef48e8c4b0d76e5 Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 14:47:09 +0700 Subject: [PATCH 2/6] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20week?= =?UTF-8?q?day=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- date/date.go | 30 +++++++++++++++++++++++++++++- messages/messages.go | 3 ++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/date/date.go b/date/date.go index 43551b4..634193b 100644 --- a/date/date.go +++ b/date/date.go @@ -7,5 +7,33 @@ func Today(offset time.Duration) string { if err != nil { panic(err) } - return time.Now().In(location).Add(offset).Format("2006-01-02") + return time.Now().In(location).Add(offset).Format("2006-01-02") +} + +func GetTranslatedWeekday(date time.Time) string { + switch date.Weekday() { + case time.Monday: + return "Понедельник" + + case time.Tuesday: + return "Вторник" + + case time.Wednesday: + return "Среда" + + case time.Thursday: + return "Четверг" + + case time.Friday: + return "Пятница" + + case time.Saturday: + return "Суббота" + + case time.Sunday: + return "Воскресенье" + + default: + return "" + } } diff --git a/messages/messages.go b/messages/messages.go index ec45b5f..c1e8f8d 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -5,6 +5,7 @@ import ( "math/rand" "strconv" "strings" + "student_bot/date" "student_bot/new_year_service" "student_bot/parser" "time" @@ -60,7 +61,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { s += "\n" } endDate = l.TimeStart.Format("02.01") - s += endDate + "\n" + s += endDate + " " + date.GetTranslatedWeekday(l.TimeStart) + "\n" } if strings.Contains(l.User, "Ярных В.В.") { s += "⭐️ " From 56a6ba3466b5b705904c6dc01ba799e0cc484e60 Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 15:13:59 +0700 Subject: [PATCH 3/6] =?UTF-8?q?=D0=BF=D0=BE=D0=BC=D0=B5=D0=BD=D1=8F=D0=BB?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=81=D1=82=D0=B0=D0=BC=D0=B8=20=D0=B4=D0=B0?= =?UTF-8?q?=D1=82=D1=83=20=D0=B8=20=D0=B4=D0=B5=D0=BD=D1=8C=20=D0=BD=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- messages/messages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/messages.go b/messages/messages.go index c1e8f8d..ce666c7 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -61,7 +61,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { s += "\n" } endDate = l.TimeStart.Format("02.01") - s += endDate + " " + date.GetTranslatedWeekday(l.TimeStart) + "\n" + s += date.GetTranslatedWeekday(l.TimeStart) + " " + endDate + "\n" } if strings.Contains(l.User, "Ярных В.В.") { s += "⭐️ " From c50dcc5e2a103b42a63bd5ed26b8fed5a9fe5675 Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 15:18:33 +0700 Subject: [PATCH 4/6] style fix --- messages/messages.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/messages/messages.go b/messages/messages.go index ce666c7..a99cc30 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -70,7 +70,8 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { l.Name = strings.ReplaceAll(l.Name, "()", "") l.Name = strings.ReplaceAll(l.Name, l.TimeStart.Format("15:04"), "") l.Name = strings.TrimSpace(l.Name) - s += fmt.Sprintf("%s %s (%s)\n", l.TimeMsg, l.Name, l.Place) + s += fmt.Sprintf("%s %s (%s)\n"+ + "%s \n", l.TimeMsg, l.Name, l.Place, l.User) } if prefix != "" { s += "\n" + From 179c2eaf6b2930eaafc9c28e412b3e1f69bc8e4a Mon Sep 17 00:00:00 2001 From: "k.ukolov" Date: Fri, 10 Feb 2023 15:20:30 +0700 Subject: [PATCH 5/6] change help version --- messages/messages.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messages/messages.go b/messages/messages.go index a99cc30..337e6df 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -30,7 +30,7 @@ func ThanksMessage() string { } func HelpMessage(chatID int64) string { - return "Вот чем я могу вам помочь (v1.4.2), отправь:\n\n" + + return "Вот чем я могу вам помочь (v1.4.3), отправь:\n\n" + "- /ping отобью pong\n" + "- /today_lessons покажу расписание на сегодня\n" + "- /tomorrow_lessons покажу расписание на завтра\n" + From d189be8e44e5ccd7483864a320473a75dca72912 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Fri, 10 Feb 2023 15:43:13 +0700 Subject: [PATCH 6/6] fix --- date/date.go | 7 ------- messages/messages.go | 3 +-- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/date/date.go b/date/date.go index 634193b..23ce2e6 100644 --- a/date/date.go +++ b/date/date.go @@ -14,25 +14,18 @@ func GetTranslatedWeekday(date time.Time) string { switch date.Weekday() { case time.Monday: return "Понедельник" - case time.Tuesday: return "Вторник" - case time.Wednesday: return "Среда" - case time.Thursday: return "Четверг" - case time.Friday: return "Пятница" - case time.Saturday: return "Суббота" - case time.Sunday: return "Воскресенье" - default: return "" } diff --git a/messages/messages.go b/messages/messages.go index 337e6df..957b0ad 100644 --- a/messages/messages.go +++ b/messages/messages.go @@ -70,8 +70,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string { l.Name = strings.ReplaceAll(l.Name, "()", "") l.Name = strings.ReplaceAll(l.Name, l.TimeStart.Format("15:04"), "") l.Name = strings.TrimSpace(l.Name) - s += fmt.Sprintf("%s %s (%s)\n"+ - "%s \n", l.TimeMsg, l.Name, l.Place, l.User) + s += fmt.Sprintf("%s %s (%s)\n%s\n", l.TimeMsg, l.Name, l.Place, l.User) } if prefix != "" { s += "\n" +