Documentation
¶
Overview ¶
Package teled implements Telegram Server in Go.
Index ¶
Constants ¶
const ( BotFatherStepNewBotName = "newbot_name" // awaiting the new bot's display name BotFatherStepNewBotUsername = "newbot_username" // awaiting the new bot's username BotFatherStepRevokeSelect = "revoke_select" // awaiting which bot's token to revoke )
BotFather conversation steps. An empty step means no flow is in progress.
const BotFatherID int64 = 93372553
BotFatherID is the fixed user id of the built-in BotFather account. It mirrors real Telegram's BotFather id and is seeded by migration.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotCommand ¶ added in v0.4.0
BotCommand is one entry in a bot's published command list.
type BotFatherState ¶ added in v0.4.0
type BotFatherState struct {
Step string
DraftName string // the pending bot name captured during /newbot
}
BotFatherState is a user's position in a multi-step BotFather flow.
type DeleteResult ¶
type DeleteResult struct {
Pts int
PtsCount int
LocalIDs []int64 // the caller's local ids actually deleted
}
DeleteResult is the outcome of deleting messages.
type EditResult ¶
type EditResult struct {
SelfLocalID int64
SelfPts int
PeerUserID int64
PeerLocalID int64 // 0 when the peer has no copy (self-chat)
PeerPts int
Date time.Time
EditDate time.Time
}
EditResult is the outcome of editing a message.
type File ¶
type File struct {
ID int64
OwnerUserID int64
AccessHash int64
ObjectKey string
Size int64
Mime string
SHA256 []byte
FileReference []byte
Kind string // "photo" or "document"
CreatedAt time.Time
}
File is stored media metadata. The blob lives in the ObjectStore at ObjectKey.
type Message ¶
type Message struct {
GlobalID int64 // canonical id, shared by both participants
LocalID int64 // viewer's per-account message id
FromUserID int64 // sender
PeerUserID int64 // the other party in the conversation
Out bool // true if the viewer is the sender
Text string // message text
Date time.Time // sent time
EditDate time.Time // zero if never edited
RandomID int64 // sender-provided dedup id
Media *File // attached media, nil when text-only
}
Message is a DM message from the perspective of one account (the viewer).
type ObjectInfo ¶
type ObjectInfo struct {
// Size is the object size in bytes.
Size int64
}
ObjectInfo describes a stored object.
type ObjectStore ¶
type ObjectStore interface {
// Put stores r under key. size is the exact number of bytes in r.
Put(ctx context.Context, key string, r io.Reader, size int64, opt PutOptions) error
// Get returns the full object. The caller must Close the reader.
Get(ctx context.Context, key string) (io.ReadCloser, error)
// GetRange returns length bytes starting at offset. It is the primitive
// behind upload.getFile chunking. The caller must Close the reader.
GetRange(ctx context.Context, key string, offset, length int64) (io.ReadCloser, error)
// Stat returns object metadata.
Stat(ctx context.Context, key string) (ObjectInfo, error)
// Delete removes the object. Deleting a missing object is not an error.
Delete(ctx context.Context, key string) error
}
ObjectStore is an S3-shaped blob store for media (photos, documents, video). Keys are opaque; callers use content-addressed keys. The local-filesystem implementation lives in internal/objstore; an S3-compatible backend can be added behind the same interface.
type PutOptions ¶
type PutOptions struct {
// ContentType is an advisory MIME type. Backends may ignore it; the
// authoritative MIME is tracked in the files table.
ContentType string
}
PutOptions are optional parameters for ObjectStore.Put.
type SentMessage ¶
type SentMessage struct {
GlobalID int64
Date time.Time
SenderLocalID int64
SenderPts int
RecipientLocalID int64
RecipientPts int
SelfChat bool // true when sender == peer (no separate recipient copy)
}
SentMessage is the result of persisting a DM: the per-account local ids and pts allocated for each participant.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
teled
command
Binary teled implements Telegram Server in Go.
|
Binary teled implements Telegram Server in Go. |
|
Package gorules contains ruleguard linter rules.
|
Package gorules contains ruleguard linter rules. |
|
internal
|
|
|
cmd
Package cmd implements commands of teled binary.
|
Package cmd implements commands of teled binary. |
|
db
Package db implements PostgreSQL-backed storage for teled.
|
Package db implements PostgreSQL-backed storage for teled. |
|
key
Package key implements RSA private key management.
|
Package key implements RSA private key management. |
|
mtproto
Package mtproto implements a custom MTProto server for teled.
|
Package mtproto implements a custom MTProto server for teled. |
|
objstore
Package objstore provides ObjectStore implementations.
|
Package objstore provides ObjectStore implementations. |
|
obs
Package obs holds small helpers shared by the OpenTelemetry instrumentation across teled's internal packages.
|
Package obs holds small helpers shared by the OpenTelemetry instrumentation across teled's internal packages. |
|
pgtest
Package pgtest provides a throwaway PostgreSQL container for tests.
|
Package pgtest provides a throwaway PostgreSQL container for tests. |
|
queue
Package queue wires the River background job queue over PostgreSQL.
|
Package queue wires the River background job queue over PostgreSQL. |
|
rpc
Package rpc implements teled's Telegram RPC handlers over tg.ServerDispatcher.
|
Package rpc implements teled's Telegram RPC handlers over tg.ServerDispatcher. |
|
Package server assembles teled's storage, RPC handlers and MTProto transport into a single embeddable Telegram server.
|
Package server assembles teled's storage, RPC handlers and MTProto transport into a single embeddable Telegram server. |
|
Package teledtest runs a real teled Telegram server in-process for tests.
|
Package teledtest runs a real teled Telegram server in-process for tests. |
