cmd

package
v0.0.0-...-e6bf12f Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: AGPL-3.0-only Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SqliteSchema = `` /* 216-byte string literal not displayed */

	KeepTweets int = 10 // How many tweets to keep in database before pruning
)
View Source
const (
	ScrapeInterval int   = 3  // How often to check for new tweets (in minutes)
	ScrapeDelay    int64 = 0  // How long to wait between api requests (in seconds)
	ScrapeStep     int   = 10 // How many tweets to get at a time
)
View Source
const (
	BaseURL  = "https://twitter.com/"
	BaseIcon = "https://abs.twimg.com/icons/apple-touch-icon-192x192.png"
)

Variables

This section is empty.

Functions

func Run

func Run()

Types

type App

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

type Author

type Author struct {
	Name    string `json:"name"`
	URL     string `json:"url"`
	IconURL string `json:"icon_url"`
}

type Config

type Config struct {
	Username   string
	Password   string
	ProxyAddr  string
	Channels   []string
	Filter     []uint8
	Webhook    string
	DbPath     string
	CookiePath string
}

func ConfigFromFile

func ConfigFromFile(filePath string) (conf *Config, err error)

type Database

type Database struct {
	*sqlx.DB
}

func NewDatabase

func NewDatabase(driver string, connectString string) (*Database, error)

func (*Database) ContainsTweet

func (db *Database) ContainsTweet(channel string, tweet *ts.Tweet) (bool, error)

func (*Database) GetNewestTweet

func (db *Database) GetNewestTweet(channel string) (*Tweet, error)

func (*Database) GetTweets

func (db *Database) GetTweets(channel string) ([]*Tweet, error)

func (*Database) InsertTweet

func (db *Database) InsertTweet(channel string, tweet *ts.Tweet) error

func (*Database) PruneOldestTweets

func (db *Database) PruneOldestTweets(channel string) error

type Embed

type Embed struct {
	Author      Author  `json:"author,omitempty"`
	Title       string  `json:"title,omitempty"`
	URL         string  `json:"url,omitempty"`
	Description string  `json:"description,omitempty"`
	Timestamp   string  `json:"timestamp,omitempty"`
	Color       int64   `json:"color,omitempty"`
	Fields      []Field `json:"fields,omitempty"`
	Thumbnail   Image   `json:"thumbnail,omitempty"`
	Image       Image   `json:"image,omitempty"`
	Video       Video   `json:"video,omitempty"`
	Footer      Footer  `json:"footer,omitempty"`
}

func (*Embed) AddField

func (e *Embed) AddField(Name, Value string, Inline bool) *Embed

func (*Embed) SetAuthor

func (e *Embed) SetAuthor(Name, URL, IconURL string) *Embed

func (*Embed) SetColor

func (e *Embed) SetColor(color string) (*Embed, error)

func (*Embed) SetFooter

func (e *Embed) SetFooter(Text, IconURL string) *Embed

func (*Embed) SetImage

func (e *Embed) SetImage(URL string) *Embed

func (*Embed) SetText

func (e *Embed) SetText(Description string) *Embed

func (*Embed) SetThumbnail

func (e *Embed) SetThumbnail(URL string) *Embed

func (*Embed) SetTimestamp

func (e *Embed) SetTimestamp(timestamp time.Time) *Embed

func (*Embed) SetTitle

func (e *Embed) SetTitle(Title string) *Embed

func (*Embed) SetVideo

func (e *Embed) SetVideo(URL string) *Embed

type Field

type Field struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline,omitempty"`
}
type Footer struct {
	Text    string `json:"text"`
	IconURL string `json:"icon_url,omitempty"`
}

type Image

type Image struct {
	URL string `json:"url"`
}

type Mention

type Mention struct {
	Parse       []string `json:"parse,omitempty"`
	Roles       []string `json:"roles,omitempty"`
	Users       []string `json:"users,omitempty"`
	RepliedUser bool     `json:"replied_user,omitempty"`
}

type Tweet

type Tweet struct {
	TweetId   int    `db:"tweet_id"`
	Snowflake uint64 `db:"snowflake"`
	Channel   string `db:"channel"`
	Timestamp int64  `db:"timestamp"`
}

func FromTweet

func FromTweet(channel string, tweet *ts.Tweet) (*Tweet, error)

func (*Tweet) Equals

func (t *Tweet) Equals(tweet *Tweet) bool

func (*Tweet) EqualsTweet

func (t *Tweet) EqualsTweet(tweet *ts.Tweet) bool

type Video

type Video struct {
	URL string `json:"url"`
}

type Webhook

type Webhook struct {
	Content string   `json:"content"`
	Name    string   `json:"username,omitempty"`
	Avatar  string   `json:"avatar_url,omitempty"`
	Mention *Mention `json:"allowed_mentions,omitempty"`
	Embeds  []*Embed `json:"embeds,omitempty"`
}

func (*Webhook) NewEmbed

func (w *Webhook) NewEmbed() *Embed

func (*Webhook) NewEmbedWithURL

func (w *Webhook) NewEmbedWithURL(URL string) *Embed

Jump to

Keyboard shortcuts

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