update example in README.

This commit is contained in:
fiatjaf 2023-12-09 14:40:39 -03:00
parent fabd5160a8
commit e73b784501
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1

View File

@ -101,8 +101,7 @@ for _, url := range []string{"wss://nostr.zebedee.cloud", "wss://nostr-pub.wello
fmt.Println(err)
continue
}
_, err = relay.Publish(ctx, ev)
if err != nil {
if err := relay.Publish(ctx, ev); err != nil {
fmt.Println(err)
continue
}
@ -111,28 +110,6 @@ for _, url := range []string{"wss://nostr.zebedee.cloud", "wss://nostr-pub.wello
}
```
### Authenticating with NIP-42
For this section, the user needs access to a relay implementing NIP-42.
E.g., https://github.com/fiatjaf/relayer with a relay implementing the relayer.Auther interface.
``` go
func main() {
url := "ws://localhost:7447"
sk := nostr.GeneratePrivateKey()
relay, err := nostr.RelayConnect(context.Background(), url,
nostr.WithAuthHandler(func(ctx context.Context, authEvent *Event) (ok bool) {
authEvent.Sign(sk)
}),
)
if err != nil {
panic(err)
}
}
```
### Example script
```