knowbody

package
v0.0.0-...-3d2fae1 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CurrentConfig is what Knowbody currently sees as the config
	// Think "State" but for the config
	CurrentConfig Config
	// State is... the current state.
	State CurrentState
)

Functions

func DownloadFile

func DownloadFile(filepath string, url string) error

DownloadFile downloads files. Pretty simple.

func Lint

func Lint()

Lint simply reads the two primary files and ensures they can be parsed.

func ReadConfig

func ReadConfig()

ReadConfig will attempt to download the master config from GitHub. It then reads the current conf.yaml file on the file system and updates all the internal data structures

func ReadState

func ReadState()

ReadState looks reads /tmp/knowbody.lock and pushes it into the State variable

func Start

func Start()

Start starts the loop to look at all the things

func WriteState

func WriteState()

WriteState takes the state and dumps it to /tmp/knowbody.lock We like keeping track of state. This allows Knowbody to crash and recover without issue. Because we're lazy goddammit.

Types

type Config

type Config struct {
	Streams    []ContentStream `yaml:"streams"`
	SlackToken string          `yaml:"slackToken"`
}

Config holds all info to run Knowbody

type ContentState

type ContentState struct {
	Stream  ContentStream `yaml:"stream"`
	RSSId   string        `yaml:"rssId"`
	RSSTime time.Time     `yaml:"rssTime"`
}

ContentState tracks the current state of a specific ContentStream

type ContentStream

type ContentStream struct {
	Name    string `yaml:"name"`   // name of the stream. preferably unique.
	Source  string `yaml:"source"` // rss feed (https://twitrss.me/twitter_user_to_rss/?user=jeefy or https://danielmiessler.com/blog/rss-feed-youtube-channel/)
	Type    string `yaml:"type"`
	Channel string `yaml:"channel"` // slack channel in the workspace
	Exclude string `yaml:"exclude"` // regex of content to exclude from this source cannot be set with include.
	Include string `yaml:"include"` // regex of content to include from this source. cannot be set with exclude.
	Spoiler bool   `yaml:"spoiler"` // boolean to indicate if it should post in a thread instead of in channel.
	// contains filtered or unexported fields
}

ContentStream is a mapping of rss-feed to slack channel

func (*ContentStream) Process

func (stream *ContentStream) Process(c chan Message)

Process will attempt to read and handle a specific ContentStream's RSS feed

type CurrentState

type CurrentState struct {
	Streams  map[string]ContentState `yaml:"streams"`
	Channels map[string]string       `yaml:"channels"`
	LastRun  time.Time               `yaml:"lastRun"`
	// contains filtered or unexported fields
}

CurrentState tracks the overall running state of Knowbody

type Message

type Message struct {
	Channel string
	Link    string
	Title   string
	Spoiler bool
}

Message represents slack messages to send

Jump to

Keyboard shortcuts

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