tweet

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Add

type Add struct {
	Value string `json:"value"`
	Tag   string `json:"tag,omitempty"`
}

type AddCommand

type AddCommand struct {
	Add []Add `json:"add"`
}

func CreateAddCommand

func CreateAddCommand(values map[string]string) AddCommand

type DeleteId

type DeleteId struct {
	Ids []string `json:"ids"`
}

type DeleteIdCommand

type DeleteIdCommand struct {
	Delete DeleteId `json:"delete"`
}

func CreateDeleteIdCommand

func CreateDeleteIdCommand(ids []string) DeleteIdCommand

type DeleteValue

type DeleteValue struct {
	Values []string `json:"values"`
}

type DeleteValueCommand

type DeleteValueCommand struct {
	Delete DeleteValue `json:"delete"`
}

func CreateDeleteValueCommand

func CreateDeleteValueCommand(rules []string) DeleteValueCommand

type Meta

type Meta struct {
	Sent    time.Time `json:"sent"`
	Summary Summary   `json:"summary,omitempty"`
}

type RuleData

type RuleData struct {
	ID    string `json:"id"`
	Value string `json:"value"`
	Tag   string `json:"tag,omitempty"`
}

type RulesError

type RulesError struct {
	ClientID           string `json:"client_id"`
	RequiredEnrollment string `json:"required_enrollment"`
	RegistrationURL    string `json:"registration_url"`
	Title              string `json:"title"`
	Detail             string `json:"detail"`
	Reason             string `json:"reason"`
	Type               string `json:"type"`
}

type RulesResponse

type RulesResponse struct {
	Data []RuleData `json:"data"`
	Meta Meta       `json:"meta"`
}

func AddRule

AddRule is a convenience wrapper that delegates to the Service abstraction.

func GetRules

GetRules is a convenience wrapper that delegates to the Service abstraction.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service coordinates filtered stream operations against the Twitter API.

func NewService

func NewService(c *client.Client) *Service

NewService returns a Service backed by the provided client.

func (*Service) AddRule

AddRule creates a new filtered stream rule.

func (*Service) DeleteRule

DeleteRule removes filtered stream rules by ID.

func (*Service) GetRules

GetRules retrieves the current filtered stream rules.

func (*Service) Stream

Stream fetches filtered stream results using the provided expansion fields.

func (*Service) StreamReader

func (s *Service) StreamReader(ctx context.Context, fields map[string]string, handler TweetHandler) error

StreamReader connects to the filtered stream and processes tweets in real-time.

type StreamEnvelope

type StreamEnvelope struct {
	Data     []StreamTweet  `json:"data"`
	Includes StreamIncludes `json:"includes"`
	Errors   []RulesError   `json:"errors,omitempty"`
	Meta     StreamMeta     `json:"meta,omitempty"`
}

StreamEnvelope captures a response from the filtered stream endpoint.

func Stream

Stream is a convenience wrapper that constructs a Service on the fly and proxies to its Stream method. New code should prefer using a shared Service instance directly so that HTTP client configuration can be reused.

type StreamIncludes

type StreamIncludes struct {
	Users []StreamUser `json:"users,omitempty"`
}

StreamIncludes captures expanded entities such as users.

type StreamMeta

type StreamMeta struct {
	ResultCount int `json:"result_count"`
}

StreamMeta carries additional metadata from the endpoint.

type StreamResponse

type StreamResponse struct {
	Id   string
	Text string
}

type StreamTweet

type StreamTweet struct {
	ID                string    `json:"id"`
	Text              string    `json:"text"`
	AuthorID          string    `json:"author_id"`
	CreatedAt         time.Time `json:"created_at"`
	PossiblySensitive bool      `json:"possibly_sensitive"`
	Source            string    `json:"source"`
	Lang              string    `json:"lang"`
}

StreamTweet represents a Tweet entry in the filtered stream.

type StreamUser

type StreamUser struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	Username  string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
}

StreamUser represents a user record included alongside tweets.

type Summary

type Summary struct {
	Created    int `json:"created"`
	NotCreated int `json:"not_created"`
	Valid      int `json:"valid"`
	Invalid    int `json:"invalid"`
}

type TweetHandler

type TweetHandler func(tweet StreamTweet, includes StreamIncludes) error

TweetHandler is a function that processes tweets from the stream. Return an error to stop the stream.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL