Изменено: формат дат в сводке
parent
b4df0cf268
commit
bf9a49b13c
1
go.mod
1
go.mod
|
@ -25,6 +25,7 @@ require (
|
|||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/lib/pq v1.10.7 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.16 // indirect
|
||||
github.com/mergestat/timediff v0.0.3
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/syndtr/goleveldb v1.0.0 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -239,6 +239,8 @@ github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A
|
|||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mergestat/timediff v0.0.3 h1:ucCNh4/ZrTPjFZ081PccNbhx9spymCJkFxSzgVuPU+Y=
|
||||
github.com/mergestat/timediff v0.0.3/go.mod h1:yvMUaRu2oetc+9IbPLYBJviz6sA7xz8OXMDfhBl7YSI=
|
||||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"git.l9labs.ru/anufriev.g.a/l9_stud_bot/modules/database"
|
||||
"git.l9labs.ru/anufriev.g.a/l9_stud_bot/modules/ssau_parser"
|
||||
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||||
td "github.com/mergestat/timediff"
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
|
@ -70,16 +71,19 @@ func (bot *Bot) GetSummary(
|
|||
str := "📝Краткая сводка:\n\n"
|
||||
if pairs[0][0].Begin.Day() != now.Day() {
|
||||
str += "❗️Сегодня пар нет\nБлижайшие занятия "
|
||||
dt := firstPair[0].Begin.Sub(now).Hours()
|
||||
if dt < 35 {
|
||||
str += "завтра\n"
|
||||
} else {
|
||||
str += td.TimeDiff(
|
||||
firstPair[0].Begin,
|
||||
td.WithLocale("ru_RU"),
|
||||
td.WithStartTime(now),
|
||||
)
|
||||
if firstPair[0].Begin.Sub(now).Hours() > 36 {
|
||||
str += fmt.Sprintf(
|
||||
"%d %s\n\n",
|
||||
", <b>%d %s</b>",
|
||||
firstPair[0].Begin.Day(),
|
||||
month[firstPair[0].Begin.Month()-1],
|
||||
)
|
||||
}
|
||||
str += "\n\n"
|
||||
day, err := bot.StrDayShedule(pairs)
|
||||
if err != nil {
|
||||
return nilMsg, err
|
||||
|
@ -89,7 +93,12 @@ func (bot *Bot) GetSummary(
|
|||
if firstPair[0].Begin.Before(now) {
|
||||
str += "Сейчас:\n\n"
|
||||
} else {
|
||||
str += "Ближайшая пара сегодня:\n\n"
|
||||
dt := td.TimeDiff(
|
||||
firstPair[0].Begin,
|
||||
td.WithLocale("ru_RU"),
|
||||
td.WithStartTime(now),
|
||||
)
|
||||
str += fmt.Sprintf("Ближайшая пара %s:\n\n", dt)
|
||||
}
|
||||
firstStr, err := PairToStr(firstPair, bot.DB)
|
||||
if err != nil {
|
||||
|
|
|
@ -141,6 +141,7 @@ func (bot *Bot) EditOrSend(
|
|||
str,
|
||||
)
|
||||
msg.ReplyMarkup = &markup
|
||||
msg.ParseMode = tgbotapi.ModeHTML
|
||||
if _, err := bot.TG.Request(msg); err != nil {
|
||||
if strings.Contains(err.Error(), "message is not modified") {
|
||||
return tgbotapi.Message{}, nil
|
||||
|
@ -151,6 +152,7 @@ func (bot *Bot) EditOrSend(
|
|||
} else {
|
||||
msg := tgbotapi.NewMessage(id, str)
|
||||
msg.ReplyMarkup = &markup
|
||||
msg.ParseMode = tgbotapi.ModeHTML
|
||||
return bot.TG.Send(msg)
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue