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

8 years ago
8 years ago
8 years ago
  1. // Package echo implements a Service which echoes back !commands.
  2. package echo
  3. import (
  4. "strings"
  5. "github.com/matrix-org/go-neb/types"
  6. "github.com/matrix-org/gomatrix"
  7. )
  8. // ServiceType of the Echo service
  9. const ServiceType = "echo"
  10. // Service represents the Echo service. It has no Config fields.
  11. type Service struct {
  12. types.DefaultService
  13. }
  14. // Commands supported:
  15. // !echo some message
  16. // Responds with a notice of "some message".
  17. func (e *Service) Commands(cli *gomatrix.Client) []types.Command {
  18. return []types.Command{
  19. types.Command{
  20. Path: []string{"echo"},
  21. Command: func(roomID, userID string, args []string) (interface{}, error) {
  22. return &gomatrix.TextMessage{"m.notice", strings.Join(args, " ")}, nil
  23. },
  24. },
  25. }
  26. }
  27. func init() {
  28. types.RegisterService(func(serviceID, serviceUserID, webhookEndpointURL string) types.Service {
  29. return &Service{
  30. DefaultService: types.NewDefaultService(serviceID, serviceUserID, ServiceType),
  31. }
  32. })
  33. }