in progress
This commit is contained in:
37
telegram_test.go
Normal file
37
telegram_test.go
Normal file
@@ -0,0 +1,37 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user