telegram

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() im.AdapterFactory

NewFactory returns an im.AdapterFactory for Telegram bot channels. Supports "webhook" and "websocket" (long polling, default).

Types

type Adapter

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

Adapter implements im.Adapter for Telegram Bot API.

func NewAdapter

func NewAdapter(client *LongConnClient, botToken string) *Adapter

NewAdapter creates a Telegram adapter backed by a long-polling client.

func NewWebhookAdapter

func NewWebhookAdapter(botToken, secretToken string) *Adapter

NewWebhookAdapter creates a Telegram adapter for webhook mode.

func (*Adapter) DownloadFile

func (a *Adapter) DownloadFile(ctx context.Context, msg *im.IncomingMessage) (io.ReadCloser, string, error)

func (*Adapter) EndStream

func (a *Adapter) EndStream(ctx context.Context, incoming *im.IncomingMessage, streamID string) error

func (*Adapter) FinalizeStream

func (a *Adapter) FinalizeStream(ctx context.Context, incoming *im.IncomingMessage, streamID string, finalContent string) error

func (*Adapter) HandleURLVerification

func (a *Adapter) HandleURLVerification(c *gin.Context) bool

func (*Adapter) ParseCallback

func (a *Adapter) ParseCallback(c *gin.Context) (*im.IncomingMessage, error)

func (*Adapter) Platform

func (a *Adapter) Platform() im.Platform

func (*Adapter) SendReply

func (a *Adapter) SendReply(ctx context.Context, incoming *im.IncomingMessage, reply *im.ReplyMessage) error

func (*Adapter) SendStreamChunk

func (a *Adapter) SendStreamChunk(ctx context.Context, incoming *im.IncomingMessage, streamID string, content string) error

func (*Adapter) StartStream

func (a *Adapter) StartStream(ctx context.Context, incoming *im.IncomingMessage) (string, error)

func (*Adapter) UpdateStreamContent

func (a *Adapter) UpdateStreamContent(ctx context.Context, incoming *im.IncomingMessage, streamID string, fullContent string) error

func (*Adapter) VerifyCallback

func (a *Adapter) VerifyCallback(c *gin.Context) error

type LongConnClient

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

LongConnClient manages a Telegram long-polling connection.

func NewLongConnClient

func NewLongConnClient(botToken string, handler MessageHandler) *LongConnClient

NewLongConnClient creates a Telegram long-polling client.

func (*LongConnClient) Start

func (c *LongConnClient) Start(ctx context.Context) error

Start begins the long-polling loop. It blocks until ctx is cancelled.

type MessageHandler

type MessageHandler func(ctx context.Context, msg *im.IncomingMessage) error

MessageHandler is called when an IM message is received via long polling.

Jump to

Keyboard shortcuts

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