mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-06-05 20:49:11 +02:00
some stringifiers.
This commit is contained in:
parent
b0ae497656
commit
67d8f26d8a
11
filter.go
11
filter.go
@ -1,6 +1,7 @@
|
||||
package nostr
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
@ -20,6 +21,11 @@ type Filter struct {
|
||||
|
||||
type TagMap map[string][]string
|
||||
|
||||
func (eff Filters) String() string {
|
||||
j, _ := json.Marshal(eff)
|
||||
return string(j)
|
||||
}
|
||||
|
||||
func (eff Filters) Match(event *Event) bool {
|
||||
for _, filter := range eff {
|
||||
if filter.Matches(event) {
|
||||
@ -29,6 +35,11 @@ func (eff Filters) Match(event *Event) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (ef Filter) String() string {
|
||||
j, _ := json.Marshal(ef)
|
||||
return string(j)
|
||||
}
|
||||
|
||||
func (ef Filter) Matches(event *Event) bool {
|
||||
if event == nil {
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user