logs

package
v0.29.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2018 License: MIT Imports: 30 Imported by: 0

README

Logs

The logs plugin logs certain information from servers.

  • Can store a subset of the message history with deleted messages
  • Username changes

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrChannelBlacklisted = errors.New("Channel blacklisted from creating message logs")
)

Functions

func CheckNickname

func CheckNickname(gDB *gorm.DB, nicknameStmt *sql.Stmt, userID, guildID int64, nickname string)

func CheckUsername

func CheckUsername(gDB *gorm.DB, usernameStmt *sql.Stmt, user *discordgo.User)

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 EvtProcesser

func EvtProcesser()

Queue up all the events and process them one by one, because of limited connections

func EvtProcesserGCs

func EvtProcesserGCs()

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

func FSByte(useLocal bool, name string) ([]byte, error)

FSByte returns the named file from the embedded assets. If useLocal is true, the filesystem's contents are instead used.

func FSMustByte

func FSMustByte(useLocal bool, name string) []byte

FSMustByte is the same as FSByte, but panics if name is not present.

func FSMustString

func FSMustString(useLocal bool, name string) string

FSMustString is the string version of FSMustByte.

func FSString

func FSString(useLocal bool, name string) (string, error)

FSString is the string version of FSByte.

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 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)

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 InitPlugin

func InitPlugin()

Types

type DeleteData

type DeleteData struct {
	ID string
}

type GeneralFormData

type GeneralFormData struct {
	UsernameLoggingEnabled       bool
	NicknameLoggingEnabled       bool
	ManageMessagesCanViewDeleted bool
	EveryoneCanViewDeleted       bool
	BlacklistedChannels          []string
}

type GuildLoggingConfig

type GuildLoggingConfig struct {
	configstore.GuildConfigModel
	UsernameLoggingEnabled bool
	NicknameLoggingEnabled bool
	BlacklistedChannels    string

	ManageMessagesCanViewDeleted bool
	EveryoneCanViewDeleted       bool

	ParsedBlacklistedchannels []string `gorm:"-"`
}

func GetConfig

func GetConfig(guildID int64) (*GuildLoggingConfig, error)

Returns either stored config, err or a default config

func (*GuildLoggingConfig) GetName

func (g *GuildLoggingConfig) GetName() string

func (*GuildLoggingConfig) PostFetch

func (g *GuildLoggingConfig) PostFetch()

type Message

type Message struct {
	common.SmallModel
	MessageLogID uint `gorm:"index"` // Foreign key, belongs to MessageLog

	MessageID string `gorm:"index"`
	Content   string `gorm:"size:2000"`
	Timestamp string

	AuthorUsername string
	AuthorDiscrim  string
	AuthorID       string
	Deleted        bool
}

type MessageLog

type MessageLog struct {
	gorm.Model
	Messages []Message

	ChannelName string
	ChannelID   string
	GuildID     string

	Author   string
	AuthorID string
}

func CreateChannelLog

func CreateChannelLog(config *GuildLoggingConfig, guildID, channelID int64, author string, authorID int64, count int) (*MessageLog, error)

func GetChannelLogs

func GetChannelLogs(id int64) (*MessageLog, error)

func GetGuilLogs

func GetGuilLogs(guildID int64, before, after, limit int) ([]*MessageLog, error)
func (m *MessageLog) Link() string

type NicknameListing

type NicknameListing struct {
	gorm.Model
	UserID   int64 `gorm:"index"`
	GuildID  string
	Nickname string
}

func GetNicknames

func GetNicknames(userID, guildID int64, limit int) ([]NicknameListing, error)

type Plugin

type Plugin struct{}

func (*Plugin) InitBot

func (p *Plugin) InitBot()

func (*Plugin) InitWeb

func (lp *Plugin) InitWeb()

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) StartBot

func (p *Plugin) StartBot()

type UsernameListing

type UsernameListing struct {
	gorm.Model
	UserID   int64 `gorm:"index"`
	Username string
}

func GetUsernames

func GetUsernames(userID int64, limit int) ([]UsernameListing, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL