Documentation ¶
Index ¶
- Constants
- Variables
- func FindFeed(feeds []*models.RedditFeed, id int64) *models.RedditFeed
- func HandleModify(w http.ResponseWriter, r *http.Request) interface{}
- func HandleNew(w http.ResponseWriter, r *http.Request) interface{}
- func HandleReddit(w http.ResponseWriter, r *http.Request) interface{}
- func HandleRemove(w http.ResponseWriter, r *http.Request) interface{}
- func MaxFeedForCtx(ctx context.Context) int
- func RegisterPlugin()
- func UserAgent() string
- type CreateForm
- type CtxKey
- type KeyFastFeeds
- type KeySlowFeeds
- type Plugin
- func (p *Plugin) AddCommands()
- func (p *Plugin) DisableFeed(elem *mqueue.QueuedElement, err error)
- func (p *Plugin) InitWeb()
- func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func (p *Plugin) OnRemovedPremiumGuild(guildID int64) error
- func (p *Plugin) PluginInfo() *common.PluginInfo
- func (p *Plugin) RemoveGuild(g int64) error
- func (p *Plugin) StartFeed()
- func (p *Plugin) Status() (string, string)
- func (p *Plugin) StopFeed(wg *sync.WaitGroup)
- func (p *Plugin) WebhookAvatar() string
- type PostFetcher
- type PostHandler
- type PostHandlerImpl
- type PubSubSubredditEventData
- type RatelimitWindow
- type Ratelimiter
- type RedditIdSlice
- type UpdateForm
Constants ¶
View Source
const ( FilterNSFWNone = 0 // allow both nsfw and non nsfw content FilterNSFWIgnore = 1 // only allow non-nsfw content FilterNSFWRequire = 2 // only allow nsfw content )
View Source
const ( // Max feeds per guild GuildMaxFeedsNormal = 20 GuildMaxFeedsPremium = 1000 )
View Source
const RedditLogoPNGB64 = `` /* 2110-byte string literal not displayed */
Variables ¶
View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS reddit_feeds (
id BIGSERIAL PRIMARY KEY,
guild_id BIGINT NOT NULL,
channel_id BIGINT NOT NULL,
subreddit TEXT NOT NULL,
-- 0 = none, 1 = ignore, 2 - whitelist
filter_nsfw INT NOT NULL,
min_upvotes INT NOT NULL,
use_embeds BOOLEAN NOT NULL,
slow BOOLEAN NOT NULL
);
`, `
CREATE INDEX IF NOT EXISTS redidt_feeds_guild_idx ON reddit_feeds(guild_id);
`, `
CREATE INDEX IF NOT EXISTS redidt_feeds_subreddit_idx ON reddit_feeds(subreddit);
`, `
ALTER TABLE reddit_feeds ADD COLUMN IF NOT EXISTS disabled BOOLEAN NOT NULL DEFAULT FALSE;
`, `
ALTER TABLE reddit_feeds ADD COLUMN IF NOT EXISTS spoilers_enabled BOOLEAN NOT NULL DEFAULT TRUE;
`}
View Source
var KeyLastScannedPostIDFast = "reddit_last_post_id"
View Source
var KeyLastScannedPostIDSlow = "reddit_slow_last_post_id"
View Source
var PageHTML string
Functions ¶
func FindFeed ¶
func FindFeed(feeds []*models.RedditFeed, id int64) *models.RedditFeed
func HandleModify ¶
func HandleModify(w http.ResponseWriter, r *http.Request) interface{}
func HandleReddit ¶
func HandleReddit(w http.ResponseWriter, r *http.Request) interface{}
func HandleRemove ¶
func HandleRemove(w http.ResponseWriter, r *http.Request) interface{}
func MaxFeedForCtx ¶
func RegisterPlugin ¶
func RegisterPlugin()
Types ¶
type CreateForm ¶
type CreateForm struct { Subreddit string `schema:"subreddit" valid:",1,100"` Slow bool `schema:"slow"` Channel int64 `schema:"channel" valid:"channel,true"` ID int64 `schema:"id"` UseEmbeds bool `schema:"use_embeds"` NSFWMode int `schema:"nsfw_filter"` SpoilersEnabled bool `schema:"spoilers_enabled"` MinUpvotes int `schema:"min_upvotes" valid:"0,"` }
type KeyFastFeeds ¶
type KeyFastFeeds string
type KeySlowFeeds ¶
type KeySlowFeeds string
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) AddCommands ¶
func (p *Plugin) AddCommands()
func (*Plugin) DisableFeed ¶
func (p *Plugin) DisableFeed(elem *mqueue.QueuedElement, err error)
Remove feeds if they don't point to a proper channel
func (*Plugin) LoadServerHomeWidget ¶
func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func (*Plugin) OnRemovedPremiumGuild ¶ added in v2.17.0
func (*Plugin) PluginInfo ¶
func (p *Plugin) PluginInfo() *common.PluginInfo
func (*Plugin) RemoveGuild ¶
func (*Plugin) WebhookAvatar ¶
type PostFetcher ¶
type PostFetcher struct { Name string LastScannedPostIDKey string LastID int64 StopChan chan *sync.WaitGroup // contains filtered or unexported fields }
PostFetcher is responsible from fetching posts from reddit at a given interval and delay delay bieng it will make sure not to call the handler on posts newer than the given delay
func NewPostFetcher ¶
func NewPostFetcher(redditClient *greddit.Client, slow bool, handler PostHandler) *PostFetcher
func (*PostFetcher) GetNewPosts ¶
func (p *PostFetcher) GetNewPosts() ([]*greddit.Link, error)
func (*PostFetcher) Run ¶
func (p *PostFetcher) Run()
type PostHandler ¶
func NewPostHandler ¶
func NewPostHandler(slow bool) PostHandler
type PostHandlerImpl ¶
type PostHandlerImpl struct { Slow bool // contains filtered or unexported fields }
func (*PostHandlerImpl) FilterFeeds ¶
func (p *PostHandlerImpl) FilterFeeds(feeds []*models.RedditFeed, post *reddit.Link) []*models.RedditFeed
func (*PostHandlerImpl) HandleRedditPosts ¶
func (p *PostHandlerImpl) HandleRedditPosts(links []*reddit.Link)
type Ratelimiter ¶
type Ratelimiter struct { Windows []*RatelimitWindow // contains filtered or unexported fields }
func NewRatelimiter ¶
func NewRatelimiter() *Ratelimiter
func (*Ratelimiter) CheckIncrement ¶
func (*Ratelimiter) FullGC ¶
func (r *Ratelimiter) FullGC(t time.Time)
func (*Ratelimiter) RunGCLoop ¶
func (r *Ratelimiter) RunGCLoop()
type RedditIdSlice ¶
type RedditIdSlice []string
func (RedditIdSlice) Len ¶
func (r RedditIdSlice) Len() int
Len is the number of elements in the collection.
func (RedditIdSlice) Less ¶
func (r RedditIdSlice) Less(i, j int) bool
Less reports whether the element with index i should sort before the element with index j.
func (RedditIdSlice) Swap ¶
func (r RedditIdSlice) Swap(i, j int)
Swap swaps the elements with indexes i and j.
type UpdateForm ¶
type UpdateForm struct { Channel int64 `schema:"channel" valid:"channel,true"` ID int64 `schema:"id"` UseEmbeds bool `schema:"use_embeds"` NSFWMode int `schema:"nsfw_filter"` SpoilersEnabled bool `schema:"spoilers_enabled"` MinUpvotes int `schema:"min_upvotes" valid:"0,"` FeedEnabled bool `schema:"feed_enabled"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.