Skip to content

Commit

Permalink
Fix slack username read (excluding @ symbol)
Browse files Browse the repository at this point in the history
  • Loading branch information
thoeni committed Sep 6, 2017
1 parent a587300 commit 0d6c8ef
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion slack_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ func slackRequestHandler(w http.ResponseWriter, r *http.Request) {
sr, _ := subscribeCommand(slackCommandArgs, *slackReq)
w.WriteHeader(http.StatusOK)
encoder.Encode(sr)
case "version":
sr, _ := versionCommand(slackCommandArgs, *slackReq)
w.WriteHeader(http.StatusOK)
encoder.Encode(sr)
default:
sr := NewEphemeral()
sr.Text = fmt.Sprintf("Unrecognised command: %s", slackCommand)
Expand All @@ -81,6 +85,12 @@ func slackRequestHandler(w http.ResponseWriter, r *http.Request) {
}
}

func versionCommand(slackCommandArgs []string, slackRequest slackRequest) (*slackResponse, error) {
var r slackResponse = NewEphemeral()
r.Text = fmt.Sprintf("Slack Tube Service - %s [%s]", AppVersion, Sha)
return &r, nil
}

func statusCommand(slackCommandArgs []string, slackRequest slackRequest) (*slackResponse, error) {

var r slackResponse = NewEphemeral()
Expand Down Expand Up @@ -123,7 +133,7 @@ func forCommand(slackCommandArgs []string, slackRequest slackRequest) (*slackRes
var r slackResponse = NewEphemeral()

user := slackCommandArgs[0]
id := fmt.Sprintf("%s-%s", slackRequest.TeamID, user)
id := fmt.Sprintf("%s-%s", slackRequest.TeamID, user[1:])

lines, err := getLinesFor(id)
if err != nil {
Expand Down

0 comments on commit 0d6c8ef

Please sign in to comment.