spell: also take a --pub to run spells in the context of other users.

This commit is contained in:
fiatjaf
2025-12-22 12:11:27 -03:00
parent b95665d986
commit 5d4fe434c3

View File

@@ -24,6 +24,10 @@ var spell = &cli.Command{
ArgsUsage: "[nevent_code]", ArgsUsage: "[nevent_code]",
Description: `fetches a spell event (kind 777) and executes REQ command encoded in its tags.`, Description: `fetches a spell event (kind 777) and executes REQ command encoded in its tags.`,
Flags: append(defaultKeyFlags, Flags: append(defaultKeyFlags,
&cli.StringFlag{
Name: "pub",
Usage: "public key to run spells in the context of (if you don't want to pass a --sec)",
},
&cli.UintFlag{ &cli.UintFlag{
Name: "outbox-relays-per-pubkey", Name: "outbox-relays-per-pubkey",
Aliases: []string{"n"}, Aliases: []string{"n"},
@@ -259,6 +263,10 @@ func buildSpellReq(ctx context.Context, c *cli.Command, tags nostr.Tags) (nostr.
filter := nostr.Filter{} filter := nostr.Filter{}
getMe := func() (nostr.PubKey, error) { getMe := func() (nostr.PubKey, error) {
if !c.IsSet("sec") && !c.IsSet("prompt-sec") && c.IsSet("pub") {
return parsePubKey(c.String("pub"))
}
kr, _, err := gatherKeyerFromArguments(ctx, c) kr, _, err := gatherKeyerFromArguments(ctx, c)
if err != nil { if err != nil {
return nostr.ZeroPK, fmt.Errorf("failed to get keyer: %w", err) return nostr.ZeroPK, fmt.Errorf("failed to get keyer: %w", err)