Documentation
¶
Index ¶
- Constants
- type Adapter
- func (a *Adapter) EditMessage(_ context.Context, externalID, messageID string, msg adapter.OutgoingMessage) error
- func (a *Adapter) EditText(_ context.Context, externalID, messageID, text, parseMode string) error
- func (a *Adapter) IsAllowed(userID int64) bool
- func (a *Adapter) IsDebug(chatID int64) bool
- func (a *Adapter) IsDebugByExternalID(externalID string) bool
- func (a *Adapter) Name() string
- func (a *Adapter) RegisterSkillCommands(skillCmds []SkillCommand)
- func (a *Adapter) Send(ctx context.Context, msg adapter.OutgoingMessage) error
- func (a *Adapter) SendAndGetID(ctx context.Context, msg adapter.OutgoingMessage) (string, error)
- func (a *Adapter) SendTyping(_ context.Context, externalID string) error
- func (a *Adapter) SetCallbackResolver(r adapter.CallbackResolver)
- func (a *Adapter) Start(ctx context.Context, incoming chan<- adapter.IncomingMessage) error
- func (a *Adapter) Stop() error
- type SkillCommand
- type VoiceOpts
Constants ¶
const MessageChunkLimit = 3500
MessageChunkLimit is the largest chunk the adapter will send, in bytes of rendered HTML.
Telegram's own cap is 4096 characters of the entity-stripped text, counted in UTF-16 code units. Counting raw HTML bytes over-counts against that, which is conservative and costs only the occasional extra message.
Exported because the dispatcher's activity log builds Telegram HTML and chunks it itself, against this same number. Sharing the constant keeps the two from drifting apart, which is all it does — they previously carried the same literal with nothing tying them together.
It does not make the two budgets equivalent, and nothing here should be read as saying the activity log is bounded because it shares this constant. That path measures its accumulated lines, then appends an approval section budgeted in unescaped runes which HTML escaping can expand several times over, and it forwards the result with an explicit parse mode — which this adapter sends unchunked by contract. A single message over Telegram's cap is the outcome, and the fix belongs where the length is decided, not here.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
func (*Adapter) EditMessage ¶ added in v0.30.5
func (a *Adapter) EditMessage(_ context.Context, externalID, messageID string, msg adapter.OutgoingMessage) error
EditMessage edits both the text and inline keyboard of an existing Telegram message. Implements adapter.MessageEditor. When msg.Buttons is empty, the existing keyboard is removed.
func (*Adapter) EditText ¶ added in v0.16.10
EditText edits an existing Telegram message. Implements adapter.MessageEditor.
func (*Adapter) IsDebug ¶ added in v0.16.10
IsDebug reports whether the given chat has debug mode enabled.
func (*Adapter) IsDebugByExternalID ¶ added in v0.16.10
IsDebugByExternalID is a convenience wrapper that parses an ExternalID string.
func (*Adapter) RegisterSkillCommands ¶ added in v0.28.0
func (a *Adapter) RegisterSkillCommands(skillCmds []SkillCommand)
RegisterSkillCommands updates the Telegram bot's command menu to include both the built-in commands and the provided skill command triggers. Call this after adapter construction and skill loading, before Start.
func (*Adapter) SendAndGetID ¶ added in v0.16.10
SendAndGetID sends a message and returns the Telegram message ID as a string. Implements adapter.MessageEditor.
func (*Adapter) SendTyping ¶ added in v0.15.0
func (*Adapter) SetCallbackResolver ¶
func (a *Adapter) SetCallbackResolver(r adapter.CallbackResolver)
SetCallbackResolver sets the resolver used to handle inline keyboard button clicks (callback queries). Call this after adapter construction, before Start.
type SkillCommand ¶ added in v0.28.0
SkillCommand represents a skill's command trigger for registration.
type VoiceOpts ¶
type VoiceOpts struct {
STT voice.STTProvider
TTS voice.TTSProvider
TTSVoice string
AutoVoiceReply bool
}
VoiceOpts configures optional voice (STT/TTS) support for the adapter.