package daemon

import (
	"fmt"
	"net/http"
	"net/url"
	"time"

	"gordenko.dev/dima/httpreq"
)

// @getidsbot - показывает ID чата

const (
	// tipper, sport_oracle_bot
	//telegramBotToken = "1059580991:AAFHO4RrQCIF-JWYQI2em1D5aLJ4KbjDPZU"
	telegramBotToken = "5637682609:AAH2MJG-r0k9EIUQMagdZOXFUjY4nid514I"
	//telegramChannel  = "@Bet.One.Group"
	tennisTelegramChatID   = "-1001189544230"
	footballTelegramChatID = "-1001480163278"

	handballTelegramChatID = "-1001372665077"
)

var (
	telegramSendMessageURL = fmt.Sprintf("https://api.telegram.org/bot%s/sendMessage", telegramBotToken)
)

//chat_id=[MY_CHANNEL_NAME]&text=[MY_MESSAGE_TEXT]

func sendMessageToTelegramGroup(telegramChatID string, msg string) (err error) {
	data := make(url.Values)
	data.Set("chat_id", telegramChatID)
	data.Set("text", msg)
	data.Set("parse_mode", "HTML")

	u := telegramSendMessageURL + "?" + data.Encode()

	req, err := http.NewRequest("GET", u, nil)
	if err != nil {
		return
	}

	resp, err := httpreq.Send(req, 10*time.Second)
	if err != nil {
		return
	}

	if resp.StatusCode != 200 {
		err = fmt.Errorf("StatusCode: %d, Body: %s", resp.StatusCode, resp.Body)
		return
	}

	return
}
