Documentation ¶
Index ¶
- Constants
- Variables
- func CreatePostEmbed(post *reddit.Link) *discordgo.MessageEmbed
- func Dir(useLocal bool, name string) http.FileSystem
- func FS(useLocal bool) http.FileSystem
- func FSByte(useLocal bool, name string) ([]byte, error)
- func FSMustByte(useLocal bool, name string) []byte
- func FSMustString(useLocal bool, name string) string
- func FSString(useLocal bool, name string) (string, error)
- 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 RegisterPlugin()
- func UserAgent() string
- type CtxKey
- type Form
- type Plugin
- func (p *Plugin) HandleMQueueError(elem *mqueue.QueuedElement, err error)
- func (p *Plugin) InitBot()
- func (p *Plugin) InitWeb()
- func (p *Plugin) Name() string
- func (p *Plugin) RemoveGuild(c *redis.Client, g int64) error
- func (p *Plugin) StartFeed()
- func (p *Plugin) Status(client *redis.Client) (string, string)
- func (p *Plugin) StopFeed(wg *sync.WaitGroup)
- type PostFetcher
- type RedditIdSlice
- type SubredditWatchItem
Constants ¶
const (
// Max feeds per guild
GuildMaxFeeds = 100
)
Variables ¶
var ( ClientID = os.Getenv("YAGPDB_REDDIT_CLIENTID") ClientSecret = os.Getenv("YAGPDB_REDDIT_CLIENTSECRET") RedirectURI = os.Getenv("YAGPDB_REDDIT_REDIRECT") RefreshToken = os.Getenv("YAGPDB_REDDIT_REFRESHTOKEN") )
var KeyLastScannedPostID = "reddit_last_post_id"
Functions ¶
func CreatePostEmbed ¶
func CreatePostEmbed(post *reddit.Link) *discordgo.MessageEmbed
func Dir ¶
func Dir(useLocal bool, name string) http.FileSystem
Dir returns a http.Filesystem for the embedded assets on a given prefix dir. If useLocal is true, the filesystem's contents are instead used.
func FS ¶
func FS(useLocal bool) http.FileSystem
FS returns a http.Filesystem for the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSByte ¶
FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.
func FSMustByte ¶
FSMustByte is the same as FSByte, but panics if name is not present.
func FSMustString ¶
FSMustString is the string version of FSMustByte.
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 RegisterPlugin ¶
func RegisterPlugin()
Types ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) HandleMQueueError ¶
func (p *Plugin) HandleMQueueError(elem *mqueue.QueuedElement, err error)
Remove feeds if they don't point to a proper channel
type PostFetcher ¶
type PostFetcher struct { LastID int64 // contains filtered or unexported fields }
func NewPostFetcher ¶
func NewPostFetcher(redditClient *reddit.Client, redisClient *redis.Client) *PostFetcher
func (*PostFetcher) GetNewPosts ¶
func (p *PostFetcher) GetNewPosts() ([]*reddit.Link, error)
func (*PostFetcher) InitCursor ¶
func (p *PostFetcher) InitCursor() (int64, error)
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 SubredditWatchItem ¶
type SubredditWatchItem struct { Sub string `json:"sub"` Guild string `json:"guild"` Channel string `json:"channel"` ID int `json:"id"` }
func FindWatchItem ¶
func FindWatchItem(source []*SubredditWatchItem, id int) *SubredditWatchItem