feat: domain blocker plugin
This commit is contained in:
parent
c9edb57505
commit
7dd02c0056
25 changed files with 898 additions and 63 deletions
|
@ -4,6 +4,26 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// ActionType defines the type of action to perform
|
||||
type ActionType string
|
||||
|
||||
const (
|
||||
// ActionSendMessage is for sending a message to the chat
|
||||
ActionSendMessage ActionType = "send_message"
|
||||
// ActionDeleteMessage is for deleting a message from the chat
|
||||
ActionDeleteMessage ActionType = "delete_message"
|
||||
)
|
||||
|
||||
// MessageAction represents an action to be performed on the platform
|
||||
type MessageAction struct {
|
||||
Type ActionType
|
||||
Message *Message // For send_message
|
||||
MessageID string // For delete_message
|
||||
Chat string // Chat where the action happens
|
||||
Channel *Channel // Channel reference
|
||||
Raw map[string]interface{} // Additional data for the action
|
||||
}
|
||||
|
||||
// Message represents a chat message
|
||||
type Message struct {
|
||||
Text string
|
||||
|
@ -75,7 +95,7 @@ type ChannelPlugin struct {
|
|||
ChannelID int64
|
||||
PluginID string
|
||||
Enabled bool
|
||||
Config map[string]interface{}
|
||||
Config map[string]any
|
||||
}
|
||||
|
||||
// User represents an admin user
|
||||
|
|
|
@ -43,4 +43,7 @@ type Platform interface {
|
|||
|
||||
// SendMessage sends a message through the platform
|
||||
SendMessage(msg *Message) error
|
||||
|
||||
// DeleteMessage deletes a message from the platform
|
||||
DeleteMessage(channel string, messageID string) error
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ type Plugin interface {
|
|||
// RequiresConfig indicates if the plugin requires configuration
|
||||
RequiresConfig() bool
|
||||
|
||||
// OnMessage processes an incoming message and returns response messages
|
||||
OnMessage(msg *Message, config map[string]interface{}) []*Message
|
||||
// OnMessage processes an incoming message and returns platform actions
|
||||
OnMessage(msg *Message, config map[string]interface{}) []*MessageAction
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue