feedbot package - github.com/foxbot/feedbot - Go Packages

feedbot

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

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

Go to latest
Published: Oct 15, 2018 License: ISC Imports: 14 Imported by: 0

README

feedbot

A Discord Bot for RSS feeds.

License

Licensed under ISC. See LICENSE.md.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSubExists is returned when a subscription already exists for a feed/channel
	ErrSubExists = errors.New("a subscription already exists")
)

Functions

This section is empty.

Types

type Bot

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

Bot contains the Bot's state

func NewBot

func NewBot(token string) (*Bot, error)

NewBot creates a new bot instance

func (*Bot) Run

func (bot *Bot) Run() error

Run the bot

type Controller

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

Controller contains logic for manipulating the database

func NewController

func NewController() (*Controller, error)

NewController creates a new controller

func (*Controller) AddSubscription

func (c *Controller) AddSubscription(channelID, guildID string, feedID int) (*Subscription, error)

AddSubscription adds a subscription to the given feed for a channel

func (*Controller) CreateGuildConfig

func (c *Controller) CreateGuildConfig(guildID string, ownerContact string) error

CreateGuildConfig creates an empty GuildConfig for a guild

func (*Controller) CreateTables

func (c *Controller) CreateTables() error

CreateTables should only be called once; this will initalize the database for use with the bot.

func (*Controller) DestroyGuildData

func (c *Controller) DestroyGuildData(guildID string)

DestroyGuildData removes all data assosciated with a guild.

func (*Controller) DestroySubscription

func (c *Controller) DestroySubscription(id int) error

DestroySubscription deletes a subscription from the database

func (*Controller) GetFeeds

func (c *Controller) GetFeeds() ([]Feed, error)

GetFeeds will get a list of feeds to query from the database

func (*Controller) GetGuildConfig

func (c *Controller) GetGuildConfig(guildID string) (*GuildConfig, error)

GetGuildConfig gets a guild's config

func (*Controller) GetOrCreateFeed

func (c *Controller) GetOrCreateFeed(uri string) (*Feed, error)

GetOrCreateFeed will insert a new RSS Feed to the database if one does not exist, and return a Feed for it.

func (*Controller) GetSubscription

func (c *Controller) GetSubscription(id int) (*Subscription, error)

GetSubscription gets a subscription from its ID

func (*Controller) GetSubscriptions

func (c *Controller) GetSubscriptions(guildID string) ([]Subscription, error)

GetSubscriptions selects all subscriptions for a given guild

func (*Controller) ModifyGuildContact

func (c *Controller) ModifyGuildContact(guildID string, contact string) error

ModifyGuildContact changes the guild's contact address

func (*Controller) ModifyGuildEmbeds

func (c *Controller) ModifyGuildEmbeds(guildID string, embeds bool) error

ModifyGuildEmbeds changes the guild's embed rule

func (*Controller) ModifyGuildWebhooks

func (c *Controller) ModifyGuildWebhooks(guildID string, embeds bool) error

ModifyGuildWebhooks changes the guild's webhook rule

func (*Controller) ModifyOverwriteEmbeds

func (c *Controller) ModifyOverwriteEmbeds(subID int, embeds sql.NullBool) error

ModifyOverwriteEmbeds changes the embeds policy of a subscription overwrite

func (*Controller) ModifyOverwriteWebhooks

func (c *Controller) ModifyOverwriteWebhooks(subID int, webhooks sql.NullBool) error

ModifyOverwriteWebhooks changes the webhooks policy of a subscription overwrite

func (*Controller) ModifySubscriptionChannel

func (c *Controller) ModifySubscriptionChannel(id int, channelID string) error

ModifySubscriptionChannel changes the channel_id for a Subscription

func (*Controller) UpdateFeedTimestamp

func (c *Controller) UpdateFeedTimestamp(feed *Feed, timestamp *time.Time) error

UpdateFeedTimestamp updates a feed's last_updated value

type Feed

type Feed struct {
	ID          int
	URI         string
	LastUpdated time.Time
}

Feed contains the ID and URI of a RSS feed in the database

type FeedChecker

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

FeedChecker contains the application logic for checking RSS feeds

func NewFeedChecker

func NewFeedChecker(c *Controller) (*FeedChecker, error)

NewFeedChecker creates a new FeedChecker

func (*FeedChecker) Close

func (f *FeedChecker) Close()

Close disposes of the FeedChecker

type GuildConfig

type GuildConfig struct {
	ID       string
	Contact  string
	Embeds   bool
	Webhooks bool
}

GuildConfig contains guild-wide configuration

type Overwrite

type Overwrite struct {
	ID             int
	SubscriptionID int
	Embeds         sql.NullBool
	Webhooks       sql.NullBool
}

Overwrite contains a subscription overwrite

type Subscription

type Subscription struct {
	ID        int
	GuildID   string
	ChannelID string
	FeedID    int
	Feed      *Feed
	Overwrite *Overwrite
}

Subscription contains the metadata for a subscription to a feed

Directories

Path Synopsis
cmd
feedbot command
migrate command

Jump to

Keyboard shortcuts

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