hook

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 5 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hook contains telegram update hook middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AffectedHook

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

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