pronouns

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package pronouns provides an implementation of the pronouns personal protocol.

Index

Constants

View Source
const (
	SelfPronounsEventType event.Type = "xyz.diamondb.gotktrix.self_pronouns"
	UserPronounsEventType event.Type = "xyz.diamondb.gotktrix.user_pronouns"
)

Variables

View Source
var DefaultPronouns = []PronounForms{
	{"he", "him", "his"},
	{"she", "her", "hers"},
	{"they", "them", "theirs"},
}

DefaultPronouns is the list of default common pronouns. A client should not assume that valid pronoun choices can only be one of these three.

Functions

This section is empty.

Types

type Preferred

type Preferred struct {
	Pronouns []Pronoun `json:"pronouns"`
	// Preferred is indexed within Pronouns; the default is the first entry.
	Preferred int `json:"preferred,omitempty"`
}

Preferred lists preferred pronouns.

func SelfPronouns

func SelfPronouns(c *gotktrix.Client) Preferred

SelfPronouns fetches the current user's preferred pronouns. A zero-value Preferred instance is returned if the user has none.

func UserPronouns

func UserPronouns(c *gotktrix.Client, rID matrix.RoomID, uID matrix.UserID) Preferred

UserPronouns searches the room for the given user's preferred pronouns. If the room ID is empty, then the user ID is only searched in the current user preferences, or if the user ID belongs to the current user, then their own preference is returned (i.e. it acts like SelfPronouns).

func (Preferred) Pronoun

func (p Preferred) Pronoun() Pronoun

Pronoun returns the preferred pronoun.

type Pronoun

type Pronoun string

Pronoun describes a pronoun string in the format they/them/theirs.

type PronounForms

type PronounForms struct {
	Subject    string
	Object     string
	Possessive string
}

PronounForms describes the 3 forms of pronouns.

func ParsePronoun

func ParsePronoun(pronoun Pronoun) (PronounForms, error)

ParsePronoun parses the given pronoun in X/Y/Z form, similarly to what String() returns. Spaces inbetween pronouns will be trimmed.

Examples of valid pronoun strings are:

he/him/his
he / him / his

she/her/hers
she    / her      / hers

they  /     them / theirs
they/them/theirs

func (PronounForms) String

func (p PronounForms) String() string

String returns the pronoun in X/Y/Z form. If PronounForms is a zero-value, then an empty string is returned.

func (PronounForms) SubjectObject

func (p PronounForms) SubjectObject() string

SubjectObject is similar to String, except the Possessive form is omitted.

type SelfPronounsEvent

type SelfPronounsEvent struct {
	event.EventInfo `json:"-"`

	Self   Preferred                   `json:"self"`
	Others map[matrix.UserID]Preferred `json:"others,omitempty"`
}

SelfPronounsEvent describes the xyz.diamondb.gotktrix.self_pronouns event. It is an event that others

type UserPronounsEvent

type UserPronounsEvent struct {
	event.StateEventInfo `json:"-"`

	UserID matrix.UserID `json:"user_id"`
	Preferred
}

UserPronounsEvent describes the xyz.diamondb.gotktrix.user_pronouns event. This event is propagated to rooms as a state event for a user.

Jump to

Keyboard shortcuts

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