Documentation
¶
Overview ¶
Package feature holds the remote-control chat features (action menu, bind flow, directory browser) that sit on top of imbot.
This file builds the action menus and confirmation keyboards. Everything in it is platform-neutral — it goes through imbot's keyboard and card builders and never names a platform. It used to be called telegram_keyboard.go, which misdescribed it: the Telegram coupling lives at the call sites that render these into a Telegram payload, not here.
Index ¶
- func BuildActionKeyboard() *imbot.KeyboardBuilder
- func BuildCancelKeyboard() *imbot.KeyboardBuilder
- func BuildCreateConfirmKeyboard(path string) (*imbot.KeyboardBuilder, string)
- func SendDirectoryBrowser(ctx context.Context, bot imbot.Bot, browser *DirectoryBrowser, chatID string, ...) (string, error)
- type BindFlowState
- type DirectoryBrowser
- func (b *DirectoryBrowser) BuildKeyboard(chatID string) (*BindFlowState, *imbot.KeyboardBuilder, string, error)
- func (b *DirectoryBrowser) Clear(chatID string)
- func (b *DirectoryBrowser) GetCurrentPath(chatID string) string
- func (b *DirectoryBrowser) GetState(chatID string) *BindFlowState
- func (b *DirectoryBrowser) IsWaitingInput(chatID string) bool
- func (b *DirectoryBrowser) Navigate(chatID string, path string) error
- func (b *DirectoryBrowser) NavigateUp(chatID string) error
- func (b *DirectoryBrowser) NextPage(chatID string) error
- func (b *DirectoryBrowser) PrevPage(chatID string) error
- func (b *DirectoryBrowser) SetMessageID(chatID string, messageID string)
- func (b *DirectoryBrowser) SetWaitingInput(chatID string, waiting bool, promptMsgID string)
- func (b *DirectoryBrowser) Start(chatID string) (*BindFlowState, error)
- func (b *DirectoryBrowser) StartAt(chatID, startPath string) (*BindFlowState, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildActionKeyboard ¶
func BuildActionKeyboard() *imbot.KeyboardBuilder
BuildActionKeyboard builds the inline keyboard for actions (Clear/Bind)
func BuildCancelKeyboard ¶
func BuildCancelKeyboard() *imbot.KeyboardBuilder
BuildCancelKeyboard builds a simple cancel keyboard
func BuildCreateConfirmKeyboard ¶
func BuildCreateConfirmKeyboard(path string) (*imbot.KeyboardBuilder, string)
BuildCreateConfirmKeyboard builds the confirmation keyboard for creating a directory
Types ¶
type BindFlowState ¶
type BindFlowState struct {
ChatID string
CurrentPath string
Page int
PageSize int
MessageID string // Message ID to edit
ExpiresAt time.Time
WaitingInput bool // Waiting for custom path input
PromptMsgID string // Prompt message ID for cleanup
}
BindFlowState represents the state of an ongoing bind flow.
It used to also cache the directory listing, because a button could not carry a path: Telegram's 64-byte callback_data forced the browser to send array indices and resolve them here. Payload segments carry the path itself now, so the snapshot — and the class of bug where a stale index resolved against a re-listed directory — is gone.
type DirectoryBrowser ¶
type DirectoryBrowser struct {
// contains filtered or unexported fields
}
DirectoryBrowser manages directory navigation for bind flow
func NewDirectoryBrowser ¶
func NewDirectoryBrowser() *DirectoryBrowser
NewDirectoryBrowser creates a new directory browser
func (*DirectoryBrowser) BuildKeyboard ¶
func (b *DirectoryBrowser) BuildKeyboard(chatID string) (*BindFlowState, *imbot.KeyboardBuilder, string, error)
BuildKeyboard builds the inline keyboard for directory browsing
func (*DirectoryBrowser) Clear ¶
func (b *DirectoryBrowser) Clear(chatID string)
Clear removes the state for a chat
func (*DirectoryBrowser) GetCurrentPath ¶
func (b *DirectoryBrowser) GetCurrentPath(chatID string) string
GetCurrentPath returns the current path for a chat
func (*DirectoryBrowser) GetState ¶
func (b *DirectoryBrowser) GetState(chatID string) *BindFlowState
GetState returns the current state for a chat
func (*DirectoryBrowser) IsWaitingInput ¶
func (b *DirectoryBrowser) IsWaitingInput(chatID string) bool
IsWaitingInput checks if the chat is waiting for custom path input
func (*DirectoryBrowser) Navigate ¶
func (b *DirectoryBrowser) Navigate(chatID string, path string) error
Navigate navigates to a subdirectory
func (*DirectoryBrowser) NavigateUp ¶
func (b *DirectoryBrowser) NavigateUp(chatID string) error
NavigateUp navigates to the parent directory
func (*DirectoryBrowser) NextPage ¶
func (b *DirectoryBrowser) NextPage(chatID string) error
NextPage moves to the next page of directories
func (*DirectoryBrowser) PrevPage ¶
func (b *DirectoryBrowser) PrevPage(chatID string) error
PrevPage moves to the previous page of directories
func (*DirectoryBrowser) SetMessageID ¶
func (b *DirectoryBrowser) SetMessageID(chatID string, messageID string)
SetMessageID sets the message ID for editing
func (*DirectoryBrowser) SetWaitingInput ¶
func (b *DirectoryBrowser) SetWaitingInput(chatID string, waiting bool, promptMsgID string)
SetWaitingInput sets the waiting for input state
func (*DirectoryBrowser) Start ¶
func (b *DirectoryBrowser) Start(chatID string) (*BindFlowState, error)
Start begins a new bind flow for a chat, starting at the home directory.
func (*DirectoryBrowser) StartAt ¶
func (b *DirectoryBrowser) StartAt(chatID, startPath string) (*BindFlowState, error)
StartAt begins a new bind flow for a chat, starting at startPath. If startPath is empty or does not exist, the browser falls back to the home directory so the user always lands somewhere navigable.