Versions in this module Expand all Collapse all v1 v1.24.19 Mar 7, 2021 Changes in this version + const SidebarCategoryCore + var ConfAdsTxt = config.RegisterOption("yagpdb.ads.ads_txt", ...) + var ErrDuplicateToken = errors.New("Somehow a duplicate token was found") + var OauthConf *oauth2.Config + var StaticFileserverDir = "." + var TestingTemplatePathResolver func(in string) string + func CSRFProtectionMW(inner http.Handler) http.Handler + func GetIsReadOnly(ctx context.Context) bool + func GetUserAccessLevel(userID int64, g *common.GuildWithConnected, config *models.CoreConfig, ...) (hasRead bool, hasWrite bool) + func HandleStatusJSON(w http.ResponseWriter, r *http.Request) interface + func NewLogEntryFromContext(ctx context.Context, action string, params ...*cplogs.Param) *cplogs.LogEntry + func RequireBotOwnerMW(inner http.Handler) http.Handler + type BotStatus struct + EventsPerSecondAverage float64 + EventsPerSecondMax float64 + EventsPerSecondMin float64 + HostStatuses []*HostStatus + NumNodes int + OfflineShards []int + TotalShards int + UnavailableGuilds int + UptimeMax time.Duration + UptimeMin time.Duration + type HostStatus struct + EventsPerSecond float64 + Name string + Nodes []*botrest.NodeStatus + TotalEvents int64 type SidebarItem + CustomIconImage string + External bool + Icon string + New bool type TemplateData + func HandleStatusHTML(w http.ResponseWriter, r *http.Request) (TemplateData, error) v1.20.6 Sep 3, 2019 Changes in this version + const AlertDanger + const AlertInfo + const AlertSuccess + const AlertWarning + const SessionCookieName + const SidebarCategoryFeeds + const SidebarCategoryFun + const SidebarCategoryTools + const SidebarCategoryTopLevel + var CPMux *goji.Mux + var ConfAdVideos = config.RegisterOption("yagpdb.ad.video_paths", ...) + var CurrentAd *Advertisement + var Debug = true + var ErrChannelNotFound = errors.New("Channel not found") + var ErrNotLoggedIn = errors.New("Not logged in") + var ErrRoleNotFound = errors.New("Role not found") + var ErrTokenExpired = errors.New("OAUTH2 Token expired") + var ListenAddressHTTP = ":5000" + var ListenAddressHTTPS = ":5001" + var RootMux *goji.Mux + var ServerPubliAPIMux *goji.Mux + var ServerPublicMux *goji.Mux + var StartedAt = time.Now() + var Templates *template.Template + var WidgetCache = cache.New(time.Second * 10, time.Second * 10) + func APIHandler(inner CustomHandlerFunc) http.Handler + func ActiveServerMW(inner http.Handler) http.Handler + func AddGlobalTemplateData(key string, data interface{}) + func AddSidebarItem(category string, sItem *SidebarItem) + func AuthTokenFromB64(b64 string) (t *oauth2.Token, err error) + func BaseTemplateDataMiddleware(inner http.Handler) http.Handler + func BaseURL() string + func CheckCSRFToken(token string) (bool, error) + func CheckErr(t TemplateData, err error, errMsg string, logger func(...interface{})) bool + func ContextGuild(ctx context.Context) *discordgo.Guild + func ContextIsAdmin(ctx context.Context) bool + func ContextMember(ctx context.Context) *discordgo.Member + func ContextMemberPerms(ctx context.Context) int + func ContextUser(ctx context.Context) *discordgo.User + func ControllerHandler(f ControllerHandlerFunc, templateName string) http.Handler + func ControllerPostHandler(mainHandler ControllerHandlerFunc, extraHandler http.Handler, ...) http.Handler + func CreateCSRFToken() (string, error) + func CreateCookieSession(token *oauth2.Token) (cookie *http.Cookie, err error) + func CtxLogger(ctx context.Context) *logrus.Entry + func DiscordSessionFromContext(ctx context.Context) *discordgo.Session + func EnabledDisabledSpanStatus(enabled bool) (str string) + func FormParserMW(inner http.Handler, dst interface{}) http.Handler + func GenSessionCookie() *http.Cookie + func GetRequestIP(r *http.Request) string + func GetUserGuilds(ctx context.Context) ([]*common.GuildWithConnected, error) + func GuildScopeCacheMW(plugin common.Plugin, inner http.Handler) http.Handler + func HandleCPLogs(w http.ResponseWriter, r *http.Request) interface + func HandleChanenlPermissions(w http.ResponseWriter, r *http.Request) interface + func HandleConfirmLogin(w http.ResponseWriter, r *http.Request) + func HandleLogin(w http.ResponseWriter, r *http.Request) + func HandleLogout(w http.ResponseWriter, r *http.Request) + func HandleSelectServer(w http.ResponseWriter, r *http.Request) interface + func HasAccesstoGuildSettings(userID int64, g *common.GuildWithConnected, config *models.CoreConfig, ...) bool + func HasPermissionCTX(ctx context.Context, aperms int) bool + func Indicator(enabled bool) string + func InitOauth() + func IsAcceptingRequests() bool + func IsAdminRequest(ctx context.Context, r *http.Request) bool + func IsRequestPartial(ctx context.Context) bool + func LoadAd() + func LoadCoreConfigMiddleware(inner http.Handler) http.Handler + func LoadHTMLTemplate(pathTesting, pathProd string) + func LogIgnoreErr(err error) + func MiscMiddleware(inner http.Handler) http.Handler + func NewPublicError(a ...interface{}) error + func ParamOrEmpty(r *http.Request, key string) string + func RandBase64(size int) string + func RenderHandler(inner CustomHandlerFunc, tmpl string) http.Handler + func RequestLogger(logger io.Writer) func(http.Handler) http.Handler + func RequireActiveServer(inner http.Handler) http.Handler + func RequireBotMemberMW(inner http.Handler) http.Handler + func RequireGuildChannelsMiddleware(inner http.Handler) http.Handler + func RequirePermMW(perms ...int) func(http.Handler) http.Handler + func RequireServerAdminMiddleware(inner http.Handler) http.Handler + func RequireSessionMiddleware(inner http.Handler) http.Handler + func Run() + func SessionMiddleware(inner http.Handler) http.Handler + func SetContextTemplateData(ctx context.Context, data map[string]interface{}) context.Context + func SetGuildMemberMiddleware(inner http.Handler) http.Handler + func SimpleConfigSaverHandler(t SimpleConfigSaver, extraHandler http.Handler) http.Handler + func SkipStaticMW(maybeSkip func(http.Handler) http.Handler, alwaysRunSuffixes ...string) func(http.Handler) http.Handler + func StaticRoleProvider(roles []int64) func(guildID, userID int64) []int64 + func Stop() + func UserInfoMiddleware(inner http.Handler) http.Handler + func ValidateChannelField(s int64, channels []*discordgo.Channel, allowEmpty bool) error + func ValidateFloatField(f float64, min, max float64) error + func ValidateForm(guild *discordgo.Guild, tmpl TemplateData, form interface{}) bool + func ValidateIntField(i int64, tags *ValidationTag, guild *discordgo.Guild) (keep bool, err error) + func ValidateIntMinMaxField(i int64, min, max int64) error + func ValidateIntSliceField(is []int64, tags *ValidationTag, guild *discordgo.Guild) (filtered []int64, err error) + func ValidateNormalStringField(s string, min, max int) error + func ValidateRegexField(s string, max int) error + func ValidateRoleField(s int64, roles []*discordgo.Role, allowEmpty bool) error + func ValidateStringField(s string, tags *ValidationTag, guild *discordgo.Guild) (str string, err error) + func ValidateTemplateField(s string, max int) error + func WriteErrorResponse(w http.ResponseWriter, r *http.Request, err string, statusCode int) + type APIError struct + Message string + type Advertisement struct + Height int + LinkURL template.URL + Path template.URL + VideoTypes []string + VideoUrls []template.URL + Width int + type Alert struct + Message string + Style string + func ErrorAlert(args ...interface{}) *Alert + func SucessAlert(args ...interface{}) *Alert + func WarningAlert(args ...interface{}) *Alert + type ControlPanelPlugin struct + func (p *ControlPanelPlugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func (p *ControlPanelPlugin) PluginInfo() *common.PluginInfo + func (p *ControlPanelPlugin) ServerHomeWidgetOrder() int + type ControllerHandlerFunc func(w http.ResponseWriter, r *http.Request) (TemplateData, error) + type ControllerHandlerFuncJson func(w http.ResponseWriter, r *http.Request) (interface{}, error) + type CoreConfigPostForm struct + AllowAllMembersReadOnly bool + AllowNonMembersReadOnly bool + AllowedReadOnlyRoles []int64 + AllowedWriteRoles []int64 + type CustomHandlerFunc func(w http.ResponseWriter, r *http.Request) interface + type CustomResponseWriter struct + func (c *CustomResponseWriter) Header() http.Header + func (c *CustomResponseWriter) Write(b []byte) (int, error) + func (c *CustomResponseWriter) WriteHeader(statusCode int) + type CustomValidator interface + Validate func(tmplData TemplateData) (ok bool) + type Plugin interface + InitWeb func() + type PluginWithServerHomeWidget interface + LoadServerHomeWidget func(w http.ResponseWriter, r *http.Request) (TemplateData, error) + type PluginWithServerHomeWidgetMiddlewares interface + ServerHomeWidgetApplyMiddlewares func(inner http.Handler) http.Handler + type PublicError struct + func (p *PublicError) Error() string + type RenderedServerHomeWidget struct + Body template.HTML + Enabled bool + Title template.HTML + type ServerHomeWidgetWithOrder interface + ServerHomeWidgetOrder func() int + type SidebarItem struct + Name string + URL string + type SimpleConfigSaver interface + Name func() string + Save func(guildID int64) error + type TemplateData map[string]interface + func (t TemplateData) AddAlerts(alerts ...*Alert) TemplateData + func (t TemplateData) Alerts() []*Alert + func GetBaseCPContextData(ctx context.Context) (*discordgo.Guild, TemplateData) + func GetCreateTemplateData(ctx context.Context) (context.Context, TemplateData) + func HandleGetManagedGuilds(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func HandleLandingPage(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func HandlePostCoreSettings(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func HandleReconnectShard(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func HandleServerHome(w http.ResponseWriter, r *http.Request) (TemplateData, error) + func HandleStatus(w http.ResponseWriter, r *http.Request) (TemplateData, error) + type ValidationTag struct + func ParseValidationTag(tag string) *ValidationTag + func (p *ValidationTag) Float(index int) (float64, bool) + func (p *ValidationTag) Int(index int) (int, bool) + func (p *ValidationTag) Len() int + func (p *ValidationTag) Str(index int) (string, bool) + type WidgetCacheItem struct + Header http.Header + RawResponse []byte