add /send_new_year_to_chat

This commit is contained in:
2022-11-26 16:59:35 +07:00
parent 84389e11bd
commit cb7c313386
3 changed files with 59 additions and 46 deletions
+4 -1
View File
@@ -95,7 +95,10 @@ func NewYearMessage(message new_year_service.NewYearMessage) string {
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)
if message.Header != "" {
return fmt.Sprintf("❄ %s ❄ \n\n%s\n\n%s", toStrDays(int(days)), message.Header, message.Text)
}
return fmt.Sprintf("❄ %s ❄ \n\n%s", toStrDays(int(days)), message.Text)
}
func toStrDays(days int) string {