This commit is contained in:
parent
9c78ea2d48
commit
7c684af8c3
79 changed files with 3594 additions and 3257 deletions
46
internal/model/platform.go
Normal file
46
internal/model/platform.go
Normal file
|
@ -0,0 +1,46 @@
|
|||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
|
||||
"git.nakama.town/fmartingr/butterrobot/internal/config"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrPlatform is a general platform error
|
||||
ErrPlatform = errors.New("platform error")
|
||||
|
||||
// ErrPlatformInit is an error during platform initialization
|
||||
ErrPlatformInit = errors.New("platform initialization error")
|
||||
|
||||
// ErrPlatformAuth is an authentication error
|
||||
ErrPlatformAuth = errors.New("platform authentication error")
|
||||
|
||||
// ErrPlatformNotFound is returned when a requested platform doesn't exist
|
||||
ErrPlatformNotFound = errors.New("platform not found")
|
||||
)
|
||||
|
||||
// AuthResponse represents a platform authentication response
|
||||
type AuthResponse struct {
|
||||
Data map[string]any
|
||||
StatusCode int
|
||||
}
|
||||
|
||||
// Platform defines the interface all chat platforms must implement
|
||||
type Platform interface {
|
||||
// Init initializes the platform
|
||||
Init(cfg *config.Config) error
|
||||
|
||||
// ParseIncomingMessage parses the incoming HTTP request into a Message
|
||||
ParseIncomingMessage(r *http.Request) (*Message, error)
|
||||
|
||||
// ParseChannelNameFromRaw extracts a human-readable channel name from raw data
|
||||
ParseChannelNameFromRaw(channelRaw map[string]any) string
|
||||
|
||||
// ParseChannelFromMessage extracts channel data from a message
|
||||
ParseChannelFromMessage(body []byte) (map[string]any, error)
|
||||
|
||||
// SendMessage sends a message through the platform
|
||||
SendMessage(msg *Message) error
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue