plurabiltycore

package module
v0.0.0-...-0148790 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

README

Plurability

A better API for systems

TODO: Add more to this

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG_FILE_NAME string = "config.json"

Functions

func AddGroup

func AddGroup(system *System, group *Group) error

func AddMember

func AddMember(system *System, member *Member) error

func AddSystem

func AddSystem(system *System) error

func BytesEqual

func BytesEqual(a []byte, b []byte) bool

func ConnectDiscord

func ConnectDiscord(system *System, discordID uint64) error

func DeleteGroup

func DeleteGroup(id []byte) error

func DeleteMember

func DeleteMember(id []byte) error

func DeleteSystem

func DeleteSystem(id []byte) error

func EditSwitch

func EditSwitch(pswitch *PluralSwitch) error

func ExportJSON

func ExportJSON(system System) string

Needs to be implemented (Memphis&)

func Find

func Find(object interface{}, array []interface{}) int

func FindInt

func FindInt(object int, array []int) int

func FindInt64

func FindInt64(object int64, array []int64) int

func FindStr

func FindStr(object string, array []string) int

func FindUInt64

func FindUInt64(object uint64, array []uint64) int

func GetDateString

func GetDateString(t time.Time) string

func GetFronters

func GetFronters(at time.Time) (*[]*Member, error)

func GetGroupMembers

func GetGroupMembers(id []byte) (*[]*Member, error)

func GetMembers

func GetMembers(id []byte) (*[]*Member, error)

Get the members of a plural object

func GetMembersFromRows

func GetMembersFromRows(rows *sql.Rows) (*[]*Member, error)

func GetSwitchesBetween

func GetSwitchesBetween(from *time.Time, to *time.Time) (*[]*PluralSwitch, error)

func GetSystemMembers

func GetSystemMembers(id []byte) (*[]*Member, error)

func HasBit

func HasBit(n uint16, pos uint) bool

func InitialiseDatabase

func InitialiseDatabase(config JSONConfig) error

func ParsePluralKitBirthday

func ParsePluralKitBirthday(timeString string) (*time.Time, error)

func ParsePluralKitTime

func ParsePluralKitTime(timeString string) (*time.Time, error)

func ParseTupperTime

func ParseTupperTime(timeString string) (*time.Time, error)

func SaveSwitch

func SaveSwitch(pswitch *PluralSwitch) error

func SaveSwitchOut

func SaveSwitchOut(memberID []byte, at time.Time) error

func UpdateGroup

func UpdateGroup(group *Group) error

func UpdateMember

func UpdateMember(member *Member) error

func UpdateSystem

func UpdateSystem(system *System) error

Types

type Group

type Group struct {
	PluralBase
	Tag     *string
	Members []*Member
	Privacy GroupPrivacy
}

func GetGroup

func GetGroup(id []byte) (*Group, error)

type GroupPrivacy

type GroupPrivacy struct {
	Visible     bool
	Description bool
	Icon        bool
}

func GetGroupPrivacy

func GetGroupPrivacy(number uint16) GroupPrivacy

func (*GroupPrivacy) ToInt

func (p *GroupPrivacy) ToInt() uint16

type JSONConfig

type JSONConfig struct {
	Database struct {
		Address  string `json:"address"`
		Name     string `json:"database"`
		Username string `json:"username"`
		Password string `json:"password"`
	} `json:"db"`
}

func GetJSONConfig

func GetJSONConfig() (*JSONConfig, error)

type JSONMemberSettings

type JSONMemberSettings struct {
}

type JSONSystemSettings

type JSONSystemSettings struct {
}

type JSONUInt

type JSONUInt struct {
	Value uint64
	Valid bool
	Set   bool
}

func (*JSONUInt) UnmarshalJSON

func (i *JSONUInt) UnmarshalJSON(data []byte) error

type Member

type Member struct {
	PluralBase
	Proxies       [][]string
	Birthday      *time.Time
	ServerMembers []*ServerMember
	Groups        []*Group
	KeepProxy     bool
	Pronouns      string
	MessageCount  int
	Settings      *JSONMemberSettings
	PluralKitID   *string
	Privacy       MemberPrivacy
	// contains filtered or unexported fields
}

func GetMember

func GetMember(id []byte) (*Member, error)

func NewMember

func NewMember(name string) *Member

type MemberPrivacy

type MemberPrivacy struct {
	Visible      bool
	Name         bool
	Description  bool
	Icon         bool
	Birthday     bool
	Pronouns     bool
	Metadata     bool
	Front        bool
	FrontHistory bool
}

func GetMemberPrivacy

func GetMemberPrivacy(number uint16) MemberPrivacy

func (*MemberPrivacy) ToInt

func (p *MemberPrivacy) ToInt() uint16

type PKMemberData

type PKMemberData struct {
	Id           string        `json:"id"`
	Name         string        `json:"name"`
	DisplayName  string        `json:"display_name"`
	Description  string        `json:"description"`
	Birthday     string        `json:"birthday"`
	Pronouns     string        `json:"pronouns"`
	Colour       string        `json:"colour"`
	AvatarURL    string        `json:"avatar_url"`
	ProxyTags    []PKProxyData `json:"proxy_tags"`
	KeepProxy    bool          `json:"keep_proxy"`
	MessageCount JSONUInt      `json:"message_count"`
	Created      string        `json:"created"`
}

type PKProxyData

type PKProxyData struct {
	Prefix string `json:"prefix"`
	Suffix string `json:"suffix"`
}

type PKSwitchData

type PKSwitchData struct {
	Timestamp string   `json:"timezone"`
	Members   []string `json:"members"`
}

type PKSystemData

type PKSystemData struct {
	Version     JSONUInt       `json:"version"`
	Id          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description"`
	Tag         string         `json:"tag"`
	AvatarURL   string         `json:"avatar_url"`
	Timezone    string         `json:"timezone"`
	Members     []PKMemberData `json:"members"`
	Switches    []PKSwitchData `json:"switches"`
	Accounts    []JSONUInt     `json:"accounts"`
	Created     string         `json:"created"`
}

type PluralBase

type PluralBase struct {
	ID          []byte
	Name        *string
	DisplayName *string
	Description *string
	IconURL     *string
	BannerURL   *string
	Colour      *string
	System      *System
	CreatedUTC  *time.Time
	SystemID    []byte
}

type PluralSwitch

type PluralSwitch struct {
	ID       []byte
	MemberID *[]byte
	StartUTC *time.Time
	EndUTC   *time.Time
	Member   *Member
	Custom   *string
	Comment  *string
}

type ServerMember

type ServerMember struct {
	ID                []byte
	ServerID          int
	Member            *Member
	ServerDisplayName *string
	ServerIconURL     *string
	// contains filtered or unexported fields
}

type System

type System struct {
	PluralBase
	Email          *string
	Password       *string
	Tag            *string
	Groups         []*Group
	Members        []*Member
	Switches       []*PluralSwitch
	Discords       []uint64
	KeepProxy      bool
	Singlet        bool
	Settings       *JSONSystemSettings
	PluralKitToken *string
	PluralKitID    *string
	Privacy        SystemPrivacy
	// contains filtered or unexported fields
}

func FromPluralKitJSON

func FromPluralKitJSON(pkJSON string) (System, error)

func FromTupperBoxJSON

func FromTupperBoxJSON(pkJSON string) (System, error)

func GetSystem

func GetSystem(id []byte) (*System, error)

func GetSystemByDiscord

func GetSystemByDiscord(discordID uint64) (*System, error)

func NewAccount

func NewAccount(name string, singlet bool) *System

type SystemPrivacy

type SystemPrivacy struct {
	Description  bool
	Icon         bool
	Front        bool
	FrontHistory bool
}

func GetSystemPrivacy

func GetSystemPrivacy(number uint16) SystemPrivacy

func (*SystemPrivacy) ToInt

func (p *SystemPrivacy) ToInt() uint16

type TupperGroupData

type TupperGroupData struct {
	Id          JSONUInt `json:"id"`
	UserId      string   `json:"user_id"`
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Tag         string   `json:"tag"`
	Position    JSONUInt `json:"position"`
}

type TupperMemberData

type TupperMemberData struct {
	Id           JSONUInt `json:"id"`
	UserId       string   `json:"user_id"`
	Name         string   `json:"name"`
	Position     JSONUInt `json:"position"`
	AvatarURL    string   `json:"avatar_url"`
	Brackets     []string `json:"brackets"`
	Posts        JSONUInt `json:"posts"`
	ShowBrackets bool     `json:"show_brackets"`
	Birthday     string   `json:"birthday"`
	Description  string   `json:"description"`
	Tag          string   `json:"tag"`
	GroupId      JSONUInt `json:"group_id"`
	GroupPos     JSONUInt `json:"group_pos"`
	CreatedAt    string   `json:"created_at"`
	Nick         string   `json:"nick"`
}

type TupperSystemData

type TupperSystemData struct {
	Tuppers []TupperMemberData `json:"tuppers"`
	Groups  []TupperGroupData  `json:"groups"`
}

Jump to

Keyboard shortcuts

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