birds

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package birds generates HTML out of twitter threads.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTwitterQuery

func AddTwitterQuery(query url.Values) url.Values

AddTwitterQuery adds extra expansion and field queries.

Types

type Entities

type Entities struct {
	URLs     []URLEntity     `json:"urls,omitempty"`
	Mentions []MentionEntity `json:"mentions,omitempty"`
}

Entities represent twitter entities of a single tweet.

type Includes

type Includes struct {
	Tweets []*Tweet `json:"tweets"`
	Users  []*User  `json:"users"`
	Media  []*Media `json:"media,omitempty"`
}

Includes represends the included tweets, users, media.

type Media

type Media struct {
	Key    string `json:"media_key"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Type   string `json:"type"`
	URL    string `json:"url"`
}

Media represents a twitter media (e.g. photo)

type MentionEntity

type MentionEntity struct {
	Start    int    `json:"start"`
	End      int    `json:"end"`
	Username string `json:"username"`
}

MentionEntity represents a mention in tweet's entities.

type Meta

type Meta struct {
	NextToken string `json:"next_token,omitempty"`
}

Meta represents the metadata portion of a twitter api response.

type Photos

type Photos = map[string]*Media

Photos defines the map from media key to the photo media.

type Session

type Session struct {
	UserAgent string
	Bearer    string
}

Session manages a twitter application-only authentication sesison.

func (*Session) Do

func (s *Session) Do(ctx context.Context, req *http.Request) (*http.Response, error)

Do executes http request with the bearer token in this session.

func (*Session) Thread

func (s *Session) Thread(ctx context.Context, id string) (string, error)

Thread generates HTML of a twitter thread from a single tweet id.

type Tweet

type Tweet struct {
	Text     string      `json:"text"`
	ID       json.Number `json:"id"`
	AuthorID json.Number `json:"author_id"`

	CreatedAt       string      `json:"created_at"`
	ConversationID  json.Number `json:"conversation_id,omitempty"`
	InReplyToUserID json.Number `json:"in_reply_to_user_id,omitempty"`

	Entities Entities `json:"entities,omitempty"`

	Attachments struct {
		MediaKeys []string `json:"media_keys,omitempty"`
	} `json:"attachments,omitempty"`

	ReferencedTweets []struct {
		Type string      `json:"type"`
		ID   json.Number `json:"id"`
	} `json:"referenced_tweets,omitempty"`
}

Tweet represents a single tweet.

func (*Tweet) RenderHTML

func (t *Tweet) RenderHTML(photos Photos) string

RenderHTML renders the tweet text into HTML.

type URLEntity

type URLEntity struct {
	Start       int    `json:"start"`
	End         int    `json:"end"`
	ExpandedURL string `json:"expanded_url"`
}

URLEntity represents an url in tweet's entities.

type User

type User struct {
	ID       json.Number `json:"id"`
	Username string      `json:"username"`
}

User represents a twitter user.

type Users

type Users = map[string]*User

Users defines the map from id to the user.

Jump to

Keyboard shortcuts

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