hdkv
/
i2_bot
Archived
1
Fork 0
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues/pull-requests.
i2_bot/lib/reminder/sender.go

34 lines
1.0 KiB
Go
Raw Normal View History

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package reminder
import (
2018-05-02 07:25:39 +04:00
"time"
"github.com/go-telegram-bot-api/telegram-bot-api"
2018-05-19 12:14:25 +04:00
"github.com/fat0troll/i2_bot/lib/dbmapping"
)
// SendReminders sends reminders for users about coming league tournament
func (r *Reminder) SendReminders() {
currentHour := time.Now().Hour()
nextTournamentID := (currentHour / 2) + 1
playersRaw := []dbmapping.Player{}
err := c.Db.Select(&playersRaw, "SELECT p.* FROM players p, alarms a WHERE a.turnir_number=? AND a.player_id = p.id GROUP BY p.id", nextTournamentID)
if err != nil {
c.Log.Error(err.Error())
}
for i := range playersRaw {
message := "*Турнир Лиг покемемов состоится через пять минут!*\n"
message += "Вперёд, за опытом и деньгами! Выстави атаку и жди результата!"
msg := tgbotapi.NewMessage(int64(playersRaw[i].TelegramID), message)
msg.ParseMode = "Markdown"
c.Bot.Send(msg)
}
}