app

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.2"

Variables

View Source
var ErrNotLoggedIn = errors.New("not logged in")

ErrNotLoggedIn means the session is not authorized and no headless credentials were supplied; the user should run `<cmd> initialize`.

Functions

func BotOptions added in v0.1.1

func BotOptions(cfg *config.Config) bot.Options

BotOptions derives the companion bot settings from cfg. initialize uses it too, so its login lands in the session file run reads.

func EnsureAuth

func EnsureAuth(ctx context.Context, client *telegram.Client) error

EnsureAuth returns nil when the session is authorized, logs in headlessly when PAPERVALET_PHONE is set, and returns ErrNotLoggedIn otherwise.

func NewTelegramClient added in v0.1.1

func NewTelegramClient(cfg *config.Config, h telegram.UpdateHandler) *telegram.Client

NewTelegramClient builds the gotd client with PaperValet's device info. initialize uses it too, so the login session matches what run expects.

Types

type App

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

App is the top-level orchestrator.

func New

func New(cfg *config.Config) (*App, error)

func (*App) GetI18n

func (a *App) GetI18n() *i18n.Manager

GetI18n returns the i18n manager.

func (*App) GetPluginLoader

func (a *App) GetPluginLoader() *loader.Loader

GetPluginLoader returns the external plugin loader.

func (*App) Run

func (a *App) Run(ctx context.Context) error

Run connects, authenticates, loads plugins, and blocks until ctx is cancelled.

func (*App) SetConfigPath added in v0.1.1

func (a *App) SetConfigPath(path string)

SetConfigPath tells the backup plugin which config file to include.

func (*App) Shutdown

func (a *App) Shutdown(ctx context.Context) error

Shutdown gracefully stops the app.

type PeerRegistry added in v0.1.1

type PeerRegistry interface {
	RegisterPeer(peerID, accessHash int64, peerType string)
}

PeerRegistry receives access hashes harvested from updates.

type UpdateHandler

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

UpdateHandler processes Telegram updates and emits events.

func NewUpdateHandler

func NewUpdateHandler(bus *eventbus.Bus) *UpdateHandler

func (*UpdateHandler) Handle

func (h *UpdateHandler) Handle(ctx context.Context, u tg.UpdatesClass) error

func (*UpdateHandler) SetPeerRegistry added in v0.1.1

func (h *UpdateHandler) SetPeerRegistry(r PeerRegistry)

SetPeerRegistry wires the cache that learns access hashes from updates. Without it, replies in channels and supergroups fail with CHANNEL_INVALID.

func (*UpdateHandler) SetSelfUserID

func (h *UpdateHandler) SetSelfUserID(id int64)

Jump to

Keyboard shortcuts

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