46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
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
|
|
}
|