38 lines
638 B
Go
38 lines
638 B
Go
package notify_test
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"git.gm6.ru/icewind/notify"
|
|
"gopkg.in/yaml.v2"
|
|
)
|
|
|
|
type ConfigTelegram struct {
|
|
GroupID int64 `yaml:"group_id"`
|
|
Token string `yaml:"token"`
|
|
}
|
|
|
|
func TestMessage(t *testing.T) {
|
|
cData, err := os.ReadFile("test_data/telegram.yaml")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
var conf ConfigTelegram
|
|
if err = yaml.Unmarshal(cData, &conf); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
log.Println(conf)
|
|
bot, err := notify.NewTelegram(conf.Token, true)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, err := bot.SendTextMessage(conf.GroupID, "Привет ))")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log(m)
|
|
}
|