draft nip-34 helpers.

This commit is contained in:
fiatjaf
2024-02-07 21:44:47 -03:00
parent 60359110d7
commit 385aa9c958
6 changed files with 108 additions and 0 deletions

42
nip34/repository.go Normal file
View File

@@ -0,0 +1,42 @@
package nip34
import "github.com/nbd-wtf/go-nostr"
type Repository struct {
nostr.Event
ID string
Name string
Description string
Web []string
Clone []string
Relays []string
}
func ParseRepository(event nostr.Event) Repository {
repo := Repository{
Event: event,
}
for _, tag := range event.Tags {
if len(tag) < 2 {
continue
}
switch tag[0] {
case "d":
repo.ID = tag[1]
case "name":
repo.Name = tag[1]
case "description":
repo.Description = tag[1]
case "web":
repo.Web = append(repo.Web, tag[1])
case "clone":
repo.Clone = append(repo.Clone, tag[1])
case "relays":
repo.Relays = append(repo.Relays, tag[1])
}
}
return repo
}