nbd-wtf / go-nostr

Nostr library for Golang
MIT License
364 stars 102 forks source link

How to retrieve the last 3 notes from a user? #105

Open R3DRUN3 opened 1 year ago

R3DRUN3 commented 1 year ago

Hi, I am trying to retrieve the last 3 notes from a single user (by modifying example.go) but I dont understand how to do this. I am using the Author field in the filters but the results from the relay are empty.

fiatjaf commented 1 year ago

Can you paste your code?

R3DRUN3 commented 1 year ago

Basically is like in your example but modify the code like this:

// create filters
var filters nostr.Filters
if _, v, err := nip19.Decode(npub); err == nil {
    t := make(map[string][]string)
    // making a "p" tag for the above public key.
    // this filters for messages tagged with the user, mainly replies.
    t["p"] = []string{v.(string)}
    filters = []nostr.Filter{{
        Kinds: []int{nostr.KindTextNote},
                Authors: []string{"<HARDCODED-PUB-KEY-HERE>"}
        Tags:  t,
        Limit: 3,
fiatjaf commented 1 year ago

Maybe the relay you're querying doesn't have any of the results you want? That's the only explanation I can think of.

Maybe try doing the same query manually or with https://github.com/fiatjaf/nak.

R3DRUN3 commented 1 year ago

Silly me! I was querying a closed relay that is behind a paywall 🙈 Sorry for your time, you can close this.