controllers

package
v0.0.0-...-23acba9 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PostHealthcheckToDiscord

func PostHealthcheckToDiscord(healthcheck HealthcheckWebsiteResult) string

func PostToDiscord

func PostToDiscord(item StoredItem) string

func PutMainItem

func PutMainItem(item MainItem) string

func StoreItems

func StoreItems(items TwitterSearchResult, keyword string) string

func TranslateToEnglish

func TranslateToEnglish(originalText string, languageCode string) string

Types

type DiscordBotCredentials

type DiscordBotCredentials struct {
	Username string `json:"Username"`
	Token    string `json:"Token"`
}

func GetDiscordCredentials

func GetDiscordCredentials() DiscordBotCredentials

type DownforHttpCheckResponse

type DownforHttpCheckResponse struct {
	StatusCode int    `json:"statusCode"`
	StatusText string `json:"statusText"`
	IsDown     bool   `json:"isDown"`
}

type DynamoDBMainItem

type DynamoDBMainItem struct {
	PK        string // ID
	SK        string
	GSI1PK    string // Type
	GSI1SK    string
	UpdatedAt string
	Data      string
}

type DynamoDBNewKeywordItem

type DynamoDBNewKeywordItem struct {
	PK     string // ID
	SK     string // ItemIndex
	GSI1PK string // "ALL"
	GSI1SK string // HappenedAt
	GSI2PK string // SourceType|Keyword
	GSI2SK string // HappenedAt
}

type DynamoDBStoredItem

type DynamoDBStoredItem struct {
	PK     string // ID
	SK     string // ItemIndex
	GSI1PK string // "ALL"
	GSI1SK string // HappenedAt
	GSI2PK string // SourceType|Keyword
	GSI2SK string // HappenedAt
	Link   string
	Data   TwitterData
}

type GenericConfig

type GenericConfig struct {
	Channels []string `yaml:"channels"`
}

type HealthcheckWebsiteResult

type HealthcheckWebsiteResult struct {
	Website string
	IsUp    bool
}

type KeywordConfig

type KeywordConfig struct {
	Value    string   `yaml:"value"`
	Channels []string `yaml:"channels"`
}

type MainItem

type MainItem struct {
	ID        string // Type|ID
	Type      string // healthcheck
	UpdatedAt time.Time
	Data      string
}

func FromDynamoDBMainItemToMainItem

func FromDynamoDBMainItemToMainItem(dbitem DynamoDBMainItem) (MainItem, error)

func GetMainItem

func GetMainItem(key MainItemKey) (MainItem, error)

type MainItemKey

type MainItemKey struct {
	// HOW-TO do Pick<MainItem, "PK | SK"> ??
	PK string
	SK string
}

type MappingsConfig

type MappingsConfig struct {
	Keyword     []KeywordConfig `yaml:"keywords"`
	HealthCheck GenericConfig   `yaml:"healthcheck"`
}

func GetMappingsConfig

func GetMappingsConfig() MappingsConfig

type NewKeywordItem

type NewKeywordItem struct {
	ID         string // Source|Hash
	ItemIndex  int    // 0 = initial, >0 = aggregate
	HappenedAt time.Time
	SourceType string // twitter
	Keyword    string
	Type       string // NewKeyword
}

type StoredItem

type StoredItem struct {
	ID         string // Source|Hash
	ItemIndex  int    // 0 = initial, >0 = aggregate
	HappenedAt time.Time
	SourceType string // twitter
	Keyword    string
	Link       string
	Data       TwitterData
}

func FromDynamoDStoredItemToMainItem

func FromDynamoDStoredItemToMainItem(dbitem DynamoDBStoredItem) (StoredItem, error)

func GetStoredItem

func GetStoredItem(key StoredItemKey) (StoredItem, error)

type StoredItemKey

type StoredItemKey struct {
	// HOW-TO: do Pick<StoredItem, "PK | SK"> ??
	PK string
	SK string
}

type TwitterBotCredentials

type TwitterBotCredentials struct {
	APIKey       string `json:"ApiKey"`
	APISecretKey string `json:"ApiSecretKey"`
	BearerToken  string `json:"BearerToken"`
}

func GetTwitterCredentials

func GetTwitterCredentials() TwitterBotCredentials

type TwitterData

type TwitterData struct {
	TwitterSearchResultTweet        // important: don't use a comma here
	TranslatedText           string `json:"translated_text"`
}

type TwitterGetUserDetailResult

type TwitterGetUserDetailResult struct {
	Data struct {
		PublicMetrics struct {
			Followers int `json:"followers_count"`
		} `json:"public_metrics"`
	} `json:"data"`
}

type TwitterSearchResult

type TwitterSearchResult struct {
	Data []TwitterSearchResultTweet  `json:"data"`
	Meta TwitterSearchResultMetadata `json:"meta"`
}

func SearchTwitter

func SearchTwitter(keyword string) TwitterSearchResult

type TwitterSearchResultMetadata

type TwitterSearchResultMetadata struct {
	NewestID    string `json:"newest_id"`
	OldestID    string `json:"oldest_id"`
	ResultCount int    `json:"result_count"`
	NextToken   string `json:"next_token"`
}

type TwitterSearchResultTweet

type TwitterSearchResultTweet struct {
	ID             string    `json:"id"`
	Text           string    `json:"text"`
	CreatedAt      time.Time `json:"created_at"`
	ConversationID string    `json:"conversation_id"`
	AuthorID       string    `json:"author_id"`
	Lang           string    `json:"lang"`
}

type TwitterUserDetails

type TwitterUserDetails struct {
	ID        string `json:"id"`
	Followers int    `json:"followers"`
}

func GetTwitterUserDetails

func GetTwitterUserDetails(userId string) (TwitterUserDetails, error)

Jump to

Keyboard shortcuts

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