add /send_new_year_to_chat
This commit is contained in:
@@ -138,6 +138,12 @@ func run() {
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = fmt.Fprintf(w, `{"result":"ok"}`)
|
||||
})
|
||||
http.HandleFunc("/send_new_year_to_chat", func(w http.ResponseWriter, r *http.Request) {
|
||||
sendNewYearToChat(bot, opts.ChatID, imageService)
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_, _ = fmt.Fprintf(w, `{"result":"ok"}`)
|
||||
})
|
||||
|
||||
port := ":10001"
|
||||
log.Println("Server is start up! port", port)
|
||||
@@ -191,11 +197,7 @@ func run() {
|
||||
send(bot, tgbot.NewMessage(chatID, messages.WeatherMessage(w)))
|
||||
|
||||
case commands.NewYear:
|
||||
url := imageService.GetRandomImageURL()
|
||||
message := imageService.GetRandomMessage()
|
||||
msg := tgbot.NewPhotoShare(chatID, url)
|
||||
msg.Caption = messages.NewYearMessage(message)
|
||||
send(bot, msg)
|
||||
sendNewYearToChat(bot, chatID, imageService)
|
||||
|
||||
default:
|
||||
}
|
||||
@@ -234,3 +236,11 @@ func sendTomorrowLessonsToChat(bot *tgbot.BotAPI, chatID int64, prefix string) {
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
func sendNewYearToChat(bot *tgbot.BotAPI, chatID int64, imageService new_year_service.NewYearService) {
|
||||
url := imageService.GetRandomImageURL()
|
||||
message := imageService.GetRandomMessage()
|
||||
msg := tgbot.NewPhotoShare(chatID, url)
|
||||
msg.Caption = messages.NewYearMessage(message)
|
||||
send(bot, msg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user