Documentation ¶
Index ¶
- Constants
- Variables
- func CheckCanAccessLogs(w http.ResponseWriter, r *http.Request, config *models.GuildLoggingConfig) bool
- func CheckNickname(exec boil.ContextExecutor, ctx context.Context, nicknameStmt *sql.Stmt, ...) error
- func CheckUsername(exec boil.ContextExecutor, ctx context.Context, usernameStmt *sql.Stmt, ...) error
- func CreateChannelLog(ctx context.Context, config *models.GuildLoggingConfig, ...) (*models.MessageLogs2, error)
- func CreateLink(guildID int64, id int) string
- func EvtProcesser()
- func EvtProcesserGCs()
- func GetChannelLogs(ctx context.Context, id, guildID int64, sm SearchMode) (*models.MessageLogs2, []*models.Messages2, error)
- func GetConfig(exec boil.ContextExecutor, ctx context.Context, guildID int64) (*models.GuildLoggingConfig, error)
- func GetConfigCached(exec boil.ContextExecutor, gID int64) (*models.GuildLoggingConfig, error)
- func GetGuilLogs(ctx context.Context, guildID int64, before, after, limit int) ([]*models.MessageLogs2, error)
- func GetNicknames(ctx context.Context, userID, guildID int64, limit, offset int) ([]*models.NicknameListing, error)
- func GetUsernames(ctx context.Context, userID int64, limit, offset int) ([]*models.UsernameListing, error)
- func HandleDeleteMessageJson(w http.ResponseWriter, r *http.Request) interface{}
- func HandleGC(evt *eventsystem.EventData)
- func HandleLogsCP(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleLogsCPDelete(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleLogsCPDeleteAll(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleLogsCPSaveGeneral(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func HandleLogsHTML(w http.ResponseWriter, r *http.Request) interface{}
- func HandleMsgDelete(evt *eventsystem.EventData) (retry bool, err error)
- func HandlePresenceUpdate(evt *eventsystem.EventData)
- func HandleQueueEvt(evt *eventsystem.EventData)
- func LogFetchMW(inner web.CustomHandlerFunc, legacy bool) web.CustomHandlerFunc
- func ProcessBatch(users []*UserGuildPair, members []*discordgo.Member) error
- func RegisterPlugin()
- func SetMessageLogsColors(guildID int64, views []*MessageView)
- type CCNameChange
- type ConfigFormData
- type DeleteData
- type LightGC
- type MessageView
- type Plugin
- func (p *Plugin) AddCommands()
- func (p *Plugin) BotInit()
- func (p *Plugin) DeleteOldMessageLogs()
- func (p *Plugin) DeleteOldMessages()
- func (lp *Plugin) InitWeb()
- func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
- func (p *Plugin) PluginInfo() *common.PluginInfo
- func (p *Plugin) RunBackgroundWorker()
- func (p *Plugin) StopBackgroundWorker(wg *sync.WaitGroup)
- type SearchMode
- type UserGuildPair
Constants ¶
View Source
const ( AccessModeMembers = 0 AccessModeEveryone = 1 )
Variables ¶
View Source
var ( ErrChannelBlacklisted = errors.New("Channel blacklisted from creating message logs") ConfEnableMessageLogPurge = config.RegisterOption("yagpdb.enable_message_log_purge", "If enabled message logs older than 30 days will be deleted", false) )
View Source
var AuthorColors = []string{
"7c7cff",
"529fb7",
"4aa085",
"7ea04a",
"a0824a",
"a04a4a",
"a04a89",
}
View Source
var DBSchemas = []string{`
CREATE TABLE IF NOT EXISTS message_logs2 (
id INT NOT NULL,
guild_id BIGINT NOT NULL,
legacy_id INT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
channel_name TEXT NOT NULL,
channel_id BIGINT NOT NULL,
author_id BIGINT NOT NULL,
author_username TEXT NOT NULL,
messages BIGINT[],
PRIMARY KEY(guild_id, id)
);
`,
`
CREATE TABLE IF NOT EXISTS messages2 (
id BIGINT PRIMARY KEY,
guild_id BIGINT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
deleted BOOLEAN NOT NULL,
author_username TEXT NOT NULL,
author_id BIGINT NOT NULL,
content TEXT NOT NULL
);
`, `
CREATE TABLE IF NOT EXISTS guild_logging_configs (
guild_id BIGINT PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
username_logging_enabled BOOLEAN,
nickname_logging_enabled BOOLEAN,
blacklisted_channels TEXT,
manage_messages_can_view_deleted BOOLEAN,
everyone_can_view_deleted BOOLEAN
);`,
`ALTER TABLE guild_logging_configs ADD COLUMN IF NOT EXISTS message_logs_allowed_roles BIGINT[];`,
`ALTER TABLE guild_logging_configs ADD COLUMN IF NOT EXISTS access_mode SMALLINT NOT NULL DEFAULT 0;`,
`CREATE TABLE IF NOT EXISTS username_listings (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
user_id BIGINT,
username TEXT
);`,
`CREATE INDEX IF NOT EXISTS idx_username_listings_user_id ON username_listings(user_id);`,
`CREATE TABLE IF NOT EXISTS nickname_listings (
id SERIAL PRIMARY KEY,
created_at TIMESTAMP WITH TIME ZONE,
updated_at TIMESTAMP WITH TIME ZONE,
deleted_at TIMESTAMP WITH TIME ZONE,
user_id BIGINT,
guild_id TEXT,
nickname TEXT
);`,
`CREATE INDEX IF NOT EXISTS idx_nickname_listings_deleted_at ON nickname_listings(deleted_at);`,
`DROP INDEX IF EXISTS idx_nickname_listings_user_id;`,
`DROP INDEX IF EXISTS nickname_listings_user_id_guild_idx;`,
`CREATE INDEX IF NOT EXISTS nickname_listings_user_id_guild_id_id_idx ON nickname_listings(user_id, guild_id, id);`,
`CREATE INDEX IF NOT EXISTS username_listings_user_id_id_idx ON username_listings(user_id, id);`,
}
View Source
var PageHTMLControlPanel string
View Source
var PageHTMLView string
Functions ¶
func CheckCanAccessLogs ¶
func CheckCanAccessLogs(w http.ResponseWriter, r *http.Request, config *models.GuildLoggingConfig) bool
func CheckNickname ¶
func CheckUsername ¶
func CreateChannelLog ¶
func CreateLink ¶
func EvtProcesser ¶
func EvtProcesser()
Queue up all the events and process them one by one, because of limited connections
func EvtProcesserGCs ¶
func EvtProcesserGCs()
func GetChannelLogs ¶
func GetChannelLogs(ctx context.Context, id, guildID int64, sm SearchMode) (*models.MessageLogs2, []*models.Messages2, error)
func GetConfig ¶
func GetConfig(exec boil.ContextExecutor, ctx context.Context, guildID int64) (*models.GuildLoggingConfig, error)
Returns either stored config, err or a default config
func GetConfigCached ¶
func GetConfigCached(exec boil.ContextExecutor, gID int64) (*models.GuildLoggingConfig, error)
func GetGuilLogs ¶
func GetNicknames ¶
func GetUsernames ¶
func HandleDeleteMessageJson ¶
func HandleDeleteMessageJson(w http.ResponseWriter, r *http.Request) interface{}
func HandleGC ¶
func HandleGC(evt *eventsystem.EventData)
func HandleLogsCP ¶
func HandleLogsCP(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleLogsCPDelete ¶
func HandleLogsCPDelete(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleLogsCPDeleteAll ¶
func HandleLogsCPDeleteAll(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleLogsCPSaveGeneral ¶
func HandleLogsCPSaveGeneral(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func HandleLogsHTML ¶
func HandleLogsHTML(w http.ResponseWriter, r *http.Request) interface{}
func HandleMsgDelete ¶
func HandleMsgDelete(evt *eventsystem.EventData) (retry bool, err error)
Mark all log messages with this id as deleted
func HandlePresenceUpdate ¶
func HandlePresenceUpdate(evt *eventsystem.EventData)
func HandleQueueEvt ¶
func HandleQueueEvt(evt *eventsystem.EventData)
While presence update is sent when user changes username.... MAKES NO SENSE IMO BUT WHATEVER Also check nickname incase the user came online
func LogFetchMW ¶
func LogFetchMW(inner web.CustomHandlerFunc, legacy bool) web.CustomHandlerFunc
func ProcessBatch ¶
func ProcessBatch(users []*UserGuildPair, members []*discordgo.Member) error
func RegisterPlugin ¶
func RegisterPlugin()
func SetMessageLogsColors ¶
func SetMessageLogsColors(guildID int64, views []*MessageView)
Types ¶
type CCNameChange ¶
type ConfigFormData ¶
type DeleteData ¶
type DeleteData struct {
ID int64
}
type MessageView ¶
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
func (*Plugin) AddCommands ¶
func (p *Plugin) AddCommands()
func (*Plugin) DeleteOldMessageLogs ¶
func (p *Plugin) DeleteOldMessageLogs()
func (*Plugin) DeleteOldMessages ¶
func (p *Plugin) DeleteOldMessages()
func (*Plugin) LoadServerHomeWidget ¶
func (p *Plugin) LoadServerHomeWidget(w http.ResponseWriter, r *http.Request) (web.TemplateData, error)
func (*Plugin) PluginInfo ¶
func (p *Plugin) PluginInfo() *common.PluginInfo
func (*Plugin) RunBackgroundWorker ¶
func (p *Plugin) RunBackgroundWorker()
func (*Plugin) StopBackgroundWorker ¶
type UserGuildPair ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.