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.

36 lines
989 B

  1. package services
  2. import (
  3. "github.com/matrix-org/go-neb/matrix"
  4. "github.com/matrix-org/go-neb/plugin"
  5. "github.com/matrix-org/go-neb/types"
  6. "strings"
  7. )
  8. type echoService struct {
  9. types.DefaultService
  10. id string
  11. serviceUserID string
  12. }
  13. func (e *echoService) ServiceUserID() string { return e.serviceUserID }
  14. func (e *echoService) ServiceID() string { return e.id }
  15. func (e *echoService) ServiceType() string { return "echo" }
  16. func (e *echoService) Plugin(cli *matrix.Client, roomID string) plugin.Plugin {
  17. return plugin.Plugin{
  18. Commands: []plugin.Command{
  19. plugin.Command{
  20. Path: []string{"echo"},
  21. Command: func(roomID, userID string, args []string) (interface{}, error) {
  22. return &matrix.TextMessage{"m.notice", strings.Join(args, " ")}, nil
  23. },
  24. },
  25. },
  26. }
  27. }
  28. func init() {
  29. types.RegisterService(func(serviceID, serviceUserID, webhookEndpointURL string) types.Service {
  30. return &echoService{id: serviceID, serviceUserID: serviceUserID}
  31. })
  32. }