-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.go
42 lines (33 loc) · 1.65 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package bf
import (
"context"
)
type ChatBot interface {
// Start main loop of the bot. Start after register all non-dynamic handlers.
Start(ctx context.Context) error
// SendMsg sends a message to the chat. Buttons register one-time handlers.
SendMsg(chatID int64, layer *HandlerLayer) error
// SendText sends a short text message to the chat. Doesn't wipe layers.
SendText(chatID int64, text string) error
// RegisterDefaultHandler registers a handler that will be called if no other handler is found.
RegisterDefaultHandler(handler HandlerFunc)
// RegisterCommand registers a handler for a command.
RegisterCommand(command string, handler HandlerFunc)
// RegisterIButton registers a new inline button with the given text and handler function.
RegisterIButton(btn string, handler HandlerFunc)
// RegisterMiddleware middlewares before any handler that matches the filter function.
// If the filter function returns true, the middleware will be applied.
// If filterFunc is nil, the middleware will be applied to all handlers.
RegisterMiddleware(middleware MiddlewareFunc)
// NewLayer creates a new Layer of handlers necessary for SendMsg.
NewLayer(msgText ...any) *HandlerLayer
// RetryLastLayer SendMsg with the same layer as the last one.
RetryLastLayer(event Event, newText string) error
// RegisterErrorHandler sets the default handler if error happens on handler.
RegisterErrorHandler(handler ErrorHandlerFunc)
// SelfUserName returns the username of the bot.
SelfUserName() string
// LoaderButton short loader button cancel by ctx.
LoaderButton(chatID int64, loadScreen []string) context.CancelFunc
GetFileURL(fileID string) (string, error)
}