thenovadiary

package module
v0.0.0-...-af225a7 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

README

thenovadiary

Automation for the @thenovadiary Twitter account

Auth
#####
##
#
# Define these in ~/.bashrc or ~/.bash_profile
#
export DIARY_PHOTOPRISMUSER=""
export DIARY_PHOTOPRISMPASS=""
export DIARY_PHOTOPRISMCONN=""
export DIARY_TWITTERTOKEN=""
export DIARY_TWITTERTOKENSECRET=""
export DIARY_TWITTERCONSUMERKEY=""
export DIARY_TWITTERCONSUMERKEYSECRET=""
#
#
##
######

Documentation

Index

Constants

View Source
const (
	DatabaseMode = 0755
	DatabaseName = "cache.db"
	DatabaseDir  = "thenovadiary"
)
View Source
const (

	// BypassSendDailyTweetTwitter
	//
	// Bypass hitting the twitter API for the SendDailyTweet task
	BypassSendDailyTweetTwitter = false

	// BBypassSendDailyTweetCache
	//
	// Bypass saving the cache with an updated last tweet time
	BypassSendDailyTweetCache = false
)
View Source
const (

	// TimeLayoutHuman is the time that is
	// relevant for me and you :)
	TimeLayoutHuman = "2006-01-02T15:04:05"

	// TimeLayout8601 is the ISO 8601 Standard
	TimeLayout8601 = "2006-01-02T15:04:05Z0700"

	// TimeLayoutTimeTime Is the format used by the Go
	// standard library time.Time String() method
	// Use this to decode a time.Time string -> *time.Time
	// instance with time.Parse()
	//
	// 2020-11-05 00:00:00 -0800 PST
	TimeLayoutTimeTime = "2006-01-02 15:04:05 -0700 PST"
)
View Source
const (

	// Default Twitter Values
	// These are constants and if
	// we every change our app account
	// we should update here
	DefaultTwitterHandle = "thenovadiary"
	DefaultTwitterURL    = "https://twitter.com/thenovadiary"

	// The twitter API now accepts tweets with 280 characters
	TwitterLengthLimit = 280
)
View Source
const (
	DailyTweetCacheKey = "dailytweet"
)

Variables

This section is empty.

Functions

func CronIsExpiredDays

func CronIsExpiredDays(timeToCheck time.Time, days int) bool

func DebugConfig

func DebugConfig()

func FindNextPhotoInAlbum

func FindNextPhotoInAlbum(client *photoprism.Client, albumID string) (*api.Photo, error)

func FindPhoto

func FindPhoto(photos []api.Photo) (*api.Photo, error)

FindNextPhoto will list all photos and linear search for a photo that was last updated with the greatest delta in days ago based on the timestamp found in

The function will return unprocessed photos first by design.

func GetCachePath

func GetCachePath(name string) (*os.File, error)

GetCachePath is a deterministic function to return an *os.File based on the system running.

By design this will also ensure the path is writeable and created by this process's file descriptor access.

func GetStatus

func GetStatus(photo api.Photo) string

func SendPhotoTweet

func SendPhotoTweet(twitter *anaconda.TwitterApi, photo api.Photo, pBytes []byte) (string, error)

SendPhotoTweet will return the URL of the sent tweet and/or an error.

func SetCustomData

func SetCustomData(d *CustomData, photo *api.Photo) error

func TimeDeltaDays

func TimeDeltaDays(t1, t2 time.Time) int

TimeDeltaDays will calculate the absolute value of the difference (delta) in days between two given points in time.

func TimeDeltaDaysFromNow

func TimeDeltaDaysFromNow(delta int) time.Time

func TimeStringToTime

func TimeStringToTime(str string) (*time.Time, error)

func TimeTimeToString

func TimeTimeToString(t time.Time) string

func TimeToday

func TimeToday() time.Time

func TimeTomorrow

func TimeTomorrow() time.Time

func TimeYesterday

func TimeYesterday() time.Time

func ValidateConfig

func ValidateConfig(cfg *DiaryConfig) error

Types

type Cache

type Cache struct {
	Name string

	Records map[string]*Record `json:"Records"`
	// contains filtered or unexported fields
}

func NewCache

func NewCache(name string) *Cache

func (*Cache) Clean

func (c *Cache) Clean() error

func (*Cache) Get

func (c *Cache) Get(key string) *Record

func (*Cache) Now

func (c *Cache) Now() string

func (*Cache) Persist

func (c *Cache) Persist() error

func (*Cache) Recover

func (c *Cache) Recover() (int, error)

func (*Cache) Remove

func (c *Cache) Remove(key string)

func (*Cache) Set

func (c *Cache) Set(key string, r *Record)

type CustomData

type CustomData struct {
	LastTweet   *time.Time
	NoteStrings []string
	KeyValue    map[string]string
	Description string
}

func GetCustomData

func GetCustomData(photo api.Photo) *CustomData

type Diary

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

func New

func New(cfg *DiaryConfig) *Diary

func (*Diary) NewPhotoprismClient

func (d *Diary) NewPhotoprismClient() (*photoprism.Client, error)

NewPhotoprismClient will always return a new client with a fresh token

func (*Diary) SendDailyTweet

func (d *Diary) SendDailyTweet() error

func (*Diary) Service

func (d *Diary) Service() error

type DiaryConfig

type DiaryConfig struct {
	Name                     string // Unique identifier for logs
	TwitterToken             string
	TwitterTokenSecret       string
	TwitterConsumerKey       string
	TwitterConsumerKeySecret string
	PhotoprismPass           string
	PhotoprismUser           string
	PhotoprismConn           string
	PhotoprismAlbum          string
	// contains filtered or unexported fields
}

type Record

type Record struct {
	Found bool
	Key   string
	Value interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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