Documentation
¶
Overview ¶
Package runtime provides the main bot logic and orchestration for the Telegram bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ToRunnable = lifecycle.ToRunnable
ToRunnable converts a Lifecycle to a Runnable.
var WithStartTimeout = lifecycle.WithStartTimeout
WithStartTimeout sets the timeout for the Start operation.
var WithStopTimeout = lifecycle.WithStopTimeout
WithStopTimeout sets the timeout for the Stop operation.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is the main bot structure.
func (*Bot) Client ¶
func (b *Bot) Client() client.ClientWithResponsesInterface
Client returns the underlying Telegram Bot API client.
func (*Bot) EventEmitter ¶
func (b *Bot) EventEmitter() eventemitter.EventEmitter
EventEmitter returns the bot's event emitter.
func (*Bot) Handlers ¶
func (b *Bot) Handlers() handlers.RegistryInterface
Handlers returns the bot's handler registry.
type OptOptionsSetter ¶
type OptOptionsSetter func(o *Options)
func WithClient ¶
func WithClient(opt client.ClientWithResponsesInterface) OptOptionsSetter
client is the Telegram API client.
func WithEventEmitter ¶
func WithEventEmitter(opt eventemitter.EventEmitter) OptOptionsSetter
eventEmitter is the event emitter to use.
func WithUpdateSource ¶
func WithUpdateSource(opt UpdateSource) OptOptionsSetter
updateSource is the update source to use.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options is the options for the Bot.
func NewOptions ¶
func NewOptions( botToken string, options ...OptOptionsSetter, ) Options
type Runnable ¶
Runnable represents a long-running process that blocks until the context is canceled or an error occurs.
type RunnableFunc ¶
type RunnableFunc = lifecycle.RunnableFunc
RunnableFunc is a function adapter for the Runnable interface.
type RunnableOption ¶
RunnableOption configures the ToRunnable adapter.
type UpdateChan ¶
UpdateChan is a channel that receives updates from the Telegram API.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package botcontext provides a mechanism to embed and retrieve bot-specific context (Client, EventEmitter, Logger) within a standard context.Context.
|
Package botcontext provides a mechanism to embed and retrieve bot-specific context (Client, EventEmitter, Logger) within a standard context.Context. |
|
Package eventemitter provides a flexible event bus implementation for handling bot events.
|
Package eventemitter provides a flexible event bus implementation for handling bot events. |
|
Package events defines the events emitted by the bot and their associated payload types.
|
Package events defines the events emitted by the bot and their associated payload types. |
|
examples
|
|
|
command
command
Package main provides an example of a bot that handles commands.
|
Package main provides an example of a bot that handles commands. |
|
pingpong
command
Package main provides a simple ping-pong bot example.
|
Package main provides a simple ping-pong bot example. |
|
webhook
command
Package main provides an example of a bot using webhooks.
|
Package main provides an example of a bot using webhooks. |
|
Package handlers provides a type-safe way to register and manage event handlers.
|
Package handlers provides a type-safe way to register and manage event handlers. |
|
Package listeners provides core event listeners for the bot, such as update classification and command parsing.
|
Package listeners provides core event listeners for the bot, such as update classification and command parsing. |
|
Package logger defines a common logging interface and provides implementations for various logging libraries.
|
Package logger defines a common logging interface and provides implementations for various logging libraries. |
|
Package messagetype provides constants and utilities for identifying the type of a Telegram message.
|
Package messagetype provides constants and utilities for identifying the type of a Telegram message. |
|
Package middleware provides various middleware implementations for the bot's event emitter.
|
Package middleware provides various middleware implementations for the bot's event emitter. |
|
Package updatepoller provides a long-polling mechanism for receiving updates from the Telegram Bot API.
|
Package updatepoller provides a long-polling mechanism for receiving updates from the Telegram Bot API. |
|
offsetstore
Package offsetstore provides implementations for storing the update offset.
|
Package offsetstore provides implementations for storing the update offset. |
|
Package webhook provides an implementation of UpdateSource using Telegram webhooks.
|
Package webhook provides an implementation of UpdateSource using Telegram webhooks. |