wotd

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tweet

func Tweet(wo *Word, w http.ResponseWriter) *ent.AppError

Types

type CloudStorageClientWrapper

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

func (*CloudStorageClientWrapper) Client

func (*CloudStorageClientWrapper) GetObject

func (csc *CloudStorageClientWrapper) GetObject(ctx context.Context, bucketName, fn string) ([]byte, error)

type Dictionary

type Dictionary struct {
	Words []Word `json:"dictionary"`
}

Dictionary is the parent element of json file

type MastodonClient

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

func (*MastodonClient) NewClient

func (mclient *MastodonClient) NewClient()

func (*MastodonClient) Toot

func (mclient *MastodonClient) Toot(wo *Word, w http.ResponseWriter, bucketName string) *ent.AppError

type MastodonCredential

type MastodonCredential struct {
	MastodonServerName  string
	MastodonClientID    string
	MastodonAccessToken string
}

MastodonCredential is a wrapper for consumer and access secrets

type TwitterClient

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

TwitterClient is a wrapper for twitter client implementation

func NewTwitterClient

func NewTwitterClient(credential *TwitterCredential) *TwitterClient

NewTwitterClient returns an authenticated instance of Twitter client

func (*TwitterClient) SendTweet

func (tc *TwitterClient) SendTweet(message string) (*twitter.Tweet, *http.Response, error)

SendTweet updates the authenticated account with a new tweet

type TwitterCredential

type TwitterCredential struct {
	ConsumerKey    string
	ConsumerSecret string
	AccessToken    string
	AccessSecret   string
}

TwitterCredential is a wrapper for consumer and access secrets

type Word

type Word struct {
	Index       int    `json:"index"`
	Word        string `json:"word"`
	Meaning     string `json:"meaning"`
	Link        string `json:"link"`
	Photo       string `json:"photo"`
	Attribution string `json:"photo_attribution"`
}

Word is the wrapper around each word and it's meaning

type WordSelector

type WordSelector struct {
}

WordSelector reads, parses, and selects the word-of-the-day

func (*WordSelector) ParseFile

func (ws *WordSelector) ParseFile(f []byte) (*Dictionary, error)

ParseFile unmarshal a json string to the struct type

func (*WordSelector) ReadFile

func (ws *WordSelector) ReadFile() ([]byte, error)

ReadFile reads dictionary json file

func (*WordSelector) SelectWordByDay

func (ws *WordSelector) SelectWordByDay(words []Word) *Word

SelectWordByDay selects a word from the provided array based on the day of the year

func (*WordSelector) SelectWordByIndex

func (ws *WordSelector) SelectWordByIndex(words []Word, index int) *Word

SelectWordByIndex selects a word from the provided array based on the day of the year

Jump to

Keyboard shortcuts

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