Browse Source

Merge pull request #142 from matrix-org/kegan/gh-help

Add "!github help" and fix command selection bug
pull/147/head
Kegsay 8 years ago
committed by GitHub
parent
commit
5abfa281f5
  1. 4
      src/github.com/matrix-org/go-neb/clients/clients.go
  2. 9
      src/github.com/matrix-org/go-neb/services/github/github.go

4
src/github.com/matrix-org/go-neb/clients/clients.go

@ -215,11 +215,11 @@ func (c *Clients) onMessageEvent(client *gomatrix.Client, event *gomatrix.Event)
// response is appropriate.
func runCommandForService(cmds []types.Command, event *gomatrix.Event, arguments []string) interface{} {
var bestMatch *types.Command
for _, command := range cmds {
for i, command := range cmds {
matches := command.Matches(arguments)
betterMatch := bestMatch == nil || len(bestMatch.Path) < len(command.Path)
if matches && betterMatch {
bestMatch = &command
bestMatch = &cmds[i]
}
}

9
src/github.com/matrix-org/go-neb/services/github/github.go

@ -163,6 +163,15 @@ func (s *Service) Commands(cli *gomatrix.Client) []types.Command {
return s.cmdGithubCreate(roomID, userID, args)
},
},
types.Command{
Path: []string{"github", "help"},
Command: func(roomID, userID string, args []string) (interface{}, error) {
return &gomatrix.TextMessage{
"m.notice",
fmt.Sprintf(`!github create owner/repo "title text" "description text"`),
}, nil
},
},
}
}

Loading…
Cancel
Save