messages

package
v0.157.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package messages contains a personal-messages service implementation for the tgtest server.

It implements a minimal subset of the messages.* API needed to exercise 1:1 (user-to-user) messaging end-to-end against the in-process tgtest server: sending messages (messages.sendMessage), reading them back (messages.getHistory) and delivering them to connected recipients as tg.UpdateNewMessage updates.

Only user peers (tg.InputPeerSelf and tg.InputPeerUser) are supported; chats and channels are intentionally out of scope.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Service)

Option configures Service.

func WithClock

func WithClock(c clock.Clock) Option

WithClock sets clock to use for message dates.

func WithSelfResolver

func WithSelfResolver(f func(tgtest.Session) *tg.User) Option

WithSelfResolver sets a function that assigns an identity (self user) to a session the first time it is seen.

By default each distinct auth key is assigned a fresh synthetic user with a sequential ID.

type Service

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

Service is a Telegram personal-messages service.

It is safe for concurrent use.

func NewService

func NewService(opts ...Option) *Service

NewService creates new messages Service.

func (*Service) AddUser

func (s *Service) AddUser(u *tg.User) *tg.User

AddUser registers user in the service registry and returns it.

Registered users are resolved by ID when an InputPeerUser refers to them and are included in the Users field of responses and updates.

func (*Service) Register

func (s *Service) Register(d *tgtest.Dispatcher)

Register registers service handlers in the dispatcher.

Jump to

Keyboard shortcuts

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