package pkgo
import "github.com/starshine-sys/pkgo"
Index ¶
- Constants
- Variables
- type Color
- type Config
- type ErrStatusNot200
- type Front
- type Member
- func (m *Member) BirthdayString(format string) string
- func (m *Member) DisplayedName() string
- func (m *Member) Private(fields ...Privacy) *Member
- func (m *Member) Public(fields ...Privacy) *Member
- func (m *Member) SetDescription(desc string) *Member
- func (m *Member) SetDisplayName(n string) *Member
- func (m *Member) SetName(n string) *Member
- func (m *Member) SetPronouns(p string) *Member
- type Members
- func (m Members) Len() int
- func (m Members) Less(i, j int) bool
- func (m Members) Swap(i, j int)
- func (m Members) ToMaps() (map[string]string, map[string]string)
- type Message
- type Privacy
- type ProxyTag
- type Session
- func NewSession(c *Config) *Session
- func (s *Session) GetFronters(id string) (f Front, err error)
- func (s *Session) GetMembers(id string) (Members, error)
- func (s *Session) GetMessage(id Snowflake) (m *Message, err error)
- func (s *Session) GetSystem() (sys *System, err error)
- func (s *Session) GetSystemByID(id string) (sys *System, err error)
- func (s *Session) GetSystemByUserID(id Snowflake) (sys *System, err error)
- func (s *Session) RateLimit()
- func (s *Session) RegisterSwitch(ids ...string) (err error)
- func (s *Session) UpdateMember(id string, member *Member) (*Member, error)
- type Snowflake
- func ParseSnowflake(str string) (Snowflake, error)
- func (s Snowflake) String() string
- func (s *Snowflake) UnmarshalJSON(v []byte) error
- type Switch
- type System
Constants ¶
const ( BirthdaySource = "2006-01-02" BirthdayMMDD = "01-02" BirthdayDDMM = "02-01" BirthdayMonthName = "January 2" BirthdayMonthNameRev = "2 January" )
Birthday format constants
Variables ¶
var ( ErrNoToken = errors.New("pkgo: no token in session, can't hit endpoints requiring authentication") ErrInvalidID = errors.New("pkgo: not a 5-character ID") ErrInvalidSnowflake = errors.New("pkgo: not a valid Discord snowflake") ErrMsgNotFound = errors.New("pkgo: message not found") )
Errors
ErrRateLimit is returned when the API rate limit is hit
Types ¶
type Color ¶
type Color string
Color holds the color for a member
func (Color) IsValid ¶
IsValid returns true if the color is valid for PK
func (Color) ToInt ¶
ToInt converts the color to an int64 value
type Config ¶
Config is the config struct, passed to (Session).NewToken()
type ErrStatusNot200 ¶
ErrStatusNot200 ...
func (*ErrStatusNot200) Error ¶
func (e *ErrStatusNot200) Error() string
type Front ¶
type Front struct { Timestamp time.Time `json:"timestamp,omitempty"` Members []Member `json:"members"` }
Front holds the info for a full switch, as queried from /s/id/fronters
type Member ¶
type Member struct { ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` DisplayName string `json:"display_name,omitempty"` Description string `json:"description,omitempty"` Pronouns string `json:"pronouns,omitempty"` Color Color `json:"color,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Birthday string `json:"birthday,omitempty"` ProxyTags []ProxyTag `json:"proxy_tags,omitempty"` KeepProxy bool `json:"keep_proxy,omitempty"` Created time.Time `json:"created"` Visibility string `json:"visibility,omitempty"` NamePrivacy string `json:"name_privacy,omitempty"` DescPrivacy string `json:"description_privacy,omitempty"` AvatarPrivacy string `json:"avatar_privacy,omitempty"` BirthdayPrivacy string `json:"birthday_privacy,omitempty"` PronounPrivacy string `json:"pronoun_privacy,omitempty"` MetadataPrivacy string `json:"metadata_privacy,omitempty"` }
Member holds information for a specific system member
func (*Member) BirthdayString ¶
BirthdayString gives a member's birthday according to a format string
func (*Member) DisplayedName ¶
DisplayedName returns the member's displayed name--either DisplayName if one is set, otherwise Name
func (*Member) Private ¶
Private will set the specified field(s) to private
func (*Member) Public ¶
Public will set the specified field(s) to public
func (*Member) SetDescription ¶
SetDescription sets the member's description, honouring limits
func (*Member) SetDisplayName ¶
SetDisplayName sets the displayname, honouring limits
func (*Member) SetName ¶
SetName sets the member's name, honouring limits
func (*Member) SetPronouns ¶
SetPronouns sets the member's pronouns, honouring limits
type Members ¶
type Members []Member
Members holds multiple members, which can be sorted by creation date
func (Members) Len ¶
func (Members) Less ¶
func (Members) Swap ¶
func (Members) ToMaps ¶
ToMaps returns two maps, one of name-ID, one of ID-name. Note that the name-ID map may be incomplete if multiple members have the same name
type Message ¶
type Message struct { Timestamp time.Time `json:"timestamp"` ID Snowflake `json:"id"` Original Snowflake `json:"original"` Sender Snowflake `json:"sender"` Channel Snowflake `json:"channel"` System System `json:"system"` Member Member `json:"member"` }
Message is a proxied message
type Privacy ¶
type Privacy int
Privacy is a privacy field
const ( Visibility Privacy = iota NamePrivacy DescPrivacy AvatarPrivacy BirthdayPrivacy PronounPrivacy MetadataPrivacy )
Privacy field constants
type ProxyTag ¶
type ProxyTag struct { Prefix string `json:"prefix,omitempty"` Suffix string `json:"suffix,omitempty"` }
ProxyTag is a single proxy tag for a member, in the format <prefix>text<suffix>
func (*ProxyTag) String ¶
String returns a <prefix>text<suffix> formatted version of the proxy tag
type Session ¶
type Session struct { // NoRate disables client-side rate limiting NoRate bool // contains filtered or unexported fields }
Session is the PluralKit API session, including a token
func NewSession ¶
NewSession returns a session
func (*Session) GetFronters ¶
GetFronters gets the current fronters for a system
func (*Session) GetMembers ¶
GetMembers gets all members of a system
func (*Session) GetMessage ¶
GetMessage gets a message by Discord snowflake
func (*Session) GetSystem ¶
GetSystem gets the current token's system
func (*Session) GetSystemByID ¶
GetSystemByID gets a system by its 5-character system ID
func (*Session) GetSystemByUserID ¶
GetSystemByUserID gets a system by a Discord snowflake (user ID)
func (*Session) RateLimit ¶
func (s *Session) RateLimit()
RateLimit blocks until we can be *sure* we won't hit the rate limit. Gets a lock on s.rate, waits 500ms, and unlocks it.
func (*Session) RegisterSwitch ¶
RegisterSwitch registers a switch with the given member IDs
func (*Session) UpdateMember ¶
UpdateMember updates a member by ID
type Snowflake ¶
type Snowflake uint64
Snowflake is a Discord snowflake
func ParseSnowflake ¶
ParseSnowflake parses a snowflake from a string
func (Snowflake) String ¶
func (*Snowflake) UnmarshalJSON ¶
UnmarshalJSON ...
type Switch ¶
type Switch struct { Timestamp time.Time `json:"timestamp,omitempty"` Members []string `json:"members"` }
Switch holds the info for a simple switch, as queried from /s/id/switches
type System ¶
type System struct { ID string `json:"id"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Tag string `json:"tag,omitempty"` AvatarURL string `json:"avatar_url,omitempty"` Timezone string `json:"tz,omitempty"` Created time.Time `json:"created"` DescPrivacy string `json:"description_privacy,omitempty"` MemberListPrivacy string `json:"member_list_privacy,omitempty"` FrontPrivacy string `json:"front_privacy,omitempty"` FrontHistoryPrivacy string `json:"front_history_privacy,omitempty"` }
System holds all the data for a system
Source Files ¶
api.go errors.go limits.go member.go member_api.go member_objects.go members.go message.go session.go switches.go system.go validators.go
- Version
- v0.4.0
- Published
- Jun 9, 2021
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- now –
Tools for package owners.