Documentation ¶
Index ¶
- Constants
- Variables
- func BaseEditHandler(inner web.ControllerHandlerFunc) web.ControllerHandlerFunc
- 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 KeyLastVidID(channel string) string
- func KeyLastVidTime(channel string) string
- func RegisterPlugin()
- type ChannelSubscription
- type ContextKey
- type CtxKey
- type Form
- type Link
- type LinkEntry
- type Plugin
- func (p *Plugin) AddFeed(client *redis.Client, guildID, discordChannelID int64, ...) (*ChannelSubscription, error)
- func (p *Plugin) HandleEdit(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)
- func (p *Plugin) HandleFeedUpdate(w http.ResponseWriter, r *http.Request)
- func (p *Plugin) HandleMQueueError(elem *mqueue.QueuedElement, err error)
- func (p *Plugin) HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func (p *Plugin) HandleRemove(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)
- func (p *Plugin) HandleYoutube(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func (p *Plugin) InitBot()
- func (p *Plugin) InitWeb()
- func (p *Plugin) MaybeAddChannelWatch(lock bool, client *redis.Client, channel string) error
- func (p *Plugin) MaybeRemoveChannelWatch(channel string)
- func (p *Plugin) Name() string
- func (p *Plugin) PlaylistID(channelID string) (string, error)
- func (p *Plugin) SetupClient() error
- func (p *Plugin) StartFeed()
- func (p *Plugin) Status(client *redis.Client) (string, string)
- func (p *Plugin) StopFeed(wg *sync.WaitGroup)
- func (p *Plugin) ValidateSubscription(w http.ResponseWriter, r *http.Request, query url.Values)
- func (p *Plugin) WebSubSubscribe(ytChannelID string) error
- func (p *Plugin) WebSubUnsubscribe(ytChannelID string) error
- type XMLFeed
- type YoutubePlaylistID
Constants ¶
const ( MaxChannelsPerPoll = 30 PollInterval = time.Second * 10 WebSubCheckInterval = time.Second * 10 )
const ( RedisChannelsLockKey = "youtube_subbed_channel_lock" GuildMaxFeeds = 50 RedisKeyWebSubChannels = "youtube_registered_websub_channels" GoogleWebsubHub = "https://pubsubhubbub.appspot.com/subscribe" )
Variables ¶
var (
ErrIDNotFound = errors.New("ID not found")
)
var (
ErrNoChannel = errors.New("No channel with that id found")
)
var (
WebSubVerifyToken = os.Getenv("YAGPDB_YOUTUBE_VERIFY_TOKEN")
)
Functions ¶
func BaseEditHandler ¶
func BaseEditHandler(inner web.ControllerHandlerFunc) web.ControllerHandlerFunc
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 KeyLastVidID ¶
func KeyLastVidTime ¶
func RegisterPlugin ¶
func RegisterPlugin()
Types ¶
type ChannelSubscription ¶
type ChannelSubscription struct { common.SmallModel GuildID string ChannelID string YoutubeChannelID string YoutubeChannelName string MentionEveryone bool }
func SubsForChannel ¶
func SubsForChannel(channel string) (result []*ChannelSubscription, err error)
func (*ChannelSubscription) TableName ¶
func (c *ChannelSubscription) TableName() string
type Plugin ¶
type Plugin struct { common.BasePlugin YTService *youtube.Service Stop chan *sync.WaitGroup }
func (*Plugin) HandleEdit ¶
func (p *Plugin) HandleEdit(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)
func (*Plugin) HandleFeedUpdate ¶
func (p *Plugin) HandleFeedUpdate(w http.ResponseWriter, r *http.Request)
func (*Plugin) HandleMQueueError ¶
func (p *Plugin) HandleMQueueError(elem *mqueue.QueuedElement, err error)
Remove feeds if they don't point to a proper channel
func (*Plugin) HandleNew ¶
func (p *Plugin) HandleNew(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func (*Plugin) HandleRemove ¶
func (p *Plugin) HandleRemove(w http.ResponseWriter, r *http.Request) (templateData web.TemplateData, err error)
func (*Plugin) HandleYoutube ¶
func (p *Plugin) HandleYoutube(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func (*Plugin) MaybeAddChannelWatch ¶
maybeAddChannelWatch adds a channel watch to redis, if there wasn't one before
func (*Plugin) MaybeRemoveChannelWatch ¶
maybeRemoveChannelWatch checks the channel for subs, if it has none then it removes it from the watchlist in redis.
func (*Plugin) SetupClient ¶
func (*Plugin) ValidateSubscription ¶
func (*Plugin) WebSubSubscribe ¶
func (*Plugin) WebSubUnsubscribe ¶
type XMLFeed ¶
type XMLFeed struct { Xmlns string `xml:"xmlns,attr"` Link []Link `xml:"link"` ChannelID string `xml:"entry>channelId"` Published string `xml:"entry>published"` VideoId string `xml:"entry>videoId"` Yt string `xml:"yt,attr"` LinkEntry Link `xml:"entry>link"` AuthorUri string `xml:"entry>author>uri"` AuthorName string `xml:"entry>author>name"` UpdatedEntry string `xml:"entry>updated"` Title string `xml:"title"` TitleEntry string `xml:"entry>title"` Id string `xml:"entry>id"` Updated string `xml:"updated"` }