session

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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidSnowflake = errors.New("invalid snowflake given")
View Source
var ErrNoChannel = errors.New("no channel by that name exists")

Functions

This section is empty.

Types

type ChannelNameChange

type ChannelNameChange struct {
	ID  discord.Snowflake
	Old string
	New string
}

type RemoveFunc

type RemoveFunc func(s *Session)

RemoveFunc is a function type used to remove a Session from some storage when Close is called.

type Session

type Session struct {
	*ningen.State
	// contains filtered or unexported fields
}

Session is the reference-counted shared state between all clients for a Discord user.

func New

func New(token string, debug bool, removeFunc RemoveFunc) (*Session, error)

New creates a new Session. removeFunc is a function that will called on Close.

func (*Session) ChannelFromName

func (s *Session) ChannelFromName(guild discord.Snowflake,
	name string) discord.Snowflake

ChannelFromName returns the Discord channel for a given IRC channel name.

func (*Session) ChannelName

func (s *Session) ChannelName(guild discord.Snowflake,
	id discord.Snowflake) (string, error)

ChannelName returns the IRC channel name for the given Discord channel ID.

func (*Session) Close

func (s *Session) Close() error

Close calls the remove function given in New then closes the Discord connection.

func (*Session) Messages

func (s *Session) Messages(
	channelID discord.Snowflake) ([]discord.Message, error)

Messages overrides (*ningen.State).Messages. It is a temporary hack to process the users and members in a message before posting it, to avoid messages being sent before joins.

func (*Session) Ref

func (s *Session) Ref()

Ref increments the reference count.

func (*Session) Run

func (s *Session) Run() error

Run does nothing for now.

func (*Session) SubscribeUserList

func (s *Session) SubscribeUserList(guild discord.Snowflake,
	handler func(*UserNameChange)) (cancel func())

While IsInitial is true, the callback will only be called in one goroutine. This function blocks until all events with IsInitial are sent.

func (*Session) Unref

func (s *Session) Unref() error

Unref decrements the reference count, calling Close if it hits zero.

func (*Session) UserFromName

func (s *Session) UserFromName(guild discord.Snowflake,
	name string) discord.Snowflake

UserFromName returns the Discord user for the given IRC nickname.

func (*Session) UserName

func (s *Session) UserName(guild discord.Snowflake,
	id discord.Snowflake) (string, error)

UserName returns the IRC nickname for the given Discord user.

type UserNameChange

type UserNameChange struct {
	GuildID   discord.Snowflake
	ID        discord.Snowflake
	Old       string // can be empty
	New       string // can be empty
	IsInitial bool
}

Jump to

Keyboard shortcuts

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