entities

package
v0.0.0-...-37b14fa Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const DBPath = "database/guilds"

Variables

View Source
var (
	Mutex         deadlock.RWMutex
	SharedInfo    *sharedInfo
	AnimeSchedule = &AnimeScheduleMap{AnimeSchedule: make(map[int][]*ShowAirTime)}
)
View Source
var (
	Guilds = NewGuildMap(make(map[string]*GuildInfo))
)

Functions

func AnimeSubsWrite

func AnimeSubsWrite(animeSubs map[string][]*ShowSub) error

Writes anime notfication subscription to animeSubs.json

func HandleNewGuild

func HandleNewGuild(guildID string)

HandleNewGuild initializes a guild if it's not in memory

func IOReadDir

func IOReadDir(root string) ([]string, error)

Reads and returns the names of every file in that directory

func InTimeSpan

func InTimeSpan(start, end, check time.Time) bool

func LoadSharedDB

func LoadSharedDB()

LoadSharedDB loads global shared DBs in mem

func LoadSharedDBFile

func LoadSharedDBFile(file string)

func RemindMeWrite

func RemindMeWrite(remindMe map[string]*RemindMeSlice) error

RemindMeWrite writes RemindMes to remindMes.json

func SetupGuildSub

func SetupGuildSub(guildID string)

Types

type ASAnime

type ASAnime struct {
	deadlock.RWMutex

	Title             string    `json:"title"`
	Route             string    `json:"route"`
	EpisodeDate       time.Time `json:"episodeDate"`
	EpisodeNumber     int       `json:"episodeNumber"`
	Episodes          int       `json:"episodes`
	DelayedFrom       time.Time `json:"delayedFrom"`
	DelayedUntil      time.Time `json:"delayedUntil"`
	AirType           string    `json:"airType"`
	ImageVersionRoute string    `json:"imageVersionRoute"`
	Donghua           bool      `json:"donghua"`
}

func NewASAnime

func NewASAnime(title, route string, episodeDate time.Time, episodeNumber, episodes int, delayedFrom time.Time, delayedUntil time.Time,
	airType, imageVersionRoute string, donghua bool) *ASAnime

func (*ASAnime) GetAirType

func (a *ASAnime) GetAirType() string

func (*ASAnime) GetDelayedFrom

func (a *ASAnime) GetDelayedFrom() time.Time

func (*ASAnime) GetDelayedUntil

func (a *ASAnime) GetDelayedUntil() time.Time

func (*ASAnime) GetDonghua

func (a *ASAnime) GetDonghua() bool

func (*ASAnime) GetEpisodeDate

func (a *ASAnime) GetEpisodeDate() time.Time

func (*ASAnime) GetEpisodeNumber

func (a *ASAnime) GetEpisodeNumber() int

func (*ASAnime) GetEpisodes

func (a *ASAnime) GetEpisodes() int

func (*ASAnime) GetImageVersionRoute

func (a *ASAnime) GetImageVersionRoute() string

func (*ASAnime) GetRoute

func (a *ASAnime) GetRoute() string

func (*ASAnime) GetTitle

func (a *ASAnime) GetTitle() string

func (*ASAnime) SetAirType

func (a *ASAnime) SetAirType(airType string)

func (*ASAnime) SetDelayedFrom

func (a *ASAnime) SetDelayedFrom(delayedFrom time.Time)

func (*ASAnime) SetDelayedUntil

func (a *ASAnime) SetDelayedUntil(delayedUntil time.Time)

func (*ASAnime) SetDonghua

func (a *ASAnime) SetDonghua(donghua bool)

func (*ASAnime) SetEpisodeDate

func (a *ASAnime) SetEpisodeDate(episodeDate time.Time)

func (*ASAnime) SetEpisodeNumber

func (a *ASAnime) SetEpisodeNumber(episodeNumber int)

func (*ASAnime) SetEpisodes

func (a *ASAnime) SetEpisodes(episodes int)

func (*ASAnime) SetImageVersionRoute

func (a *ASAnime) SetImageVersionRoute(imageVersionRoute string)

func (*ASAnime) SetRoute

func (a *ASAnime) SetRoute(route string)

func (*ASAnime) SetTitle

func (a *ASAnime) SetTitle(title string)

type AnimeScheduleMap

type AnimeScheduleMap struct {
	deadlock.RWMutex
	AnimeSchedule map[int][]*ShowAirTime
}

type Cha

type Cha struct {
	deadlock.RWMutex

	Name string `json:"Name"`
	ID   string `json:"ID"`
}

func NewCha

func NewCha(name string, ID string) Cha

func (Cha) GetID

func (c Cha) GetID() string

func (Cha) GetName

func (c Cha) GetName() string

func (Cha) SetID

func (c Cha) SetID(id string) Cha

func (Cha) SetName

func (c Cha) SetName(name string) Cha

type Feed

type Feed struct {
	deadlock.RWMutex

	Subreddit string `json:"Subreddit"`
	Title     string `json:"Title"`
	Author    string `json:"Author"`
	Pin       bool   `json:"Pin"`
	PostType  string `json:"PostType"`
	ChannelID string `json:"ChannelID"`
}

func NewFeed

func NewFeed(subreddit string, title string, author string, pin bool, postType string, channelID string) Feed

func (Feed) GetAuthor

func (f Feed) GetAuthor() string

func (Feed) GetChannelID

func (f Feed) GetChannelID() string

func (Feed) GetPin

func (f Feed) GetPin() bool

func (Feed) GetPostType

func (f Feed) GetPostType() string

func (Feed) GetSubreddit

func (f Feed) GetSubreddit() string

func (Feed) GetTitle

func (f Feed) GetTitle() string

func (Feed) SetAuthor

func (f Feed) SetAuthor(author string) Feed

func (Feed) SetChannelID

func (f Feed) SetChannelID(channelID string) Feed

func (Feed) SetPin

func (f Feed) SetPin(pin bool) Feed

func (Feed) SetPostType

func (f Feed) SetPostType(postType string) Feed

func (Feed) SetSubreddit

func (f Feed) SetSubreddit(subreddit string) Feed

func (Feed) SetTitle

func (f Feed) SetTitle(title string) Feed

type FeedCheck

type FeedCheck struct {
	deadlock.RWMutex

	Feed Feed      `json:"Thread"`
	Date time.Time `json:"Date"`
	GUID string    `json:"GUID"`
}

func NewFeedCheck

func NewFeedCheck(feed Feed, date time.Time, GUID string) FeedCheck

func (FeedCheck) GetDate

func (f FeedCheck) GetDate() time.Time

func (FeedCheck) GetFeed

func (f FeedCheck) GetFeed() Feed

func (FeedCheck) GetGUID

func (f FeedCheck) GetGUID() string

func (FeedCheck) SetDate

func (f FeedCheck) SetDate(date time.Time) FeedCheck

func (FeedCheck) SetFeed

func (f FeedCheck) SetFeed(feed Feed) FeedCheck

func (FeedCheck) SetGUID

func (f FeedCheck) SetGUID(guid string) FeedCheck

type GuildInfo

type GuildInfo struct {
	deadlock.RWMutex

	ID            string
	GuildSettings GuildSettings
	Feeds         []Feed
	FeedChecks    []FeedCheck
	Raffles       []*Raffle
	ReactJoinMap  map[string]*ReactJoin
	Autoposts     map[string]Cha
}

GuildInfo contains all the data a guild can contain

func (*GuildInfo) AppendToFeedChecks

func (g *GuildInfo) AppendToFeedChecks(feedCheck FeedCheck)

func (*GuildInfo) AppendToFeeds

func (g *GuildInfo) AppendToFeeds(feed Feed)

func (*GuildInfo) AppendToRaffles

func (g *GuildInfo) AppendToRaffles(raffle *Raffle)

func (*GuildInfo) AssignToAutoposts

func (g *GuildInfo) AssignToAutoposts(key string, autopost Cha)

func (*GuildInfo) AssignToFeedChecks

func (g *GuildInfo) AssignToFeedChecks(index int, feedCheck FeedCheck)

func (*GuildInfo) AssignToFeeds

func (g *GuildInfo) AssignToFeeds(index int, feed Feed)

func (*GuildInfo) AssignToReactJoinMap

func (g *GuildInfo) AssignToReactJoinMap(key string, reactJoin *ReactJoin)

func (*GuildInfo) GetAutoposts

func (g *GuildInfo) GetAutoposts() map[string]Cha

func (*GuildInfo) GetFeedChecks

func (g *GuildInfo) GetFeedChecks() []FeedCheck

func (*GuildInfo) GetFeeds

func (g *GuildInfo) GetFeeds() []Feed

func (*GuildInfo) GetGuildSettings

func (g *GuildInfo) GetGuildSettings() GuildSettings

func (*GuildInfo) GetID

func (g *GuildInfo) GetID() string

func (*GuildInfo) GetRaffles

func (g *GuildInfo) GetRaffles() []*Raffle

func (*GuildInfo) GetReactJoinMap

func (g *GuildInfo) GetReactJoinMap() map[string]*ReactJoin

func (*GuildInfo) Load

func (g *GuildInfo) Load(file, guildID string) error

Load loads a guild file into the guild memory

func (*GuildInfo) RemoveFromAutoposts

func (g *GuildInfo) RemoveFromAutoposts(key string)

func (*GuildInfo) RemoveFromFeedChecks

func (g *GuildInfo) RemoveFromFeedChecks(index int)

func (*GuildInfo) RemoveFromFeeds

func (g *GuildInfo) RemoveFromFeeds(index int)

func (*GuildInfo) RemoveFromRaffles

func (g *GuildInfo) RemoveFromRaffles(index int)

func (*GuildInfo) RemoveFromReactJoinMap

func (g *GuildInfo) RemoveFromReactJoinMap(key string)

func (*GuildInfo) SetAutoposts

func (g *GuildInfo) SetAutoposts(autoposts map[string]Cha)

func (*GuildInfo) SetFeedChecks

func (g *GuildInfo) SetFeedChecks(feedChecks []FeedCheck)

func (*GuildInfo) SetFeeds

func (g *GuildInfo) SetFeeds(feeds []Feed)

func (*GuildInfo) SetGuildSettings

func (g *GuildInfo) SetGuildSettings(guildSettings GuildSettings)

func (*GuildInfo) SetID

func (g *GuildInfo) SetID(id string)

func (*GuildInfo) SetRaffles

func (g *GuildInfo) SetRaffles(raffles []*Raffle)

func (*GuildInfo) SetReactJoinMap

func (g *GuildInfo) SetReactJoinMap(reactJoinMap map[string]*ReactJoin)

func (*GuildInfo) WriteData

func (g *GuildInfo) WriteData(fileName string, data interface{})

WriteData writes some kind of guild data to the target guild file

type GuildMap

type GuildMap struct {
	deadlock.RWMutex

	DB map[string]*GuildInfo
}

GuildMap is a mutex-safe map of GuildInfo

func NewGuildMap

func NewGuildMap(DB map[string]*GuildInfo) *GuildMap

func (*GuildMap) Init

func (g *GuildMap) Init(guildID string) bool

Init initializes a new guild with an empty GuildInfo Object

func (*GuildMap) Load

func (g *GuildMap) Load(guildID string) (bool, error)

Load loads a preexisting guild

func (*GuildMap) LoadAll

func (g *GuildMap) LoadAll()

LoadAll loads all guilds from storage

type GuildSettings

type GuildSettings struct {
	deadlock.RWMutex

	Prefix       string     `json:"Prefix"`
	BotLog       Cha        `json:"BotLogID"`
	CommandRoles []Role     `json:"CommandRoles"`
	MutedRole    Role       `json:"MutedRole"`
	VoiceChas    []VoiceCha `json:"VoiceChas"`
	ModOnly      bool       `json:"ModOnly"`
	Donghua      bool       `json:"Donghua"`
	ReactsModule bool       `json:"ReactsModule"`
	PingMessage  string     `json:"PingMessage"`
	Premium      bool       `json:"Premium"`
}

GuildSettings contains the guild-specific settings and toggled modules

func (GuildSettings) AppendToCommandRoles

func (g GuildSettings) AppendToCommandRoles(commandRole Role) GuildSettings

func (GuildSettings) AppendToVoiceChas

func (g GuildSettings) AppendToVoiceChas(voiceCha VoiceCha) GuildSettings

func (GuildSettings) GetBotLog

func (g GuildSettings) GetBotLog() Cha

func (GuildSettings) GetCommandRoles

func (g GuildSettings) GetCommandRoles() []Role

func (GuildSettings) GetDonghua

func (g GuildSettings) GetDonghua() bool

func (GuildSettings) GetModOnly

func (g GuildSettings) GetModOnly() bool

func (GuildSettings) GetMutedRole

func (g GuildSettings) GetMutedRole() Role

func (GuildSettings) GetPingMessage

func (g GuildSettings) GetPingMessage() string

func (GuildSettings) GetPrefix

func (g GuildSettings) GetPrefix() string

func (GuildSettings) GetPremium

func (g GuildSettings) GetPremium() bool

func (GuildSettings) GetReactsModule

func (g GuildSettings) GetReactsModule() bool

func (GuildSettings) GetVoiceChas

func (g GuildSettings) GetVoiceChas() []VoiceCha

func (GuildSettings) RemoveFromCommandRoles

func (g GuildSettings) RemoveFromCommandRoles(index int) GuildSettings

func (GuildSettings) RemoveFromVoiceChas

func (g GuildSettings) RemoveFromVoiceChas(index int) GuildSettings

func (GuildSettings) SetBotLog

func (g GuildSettings) SetBotLog(cha Cha) GuildSettings

func (GuildSettings) SetCommandRoles

func (g GuildSettings) SetCommandRoles(roles []Role) GuildSettings

func (GuildSettings) SetDonghua

func (g GuildSettings) SetDonghua(donghua bool) GuildSettings

func (GuildSettings) SetModOnly

func (g GuildSettings) SetModOnly(modOnly bool) GuildSettings

func (GuildSettings) SetMutedRole

func (g GuildSettings) SetMutedRole(role Role) GuildSettings

func (GuildSettings) SetPingMessage

func (g GuildSettings) SetPingMessage(pingMessage string) GuildSettings

func (GuildSettings) SetPrefix

func (g GuildSettings) SetPrefix(prefix string) GuildSettings

func (GuildSettings) SetPremium

func (g GuildSettings) SetPremium(premium bool) GuildSettings

func (GuildSettings) SetReactsModule

func (g GuildSettings) SetReactsModule(reactsModule bool) GuildSettings

func (GuildSettings) SetVoiceChas

func (g GuildSettings) SetVoiceChas(voiceChas []VoiceCha) GuildSettings

type Raffle

type Raffle struct {
	deadlock.RWMutex

	Name           string   `json:"Name"`
	ParticipantIDs []string `json:"ParticipantIDs"`
	ReactMessageID string   `json:"ReactMessageID"`
}

func NewRaffle

func NewRaffle(name string, participantIDs []string, reactMessageID string) *Raffle

func (*Raffle) AppendToParticipantIDs

func (r *Raffle) AppendToParticipantIDs(participantID string)

func (*Raffle) GetName

func (r *Raffle) GetName() string

func (*Raffle) GetParticipantIDs

func (r *Raffle) GetParticipantIDs() []string

func (*Raffle) GetReactMessageID

func (r *Raffle) GetReactMessageID() string

func (*Raffle) RemoveFromParticipantIDs

func (r *Raffle) RemoveFromParticipantIDs(index int)

func (*Raffle) SetName

func (r *Raffle) SetName(name string)

func (*Raffle) SetParticipantIDs

func (r *Raffle) SetParticipantIDs(participantIDs []string)

func (*Raffle) SetReactMessageID

func (r *Raffle) SetReactMessageID(reactMessageID string)

type ReactJoin

type ReactJoin struct {
	deadlock.RWMutex

	RoleEmojiMap []map[string][]string `json:"roleEmoji"`
}

func (*ReactJoin) AppendToRoleEmojiMap

func (r *ReactJoin) AppendToRoleEmojiMap(roleEmoji map[string][]string)

func (*ReactJoin) GetRoleEmojiMap

func (r *ReactJoin) GetRoleEmojiMap() []map[string][]string

func (*ReactJoin) RemoveFromRoleEmojiMap

func (r *ReactJoin) RemoveFromRoleEmojiMap(index int)

func (*ReactJoin) SetRoleEmojiMap

func (r *ReactJoin) SetRoleEmojiMap(roleEmojiMap []map[string][]string)

type RemindMe

type RemindMe struct {
	deadlock.RWMutex

	Message        string
	Date           time.Time
	CommandChannel string
	RemindID       int
}

func NewRemindMe

func NewRemindMe(message string, date time.Time, commandChannel string, remindID int) *RemindMe

func (*RemindMe) AddToRemindID

func (r *RemindMe) AddToRemindID(remindID int)

func (*RemindMe) GetCommandChannel

func (r *RemindMe) GetCommandChannel() string

func (*RemindMe) GetDate

func (r *RemindMe) GetDate() time.Time

func (*RemindMe) GetMessage

func (r *RemindMe) GetMessage() string

func (*RemindMe) GetRemindID

func (r *RemindMe) GetRemindID() int

func (*RemindMe) SetCommandChannel

func (r *RemindMe) SetCommandChannel(commandChannel string)

func (*RemindMe) SetDate

func (r *RemindMe) SetDate(date time.Time)

func (*RemindMe) SetMessage

func (r *RemindMe) SetMessage(message string)

func (*RemindMe) SetRemindID

func (r *RemindMe) SetRemindID(remindID int)

type RemindMeSlice

type RemindMeSlice struct {
	deadlock.RWMutex

	RemindMeSlice []*RemindMe
	Premium       bool
	Guild         bool
}

func NewRemindMeSlice

func NewRemindMeSlice(remindMeSlice []*RemindMe, premium bool) *RemindMeSlice

func (*RemindMeSlice) AppendToRemindMeSlice

func (r *RemindMeSlice) AppendToRemindMeSlice(remindMe *RemindMe)

func (*RemindMeSlice) GetGuild

func (r *RemindMeSlice) GetGuild() bool

func (*RemindMeSlice) GetPremium

func (r *RemindMeSlice) GetPremium() bool

func (*RemindMeSlice) GetRemindMeSlice

func (r *RemindMeSlice) GetRemindMeSlice() []*RemindMe

func (*RemindMeSlice) RemoveFromRemindMeSlice

func (r *RemindMeSlice) RemoveFromRemindMeSlice(index int)

func (*RemindMeSlice) SetGuild

func (r *RemindMeSlice) SetGuild(guild bool)

func (*RemindMeSlice) SetPremium

func (r *RemindMeSlice) SetPremium(premium bool)

func (*RemindMeSlice) SetRemindMeSlice

func (r *RemindMeSlice) SetRemindMeSlice(remindMeSlice []*RemindMe)

type Role

type Role struct {
	deadlock.RWMutex

	Name     string `json:"Name"`
	ID       string `json:"ID"`
	Position int    `json:"Position"`
}

func NewRole

func NewRole(name string, ID string, position int) Role

func (Role) GetID

func (r Role) GetID() string

func (Role) GetName

func (r Role) GetName() string

func (Role) GetPosition

func (r Role) GetPosition() int

func (Role) SetID

func (r Role) SetID(id string) Role

func (Role) SetName

func (r Role) SetName(name string) Role

func (Role) SetPosition

func (r Role) SetPosition(position int) Role

type ShowAirTime

type ShowAirTime struct {
	deadlock.RWMutex

	Name     string
	AirTime  string
	Episode  string
	Delayed  string
	Key      string
	ImageUrl string
	Subbed   bool
	Donghua  bool
}

func NewShowAirTime

func NewShowAirTime(name, airTime, episode, delayed, key, imageUrl string, subbed, donghua bool) *ShowAirTime

func (*ShowAirTime) GetAirTime

func (s *ShowAirTime) GetAirTime() string

func (*ShowAirTime) GetDelayed

func (s *ShowAirTime) GetDelayed() string

func (*ShowAirTime) GetDonghua

func (s *ShowAirTime) GetDonghua() bool

func (*ShowAirTime) GetEpisode

func (s *ShowAirTime) GetEpisode() string

func (*ShowAirTime) GetImageUrl

func (s *ShowAirTime) GetImageUrl() string

func (*ShowAirTime) GetKey

func (s *ShowAirTime) GetKey() string

func (*ShowAirTime) GetName

func (s *ShowAirTime) GetName() string

func (*ShowAirTime) GetSubbed

func (s *ShowAirTime) GetSubbed() bool

func (*ShowAirTime) SetAirTime

func (s *ShowAirTime) SetAirTime(airTime string)

func (*ShowAirTime) SetDelayed

func (s *ShowAirTime) SetDelayed(delayed string)

func (*ShowAirTime) SetDonghua

func (s *ShowAirTime) SetDonghua(donghua bool)

func (*ShowAirTime) SetEpisode

func (s *ShowAirTime) SetEpisode(episode string)

func (*ShowAirTime) SetImageUrl

func (s *ShowAirTime) SetImageUrl(imageUrl string)

func (*ShowAirTime) SetKey

func (s *ShowAirTime) SetKey(key string)

func (*ShowAirTime) SetName

func (s *ShowAirTime) SetName(name string)

func (*ShowAirTime) SetSubbed

func (s *ShowAirTime) SetSubbed(subbed bool)

type ShowSub

type ShowSub struct {
	deadlock.RWMutex

	Show     string `json:"Show"`
	Notified bool   `json:"Notified"`
	Guild    bool   `json:"Guild"`
}

func NewShowSub

func NewShowSub(show string, notified bool, guild bool) *ShowSub

func (*ShowSub) GetGuild

func (s *ShowSub) GetGuild() bool

func (*ShowSub) GetNotified

func (s *ShowSub) GetNotified() bool

func (*ShowSub) GetShow

func (s *ShowSub) GetShow() string

func (*ShowSub) SetGuild

func (s *ShowSub) SetGuild(guild bool)

func (*ShowSub) SetNotified

func (s *ShowSub) SetNotified(notified bool)

func (*ShowSub) SetShow

func (s *ShowSub) SetShow(show string)

type VoiceCha

type VoiceCha struct {
	deadlock.RWMutex

	Name  string `json:"Name"`
	ID    string `json:"ID"`
	Roles []Role `json:"Roles"`
}

func (VoiceCha) AppendToRoles

func (v VoiceCha) AppendToRoles(role Role) VoiceCha

func (VoiceCha) GetID

func (v VoiceCha) GetID() string

func (VoiceCha) GetName

func (v VoiceCha) GetName() string

func (VoiceCha) GetRoles

func (v VoiceCha) GetRoles() []Role

func (VoiceCha) RemoveFromRoles

func (v VoiceCha) RemoveFromRoles(index int) VoiceCha

func (VoiceCha) SetID

func (v VoiceCha) SetID(id string) VoiceCha

func (VoiceCha) SetName

func (v VoiceCha) SetName(name string) VoiceCha

func (VoiceCha) SetRoles

func (v VoiceCha) SetRoles(roles []Role) VoiceCha

Jump to

Keyboard shortcuts

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