Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Filter ¶
type Filter []Narrow
Filter is a collection of narrow items to be applied when searching for messages or filtering events
Example ¶
package main import ( "fmt" "github.com/wakumaku/go-zulip/narrow" ) func main() { // Create a new filter with a search, topic, and stream narrow narrow := narrow.NewFilter(). Add(narrow.New(narrow.Channel, "general")). Add(narrow.New(narrow.Topic, "greetings")). Add(narrow.New(narrow.Search, "hello narrow")) narrowString := narrow.String() fmt.Println(narrowString) }
Output: channel:general topic:greetings search:hello narrow
func (Filter) MarshalEvent ¶
MarshalEvent returns the JSON encoding of the Filter for events
func (Filter) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the Filter
type Narrow ¶
type Narrow struct { Operator Operator `json:"operator"` Operand Operand `json:"operand"` Negated bool `json:"negated"` }
Narrow is a struct that represents a single narrow item to be applied when searching for messages or filtering events
var ( IsUnread Narrow = New(Is, Unread) IsFollowed Narrow = New(Is, Followed) IsDm Narrow = New(Is, Operand("dm")) IsMentioned Narrow = New(Is, Mentioned) IsStarred Narrow = New(Is, Starred) IsRead Narrow = New(Is, Read) IsAlerted Narrow = New(Is, Alerted) HasAttachment Narrow = New(Is, Attachment) HasImage Narrow = New(Is, Image) HasLink Narrow = New(Has, Link) HasReaction Narrow = New(Has, Reaction) )
Operators with Operands
func NewFromString ¶
NewFromString creates a new Narrow from a string
func NewNegated ¶
NewNegated creates a new Negated Narrow
type Operand ¶
type Operand any
Operand is a type that represents the concrete operands that can be used in the narrow parameter.
var ( Unread Operand = "unread" Followed Operand = "followed" // Dm Operand = "dm" // clashes with Dm Operator Mentioned Operand = "mentioned" Starred Operand = "starred" Read Operand = "read" Alerted Operand = "alerted" Attachment Operand = "attachment" Image Operand = "image" Link Operand = "link" Reaction Operand = "reaction" )
Operands List
type Operator ¶
type Operator string
Operator is a type that represents the concrete operators that can be used in the narrow parameter.
const ( // Search for only the message with ID 12345 Id Operator = "id" // Search for the conversation that contains the message with ID 12345. With Operator = "with" Near Operator = "near" Channel Operator = "channel" Channels Operator = "channels" // stream is a legacy alias for "channel" Stream Operator = "stream" // streams is a legacy alias for "channels" Streams Operator = "streams" Topic Operator = "topic" Sender Operator = "sender" Search Operator = "search" // Search the direct message conversation between you and user ID 1234 Dm Operator = "dm" // Search all direct messages (1-on-1 and group) that include you and user ID 1234. DmIncluding Operator = "dm-including" Is Operator = "is" Has Operator = "has" )
Operators List