You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

39 lines
973 B

// Package echo implements a Service which echoes back !commands.
package echo
import (
"strings"
"github.com/matrix-org/go-neb/types"
"github.com/matrix-org/gomatrix"
)
// ServiceType of the Echo service
const ServiceType = "echo"
// Service represents the Echo service. It has no Config fields.
type Service struct {
types.DefaultService
}
// Commands supported:
// !echo some message
// Responds with a notice of "some message".
func (e *Service) Commands(cli *gomatrix.Client) []types.Command {
return []types.Command{
types.Command{
Path: []string{"echo"},
Command: func(roomID, userID string, args []string) (interface{}, error) {
return &gomatrix.TextMessage{"m.notice", strings.Join(args, " ")}, nil
},
},
}
}
func init() {
types.RegisterService(func(serviceID, serviceUserID, webhookEndpointURL string) types.Service {
return &Service{
DefaultService: types.NewDefaultService(serviceID, serviceUserID, ServiceType),
}
})
}