Skip to content

Commit

Permalink
Merge pull request #4 from go-pkgz/paskal/update_readme
Browse files Browse the repository at this point in the history
Fix tg code examples in Readme as NewTelegram return err
  • Loading branch information
umputun authored Sep 12, 2023
2 parents 076c800 + eb2eaef commit 2422359
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ func main() {
notify.NewWebhook(notify.WebhookParams{}),
notify.NewEmail(notify.SMTPParams{}),
notify.NewSlack("token"),
notify.NewTelegram(notify.TelegramParams{token: "token"}),
}
err := notify.Send(context.Background(), notifiers, "https://example.com/webhook", "Hello, world!")
tg, err := notify.NewTelegram(notify.TelegramParams{Token: "token"})
if err == nil {
notifiers = append(notifiers, tg)
}
err = notify.Send(context.Background(), notifiers, "https://example.com/webhook", "Hello, world!")
if err != nil {
fmt.Printf("Sent message error: %s", err))
}
Expand Down Expand Up @@ -100,18 +103,19 @@ package main
import (
"context"
"log"
"time"

"github.com/go-pkgz/notify"
)

func main() {
tg := notify.NewTelegram(notify.TelegramParams{
Token: "token", // required
Timeout: time.Second * 10, // default is 5 seconds
SuccessMsg: // optional, for auth, set by default
ErrorMsg: // optional, for auth, unset by default
tg, err := notify.NewTelegram(notify.TelegramParams{
Token: "token", // required
Timeout: time.Second * 10, // default is 5 seconds
SuccessMsg: "Success", // optional, for auth, set by default
ErrorMsg: "Error", // optional, for auth, unset by default
})
err := tg.Send(context.Background(), "telegram:-1001480738202", "Hello, World!")
err = tg.Send(context.Background(), "telegram:-1001480738202", "Hello, World!")
if err != nil {
log.Fatalf("problem sending message using telegram, %v", err)
}
Expand Down

0 comments on commit 2422359

Please sign in to comment.