telegram

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	*base.Adapter
	// contains filtered or unexported fields
}

func NewAdapter

func NewAdapter(config Config, logger *slog.Logger, opts ...base.AdapterOption) *Adapter

func (*Adapter) DeleteWebhook

func (a *Adapter) DeleteWebhook(ctx context.Context) error

func (*Adapter) Logger

func (a *Adapter) Logger() *slog.Logger

func (*Adapter) SendMessage

func (a *Adapter) SendMessage(ctx context.Context, sessionID string, msg *base.ChatMessage) error

func (*Adapter) SetLogger

func (a *Adapter) SetLogger(logger *slog.Logger)

func (*Adapter) SetSender

func (a *Adapter) SetSender(fn func(ctx context.Context, sessionID string, msg *base.ChatMessage) error)

func (*Adapter) SetWebhook

func (a *Adapter) SetWebhook(ctx context.Context) error

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context) error

func (*Adapter) Stop

func (a *Adapter) Stop() error

type Config

type Config struct {
	BotToken     string
	WebhookURL   string
	ServerAddr   string
	SecretToken  string
	SystemPrompt string
}

type MessageResponse

type MessageResponse struct {
	OK     bool `json:"ok"`
	Result *Msg `json:"result"`
}

type Msg

type Msg struct {
	MessageID int64 `json:"message_id"`
	Chat      struct {
		ID int64 `json:"id"`
	} `json:"chat"`
	Date int64  `json:"date"`
	Text string `json:"text"`
}

type RateLimiter

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

func NewRateLimiter

func NewRateLimiter(maxTokens, refillRate float64) *RateLimiter

func (*RateLimiter) Allow

func (r *RateLimiter) Allow() bool

func (*RateLimiter) Wait

func (r *RateLimiter) Wait(ctx context.Context) error

type Update

type Update struct {
	UpdateID int64 `json:"update_id"`
	Message  struct {
		MessageID int64 `json:"message_id"`
		From      struct {
			ID        int64  `json:"id"`
			FirstName string `json:"first_name"`
			LastName  string `json:"last_name"`
			Username  string `json:"username"`
		} `json:"from"`
		Chat struct {
			ID    int64  `json:"id"`
			Type  string `json:"type"`
			Title string `json:"title,omitempty"`
		} `json:"chat"`
		Date     int64  `json:"date"`
		Text     string `json:"text"`
		Entities []struct {
			Type   string `json:"type"`
			Offset int    `json:"offset"`
			Length int    `json:"length"`
		} `json:"entities,omitempty"`
	} `json:"message"`
	CallbackQuery *struct {
		ID   string `json:"id"`
		From struct {
			ID        int64  `json:"id"`
			FirstName string `json:"first_name"`
			LastName  string `json:"last_name"`
			Username  string `json:"username"`
		} `json:"from"`
		Message struct {
			Chat struct {
				ID int64 `json:"id"`
			} `json:"chat"`
			MessageID int64  `json:"message_id"`
			Data      string `json:"data"`
		} `json:"message,omitempty"`
	} `json:"callback_query,omitempty"`
}

Jump to

Keyboard shortcuts

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