Versions in this module Expand all Collapse all v0 v0.0.0 Dec 25, 2022 Changes in this version + const KindBoost + const KindChannelCreation + const KindChannelHideMessage + const KindChannelMessage + const KindChannelMetadata + const KindChannelMuteUser + const KindContactList + const KindDeletion + const KindEncryptedDirectMessage + const KindReaction + const KindRecommendServer + const KindSetMetadata + const KindTextNote + func ContainsPrefixOf(haystack []string, needle string) bool + func FilterEqual(a Filter, b Filter) bool + func GeneratePrivateKey() string + func GetPublicKey(sk string) (string, error) + func NormalizeURL(u string) string + func Similar(as, bs []E) bool + func Unique(all chan EventMessage) chan Event + type Connection struct + func NewConnection(socket *websocket.Conn) *Connection + func (c *Connection) Close() error + func (c *Connection) WriteJSON(v interface{}) error + func (c *Connection) WriteMessage(messageType int, data []byte) error + type Event struct + Content string + CreatedAt time.Time + ID string + Kind int + PubKey string + Sig string + Tags Tags + func (evt *Event) GetID() string + func (evt *Event) Serialize() []byte + func (evt *Event) SetExtra(key string, value any) + func (evt *Event) Sign(privateKey string) error + func (evt *Event) UnmarshalJSON(payload []byte) error + func (evt Event) CheckSignature() (bool, error) + func (evt Event) GetExtra(key string) any + func (evt Event) GetExtraBoolean(key string) bool + func (evt Event) GetExtraNumber(key string) float64 + func (evt Event) GetExtraString(key string) string + func (evt Event) MarshalJSON() ([]byte, error) + type EventMessage struct + Event Event + Relay string + type Filter struct + Authors []string + IDs []string + Kinds []int + Limit int + Since *time.Time + Tags TagMap + Until *time.Time + func (ef Filter) Matches(event *Event) bool + func (ef Filter) String() string + func (f *Filter) UnmarshalJSON(payload []byte) error + func (f Filter) MarshalJSON() ([]byte, error) + type Filters []Filter + func (eff Filters) Match(event *Event) bool + func (eff Filters) String() string + type NoticeMessage struct + Message string + Relay string + type ProfileMetadata struct + About string + NIP05 string + Name string + Picture string + func ParseMetadata(event Event) (*ProfileMetadata, error) + type PublishStatus struct + Relay string + Status Status + type Relay struct + Connection *Connection + ConnectionError chan error + Notices chan string + URL string + func RelayConnect(url string) (*Relay, error) + func RelayConnectContext(ctx context.Context, url string) (*Relay, error) + func (r *Relay) Close() error + func (r *Relay) Connect() error + func (r *Relay) ConnectContext(ctx context.Context) error + func (r *Relay) PrepareSubscription() *Subscription + func (r *Relay) QuerySync(filter Filter, timeout time.Duration) []Event + func (r *Relay) String() string + func (r *Relay) Subscribe(filters Filters) *Subscription + func (r Relay) Publish(event Event) chan Status + type RelayPool struct + Notices chan *NoticeMessage + Policies s.MapOf[string, RelayPoolPolicy] + Relays s.MapOf[string, *Relay] + SecretKey *string + func NewRelayPool() *RelayPool + func (r *RelayPool) Add(url string, policy RelayPoolPolicy) <-chan error + func (r *RelayPool) AddContext(ctx context.Context, url string, policy RelayPoolPolicy) error + func (r *RelayPool) PublishEvent(evt *Event) (*Event, chan PublishStatus, error) + func (r *RelayPool) Remove(url string) + func (r *RelayPool) Sub(filters Filters) (subID string, events chan EventMessage, unsubscribe func()) + type RelayPoolPolicy interface + ShouldRead func(Filters) bool + ShouldWrite func(*Event) bool + type SimplePolicy struct + Read bool + Write bool + func (s SimplePolicy) ShouldRead(_ Filters) bool + func (s SimplePolicy) ShouldWrite(_ *Event) bool + type Status int + const PublishStatusFailed + const PublishStatusSent + const PublishStatusSucceeded + func (s Status) String() string + type Subscription struct + EndOfStoredEvents chan struct{} + Events chan Event + Filters Filters + Relay *Relay + func (sub *Subscription) Fire() + func (sub *Subscription) Sub(filters Filters) + func (sub *Subscription) Unsub() + type Tag []string + func (tag Tag) Key() string + func (tag Tag) Relay() string + func (tag Tag) StartsWith(prefix []string) bool + func (tag Tag) Value() string + type TagMap map[string][]string + type Tags []Tag + func (t *Tags) Scan(src interface{}) error + func (tags Tags) AppendUnique(tag Tag) Tags + func (tags Tags) ContainsAny(tagName string, values []string) bool + func (tags Tags) FilterOut(tagPrefix []string) Tags + func (tags Tags) GetAll(tagPrefix []string) Tags + func (tags Tags) GetFirst(tagPrefix []string) *Tag + func (tags Tags) GetLast(tagPrefix []string) *Tag