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 DialogKey ¶ added in v0.27.0
DialogKey is a generic peer key.
func (*DialogKey) FromInputPeer ¶ added in v0.27.0
func (d *DialogKey) FromInputPeer(peer tg.InputPeerClass) error
FromInputPeer fills key using given peer.
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 ¶
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 Promise ¶ added in v0.27.0
type Promise func(ctx context.Context) (tg.InputPeerClass, error)
Promise is a peer promise.
func Resolve ¶ added in v0.27.0
Resolve uses given text to create new message builder. It resolves peer of message using Sender's PeerResolver. Input examples:
@telegram telegram t.me/telegram https://t.me/telegram tg:resolve?domain=telegram tg://resolve?domain=telegram
func ResolveDeeplink ¶ added in v0.27.0
ResolveDeeplink uses given deeplink to create new message builder. Deeplink is a URL like https://t.me/telegram. It resolves peer of message using Sender's PeerResolver. Input examples:
t.me/telegram https://t.me/telegram tg:resolve?domain=telegram tg://resolve?domain=telegram
func ResolveDomain ¶ added in v0.27.0
ResolveDomain uses given domain to create new message builder. It resolves peer of message using Sender's PeerResolver. Can has prefix with @ or not. Input examples:
@telegram telegram
type Resolver ¶
Resolver is a abstraction to resolve domains and Telegram deeplinks
func DefaultResolver ¶
DefaultResolver creates and returns default resolver.
type ResolverFunc ¶
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.