mirror of
https://github.com/fiatjaf/nak.git
synced 2024-11-22 08:19:06 -05:00
--nevent flag on nak event to print an nevent at the end.
This commit is contained in:
parent
14b69f36cf
commit
3dfcec69b7
11
event.go
11
event.go
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
"github.com/mailru/easyjson"
|
"github.com/mailru/easyjson"
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
|
"github.com/nbd-wtf/go-nostr/nip19"
|
||||||
"github.com/nbd-wtf/go-nostr/nson"
|
"github.com/nbd-wtf/go-nostr/nson"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
@ -51,6 +52,10 @@ example:
|
||||||
Name: "auth",
|
Name: "auth",
|
||||||
Usage: "always perform NIP-42 \"AUTH\" when facing an \"auth-required: \" rejection and try again",
|
Usage: "always perform NIP-42 \"AUTH\" when facing an \"auth-required: \" rejection and try again",
|
||||||
},
|
},
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "nevent",
|
||||||
|
Usage: "print the nevent code (to stderr) after the event is published",
|
||||||
|
},
|
||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "nson",
|
Name: "nson",
|
||||||
Usage: "encode the event using NSON",
|
Usage: "encode the event using NSON",
|
||||||
|
@ -229,6 +234,7 @@ example:
|
||||||
stdout(result)
|
stdout(result)
|
||||||
|
|
||||||
// publish to relays
|
// publish to relays
|
||||||
|
successRelays := make([]string, 0, len(relays))
|
||||||
if len(relays) > 0 {
|
if len(relays) > 0 {
|
||||||
os.Stdout.Sync()
|
os.Stdout.Sync()
|
||||||
for _, relay := range relays {
|
for _, relay := range relays {
|
||||||
|
@ -241,6 +247,7 @@ example:
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// published fine
|
// published fine
|
||||||
log("success.\n")
|
log("success.\n")
|
||||||
|
successRelays = append(successRelays, relay.URL)
|
||||||
continue // continue to next relay
|
continue // continue to next relay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,6 +266,10 @@ example:
|
||||||
}
|
}
|
||||||
log("failed: %s\n", err)
|
log("failed: %s\n", err)
|
||||||
}
|
}
|
||||||
|
if len(successRelays) > 0 && c.Bool("nevent") {
|
||||||
|
nevent, _ := nip19.EncodeEvent(evt.ID, successRelays, evt.PubKey)
|
||||||
|
log(nevent + "\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user