Merge pull request 'kostyan/trash' (#1) from kostyan/trash into master
Reviewed-on: https://git.user-penguin.space/vladimir/verochka/pulls/1
This commit is contained in:
commit
9415ce4c37
21
date/date.go
21
date/date.go
|
@ -9,3 +9,24 @@ func Today(offset time.Duration) string {
|
||||||
}
|
}
|
||||||
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 ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"student_bot/date"
|
||||||
"student_bot/new_year_service"
|
"student_bot/new_year_service"
|
||||||
"student_bot/parser"
|
"student_bot/parser"
|
||||||
"time"
|
"time"
|
||||||
|
@ -29,7 +30,7 @@ func ThanksMessage() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func HelpMessage(chatID int64) string {
|
func HelpMessage(chatID int64) string {
|
||||||
return "Вот чем я могу вам помочь (v1.4.2), отправь:\n\n" +
|
return "Вот чем я могу вам помочь (v1.4.3), отправь:\n\n" +
|
||||||
"- /ping отобью pong\n" +
|
"- /ping отобью pong\n" +
|
||||||
"- /today_lessons покажу расписание на сегодня\n" +
|
"- /today_lessons покажу расписание на сегодня\n" +
|
||||||
"- /tomorrow_lessons покажу расписание на завтра\n" +
|
"- /tomorrow_lessons покажу расписание на завтра\n" +
|
||||||
|
@ -60,7 +61,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string {
|
||||||
s += "\n"
|
s += "\n"
|
||||||
}
|
}
|
||||||
endDate = l.TimeStart.Format("02.01")
|
endDate = l.TimeStart.Format("02.01")
|
||||||
s += endDate + "\n"
|
s += date.GetTranslatedWeekday(l.TimeStart) + " " + endDate + "\n"
|
||||||
}
|
}
|
||||||
if strings.Contains(l.User, "Ярных В.В.") {
|
if strings.Contains(l.User, "Ярных В.В.") {
|
||||||
s += "⭐️ "
|
s += "⭐️ "
|
||||||
|
@ -69,7 +70,7 @@ func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string {
|
||||||
l.Name = strings.ReplaceAll(l.Name, "()", "")
|
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)
|
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 != "" {
|
if prefix != "" {
|
||||||
s += "\n" +
|
s += "\n" +
|
||||||
|
@ -105,7 +106,7 @@ func WeatherMessage(w weather.Weather) string {
|
||||||
|
|
||||||
func NewYearMessage(message new_year_service.NewYearMessage) string {
|
func NewYearMessage(message new_year_service.NewYearMessage) string {
|
||||||
loc := time.FixedZone("UTC+7", +7*60*60)
|
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)
|
now := time.Now().In(loc)
|
||||||
days := ny.Sub(now).Hours() / 24
|
days := ny.Sub(now).Hours() / 24
|
||||||
if message.Header != "" {
|
if message.Header != "" {
|
||||||
|
|
Loading…
Reference in New Issue