peer

package
v0.26.3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2021 License: MIT Imports: 4 Imported by: 30

Documentation

Overview

Package peer conatains some peer resolving and extracting helpers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entities

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

Entities is simple peer entities storage.

func EntitiesFromResult

func EntitiesFromResult(r EntitySearchResult) Entities

EntitiesFromResult fills Entities struct using given context.

func EntitiesFromUpdate

func EntitiesFromUpdate(uctx tg.UpdateContext) Entities

EntitiesFromUpdate fills Entities struct using given context.

func NewEntities

func NewEntities(
	users map[int]*tg.User,
	chats map[int]*tg.Chat,
	channels map[int]*tg.Channel,
) Entities

NewEntities creates new Entities struct.

func (Entities) ExtractPeer

func (ent Entities) ExtractPeer(peerID tg.PeerClass) (tg.InputPeerClass, error)

ExtractPeer finds and creates InputPeerClass using given PeerClass.

func (Entities) Fill

func (ent Entities) Fill(
	users map[int]*tg.User,
	chats map[int]*tg.Chat,
	channels map[int]*tg.Channel,
)

Fill adds and updates all entities from given maps.

func (Entities) FillFromResult

func (ent Entities) FillFromResult(r EntitySearchResult)

FillFromResult adds and updates all entities from given result.

func (Entities) FillFromUpdate

func (ent Entities) FillFromUpdate(uctx tg.UpdateContext)

FillFromUpdate adds and updates all entities from given updates.

type EntitySearchResult

type EntitySearchResult interface {
	MapChats() tg.ChatClassArray
	MapUsers() tg.UserClassArray
}

EntitySearchResult is abstraction for different RPC responses which contains entities.

type LRUResolver

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

LRUResolver is simple decorator for Resolver to cache result in LRU.

func NewLRUResolver

func NewLRUResolver(next Resolver, capacity int) *LRUResolver

NewLRUResolver creates new LRUResolver.

func (*LRUResolver) Resolve

func (l *LRUResolver) Resolve(ctx context.Context, domain string) (tg.InputPeerClass, error)

Resolve implements Resolver.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, domain string) (tg.InputPeerClass, error)
}

Resolver is a abstraction to resolve domains and Telegram deeplinks

func DefaultResolver

func DefaultResolver(raw *tg.Client) Resolver

DefaultResolver creates and returns default resolver.

type ResolverFunc

type ResolverFunc func(ctx context.Context, domain string) (tg.InputPeerClass, error)

ResolverFunc is a functional adapter for Resolver.

func (ResolverFunc) Resolve

func (p ResolverFunc) Resolve(ctx context.Context, domain string) (tg.InputPeerClass, error)

Resolve implements Resolver.

Jump to

Keyboard shortcuts

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