hook

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: 5 Imported by: 17

Documentation

Overview

Package hook contains telegram update hook middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AffectedHook added in v0.157.0

func AffectedHook(handler AffectedHandler) telegram.Middleware

AffectedHook middleware keeps the updates manager's local pts in sync after self-initiated reads and deletes.

Methods such as messages.readHistory, messages.deleteMessages and channels.deleteMessages return messages.affectedMessages / messages.affectedHistory, which carry a pts increment the client must apply. These results are not tg.UpdatesClass, so they bypass the regular update hook; without applying them the server pts advances while the local pts stays behind, making the next genuine update look like a gap (see issue #1382).

Place it in telegram.Options.Middlewares, like UpdateHook.

Types

type AffectedHandler added in v0.157.0

type AffectedHandler interface {
	HandleAffected(ctx context.Context, channelID int64, pts, ptsCount int) error
}

AffectedHandler applies the pts increment from a messages.affected* RPC result.

It is implemented by *updates.Manager via its HandleAffected method.

type UpdateHook

type UpdateHook func(ctx context.Context, u tg.UpdatesClass) error

UpdateHook middleware is called on each tg.UpdatesClass method result.

Function is called before invoker return. Returned error will be wrapped and returned as InvokeRaw result.

func (UpdateHook) Handle

func (h UpdateHook) Handle(next tg.Invoker) telegram.InvokeFunc

Handle implements telegram.Middleware.

Jump to

Keyboard shortcuts

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