Nostr. Event. Contacts
(Nostr Lib v0.2.1)
(event)
(nip02)
View Source
Contact list
Defined in NIP 02 https://github.com/nostr-protocol/nips/blob/master/02.md
Summary
Functions
Create new Contact List (follow list) Nostr event
Parses a kind 3 event into a Contacts struct, extracting the contact list.
Types
@type contact() :: %{ :user => <<_::32, _::_*8>>, optional(:relay) => URI.t(), optional(:petname) => String.t() }
Contact structure returned from parsing
@type contact_input() :: %{ :user => binary(), optional(:relay) => String.t(), optional(:petname) => String.t() }
Contact input for creating a contact list
@type t() :: %Nostr.Event.Contacts{ contacts: [contact()], event: Nostr.Event.t(), user: <<_::32, _::_*8>> }
Functions
@spec create(contacts :: [contact_input()], opts :: Keyword.t()) :: t()
Create new Contact List (follow list) Nostr event
Arguments:
contactslist of contacts to followoptsother optional event arguments (pubkey,created_at,tags)
Examples
iex> contacts = [
...> %{user: "pubkey1", relay: "wss://relay.com", petname: "alice"},
...> %{user: "pubkey2", relay: "wss://relay.com"},
...> %{user: "pubkey3"}
...> ]
iex> Nostr.Event.Contacts.create(contacts)
@spec parse(event :: Nostr.Event.t()) :: t()
Parses a kind 3 event into a Contacts struct, extracting the contact list.