idmap

package
v0.0.0-...-a211759 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: ISC Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDMap

type IDMap struct {
	// contains filtered or unexported fields
}

IDMap is a map between Discord ID/name pairs and IRC names.

There may be multiple Discord names with the same name but different IDs, with different IRC names guaranteed by the map.

func New

func New() *IDMap

New creates a new IDMap.

func (*IDMap) Access

func (m *IDMap) Access(
	access func(forward map[discord.Snowflake]string,
		backward map[string]discord.Snowflake))

Access allows access to the internal storage.

Do not modify the maps. Calling any other method from inside the callback may deadlock.

func (*IDMap) DeleteSnowflake

func (m *IDMap) DeleteSnowflake(id discord.Snowflake) bool

DeleteSnowflake removes an ID from the map, returning whether it did anything.

func (*IDMap) Insert

func (m *IDMap) Insert(
	id discord.Snowflake, ideal string) (pre, post string)

Insert returns an IRC name for a given Discord ID. It returns the previous value and the new value.

It returns ideal if there were no collisions. It panics if passed an invalid ID. Passing an empty string for ideal is allowed, however.

func (*IDMap) Name

func (m *IDMap) Name(id discord.Snowflake) string

Name returns the IRC name for a Discord ID.

It returns the empty string if missing. It panics if passed an invalid snowflake.

func (*IDMap) Snowflake

func (m *IDMap) Snowflake(name string) discord.Snowflake

Snowflake returns the Discord ID from an IRC name.

It returns the zero snowflake if missing. It panics if passed the empty string.

Jump to

Keyboard shortcuts

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