feat: domain blocker plugin
This commit is contained in:
parent
c9edb57505
commit
7dd02c0056
25 changed files with 898 additions and 63 deletions
|
@ -24,17 +24,26 @@ func New() *PingPlugin {
|
|||
}
|
||||
|
||||
// OnMessage handles incoming messages
|
||||
func (p *PingPlugin) OnMessage(msg *model.Message, config map[string]interface{}) []*model.Message {
|
||||
func (p *PingPlugin) OnMessage(msg *model.Message, config map[string]interface{}) []*model.MessageAction {
|
||||
if !strings.EqualFold(strings.TrimSpace(msg.Text), "ping") {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Create the response message
|
||||
response := &model.Message{
|
||||
Text: "pong",
|
||||
Chat: msg.Chat,
|
||||
ReplyTo: msg.ID,
|
||||
Channel: msg.Channel,
|
||||
}
|
||||
|
||||
// Create an action to send the message
|
||||
action := &model.MessageAction{
|
||||
Type: model.ActionSendMessage,
|
||||
Message: response,
|
||||
Chat: msg.Chat,
|
||||
Channel: msg.Channel,
|
||||
}
|
||||
|
||||
return []*model.Message{response}
|
||||
return []*model.MessageAction{action}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue