2022-03-05 18:02:55 +00:00
|
|
|
|
package messages
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
"math/rand"
|
2022-09-04 15:32:58 +00:00
|
|
|
|
"strconv"
|
2022-03-05 18:02:55 +00:00
|
|
|
|
"strings"
|
|
|
|
|
"student_bot/new_year_service"
|
|
|
|
|
"student_bot/parser"
|
|
|
|
|
"time"
|
2022-09-04 12:46:04 +00:00
|
|
|
|
|
|
|
|
|
weather "github.com/3crabs/go-yandex-weather-api"
|
2022-03-05 18:02:55 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func StartMessage() string {
|
|
|
|
|
return "Привет, я Верочка!"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var thanksMessages = []string{
|
|
|
|
|
"Обращайся",
|
|
|
|
|
"Пожалуйста",
|
|
|
|
|
"Всегда рада помочь",
|
|
|
|
|
"Да незачто",
|
|
|
|
|
"Всегда к вашим услугим",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func ThanksMessage() string {
|
|
|
|
|
return thanksMessages[rand.Intn(len(thanksMessages)-1)]
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-04 15:32:58 +00:00
|
|
|
|
func HelpMessage(chatID int64) string {
|
2022-09-11 10:26:28 +00:00
|
|
|
|
return "Вот чем я могу вам помочь (v1.2.0), отправь:\n\n" +
|
2022-03-05 18:02:55 +00:00
|
|
|
|
"- /ping отобью pong\n" +
|
|
|
|
|
"- /today_lessons покажу расписание на сегодня\n" +
|
|
|
|
|
"- /tomorrow_lessons покажу расписание на завтра\n" +
|
|
|
|
|
"- /weather покажу погоду у универа\n" +
|
|
|
|
|
"- /new_year - посчитаю количество дней до нового года\n" +
|
2022-09-04 15:32:58 +00:00
|
|
|
|
"\nНу а больше я пока ничего не умею" +
|
|
|
|
|
"\nВаш chatID: " + strconv.FormatInt(chatID, 10)
|
2022-03-05 18:02:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func PongMessage() string {
|
|
|
|
|
return "pong"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func LessonsMessage(schedule []parser.Lesson, prefix, emptyText string) string {
|
|
|
|
|
if len(schedule) == 0 {
|
|
|
|
|
return emptyText
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
s := ""
|
|
|
|
|
if prefix != "" {
|
|
|
|
|
s += prefix + "\n\n"
|
|
|
|
|
}
|
|
|
|
|
for _, l := range schedule {
|
|
|
|
|
if strings.Contains(l.User, "Ярных В.В.") {
|
|
|
|
|
s += "⭐️ "
|
|
|
|
|
}
|
|
|
|
|
s += fmt.Sprintf("%s %s (%s)\n", l.Time, l.Name, l.Place)
|
|
|
|
|
}
|
|
|
|
|
if prefix != "" {
|
|
|
|
|
s += "\n" +
|
|
|
|
|
"Д — Димитрова 66 (Филологический, социологический)\n" +
|
|
|
|
|
"Л — Ленина 61 (Математический и биологический)\n" +
|
|
|
|
|
"М — Ленина 61а (Исторический и географический)\n" +
|
|
|
|
|
"С — Социалистический 68 (Экономический и юридический)"
|
|
|
|
|
}
|
|
|
|
|
return s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func WeatherMessage(w weather.Weather) string {
|
|
|
|
|
return fmt.Sprintf("Сейчас у универа:\n"+
|
|
|
|
|
"%s\n"+
|
|
|
|
|
"Температура: %d°C\n"+
|
|
|
|
|
"Ощущается как: %d°C\n"+
|
|
|
|
|
"Скорость ветра: %dм/с\n"+
|
|
|
|
|
"\nПогода на %s:\n"+
|
|
|
|
|
"%s\n"+
|
|
|
|
|
"Температура: %d°C\n"+
|
|
|
|
|
"Ощущается как: %d°C\n"+
|
|
|
|
|
"Скорость ветра: %dм/с\n",
|
|
|
|
|
w.Fact.GetCondition(),
|
|
|
|
|
w.Fact.Temp,
|
|
|
|
|
w.Fact.FeelsLike,
|
|
|
|
|
w.Fact.WindSpeed,
|
|
|
|
|
w.Forecast.Parts[0].GetPartName(),
|
|
|
|
|
w.Forecast.Parts[0].GetCondition(),
|
|
|
|
|
w.Forecast.Parts[0].TempAvg,
|
|
|
|
|
w.Forecast.Parts[0].FeelsLike,
|
|
|
|
|
w.Forecast.Parts[0].WindSpeed)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func NewYearMessage(message new_year_service.NewYearMessage) string {
|
|
|
|
|
loc := time.FixedZone("UTC+7", +7*60*60)
|
|
|
|
|
ny := time.Date(2023, 1, 1, 0, 0, 0, 0, loc)
|
|
|
|
|
now := time.Now().In(loc)
|
|
|
|
|
days := ny.Sub(now).Hours() / 24
|
|
|
|
|
return fmt.Sprintf("❄ %s ❄ \n\n%s\n\n%s", toStrDays(int(days)), message.Header, message.Text)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func toStrDays(days int) string {
|
|
|
|
|
if days == 0 {
|
|
|
|
|
return "Сегодня новый год!!!"
|
|
|
|
|
}
|
|
|
|
|
if days == 1 {
|
|
|
|
|
return "Новый год завтра!"
|
|
|
|
|
}
|
|
|
|
|
s := ""
|
|
|
|
|
a := days % 10
|
|
|
|
|
if days < 10 {
|
|
|
|
|
switch a {
|
|
|
|
|
case 2:
|
|
|
|
|
s = "дня"
|
|
|
|
|
case 3:
|
|
|
|
|
s = "дня"
|
|
|
|
|
case 4:
|
|
|
|
|
s = "дня"
|
|
|
|
|
default:
|
|
|
|
|
s = "дней"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if days >= 10 && days < 20 {
|
|
|
|
|
s = "дней"
|
|
|
|
|
}
|
|
|
|
|
if days >= 20 {
|
|
|
|
|
switch a {
|
|
|
|
|
case 1:
|
|
|
|
|
s = "день"
|
|
|
|
|
case 2:
|
|
|
|
|
s = "дня"
|
|
|
|
|
case 3:
|
|
|
|
|
s = "дня"
|
|
|
|
|
case 4:
|
|
|
|
|
s = "дня"
|
|
|
|
|
default:
|
|
|
|
|
s = "дней"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return fmt.Sprintf("До нового года %d %s", days, s)
|
|
|
|
|
}
|